From 66f38cc91c6406d86fbea5a48f07ae6893f7c0d9 Mon Sep 17 00:00:00 2001 From: Matthew Faltys Date: Mon, 5 Mar 2018 09:31:16 -0600 Subject: [PATCH] Update dice and d20 to be more efficient --- lorebot/lorebot.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lorebot/lorebot.go b/lorebot/lorebot.go index b5ab538..3d4a8d1 100644 --- a/lorebot/lorebot.go +++ b/lorebot/lorebot.go @@ -306,11 +306,8 @@ func rollhandler(rtm *slack.RTM, ev *slack.MessageEvent) { func dicerollhandler(rtm *slack.RTM, ev *slack.MessageEvent) { //fmt.Print(rand.Intn(100)) - dice := []int{1, 2, 3, 4, 5, 6} rand.Seed(time.Now().UnixNano()) - rndStr := fmt.Sprintf("%d", dice[rand.Intn(len(dice)-1)]) - - rtm.SendMessage(rtm.NewOutgoingMessage(rndStr, ev.Channel)) + rtm.SendMessage(rtm.NewOutgoingMessage(fmt.Sprintf("%d", rand.Intn(6)+1), ev.Channel)) } func rrhandler(rtm *slack.RTM, ev *slack.MessageEvent) { @@ -324,11 +321,8 @@ func rrhandler(rtm *slack.RTM, ev *slack.MessageEvent) { func d20handler(rtm *slack.RTM, ev *slack.MessageEvent) { //fmt.Print(rand.Intn(100)) - dice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20} rand.Seed(time.Now().UnixNano()) - rndStr := fmt.Sprintf("%d", dice[rand.Intn(len(dice)-1)]) - - rtm.SendMessage(rtm.NewOutgoingMessage(rndStr, ev.Channel)) + rtm.SendMessage(rtm.NewOutgoingMessage(fmt.Sprintf("%d", rand.Intn(20)+1), ev.Channel)) } func depricatedrnghandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *redis.Client) {