Browse Source

Update dice and d20 to be more efficient

develop
Matthew Faltys 7 years ago
parent
commit
66f38cc91c
  1. 10
      lorebot/lorebot.go

10
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) {

Loading…
Cancel
Save