Browse Source

Update roulette logic

master
Matthew Faltys 3 years ago
parent
commit
76c084faef
  1. 23
      lorebot/lorebot.go

23
lorebot/lorebot.go

@ -37,7 +37,8 @@ type Config struct {
} }
var ( var (
config = Config{} config = Config{}
rrCylinder int
) )
func main() { func main() {
@ -52,6 +53,9 @@ func main() {
lines := strings.Split(string(credentials), "\n") lines := strings.Split(string(credentials), "\n")
auth := lines[0] auth := lines[0]
// seed the rr cylinder
rrCylinder = rand.Intn(6-1) + 1
// Create a new Discord session using the provided bot token. // Create a new Discord session using the provided bot token.
goBot, err := discordgo.New("Bot " + auth) goBot, err := discordgo.New("Bot " + auth)
if err != nil { if err != nil {
@ -373,11 +377,18 @@ func rollHandler(s *discordgo.Session, m *discordgo.MessageCreate) {
} }
func rrHandler(s *discordgo.Session, m *discordgo.MessageCreate) { func rrHandler(s *discordgo.Session, m *discordgo.MessageCreate) {
dice := []string{"*click*", "*BANG*", "*click*", "*click*", "*click*", "*click*"} // decriment counter
rand.Seed(time.Now().UnixNano()) rrCylinder = rrCylinder - 1
rndStr := dice[rand.Intn(len(dice)-1)]
// check if we are at 0
s.ChannelMessageSend(m.ChannelID, rndStr) if rrCylinder == 0 {
// you've been hit by, you've been struck by a smooth bore
s.ChannelMessageSend(m.ChannelID, "*BANG*")
s.ChannelMessageSend(m.ChannelID, "https://i.imgur.com/9jWcCyt.gifv")
rrCylinder = rand.Intn(6-1) + 1
} else {
s.ChannelMessageSend(m.ChannelID, "*click*")
}
} }
func diceRollHandler(s *discordgo.Session, m *discordgo.MessageCreate) { func diceRollHandler(s *discordgo.Session, m *discordgo.MessageCreate) {

Loading…
Cancel
Save