bb/bot/commands/coin.go

30 lines
437 B
Go
Raw Normal View History

2022-09-06 05:00:47 +00:00
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
}