bb/bot/commands/coin.go
Ryan Cavicchioni 7127f8c1ae
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
Refactor commands to use the router
2022-09-06 00:00:47 -05:00

30 lines
437 B
Go

package commands
import (
"git.kill0.net/chill9/beepboop/bot"
"git.kill0.net/chill9/beepboop/lib"
)
type Coin bool
func (c *Coin) Flip() bool {
*c = Coin(lib.Itob(lib.RandInt(0, 1)))
return bool(*c)
}
func CoinCommand(cmd *bot.Command, args []string) error {
var (
c Coin
msg string
)
if c.Flip() {
msg = "heads"
} else {
msg = "tails"
}
cmd.Session.ChannelMessageSend(cmd.Message.ChannelID, msg)
return nil
}