1
0

legacy hats function

This commit is contained in:
2020-12-08 11:38:12 +01:00
parent cdb4b6f454
commit 804ed6ee5b
2 changed files with 17 additions and 0 deletions

View File

@ -58,6 +58,18 @@ func MessageHandler(s *discordgo.Session, m *discordgo.MessageCreate) {
} }
} }
func MessageHat(s *discordgo.Session, m *discordgo.MessageCreate, message string) {
hat := []string{"🧢", "👒", "⛑", "🎩", "🎓"}
rand.Seed(time.Now().UnixNano())
var amount int = rand.Intn(len(hat))
var bag []string
for i := 0; i < amount; i++ {
rand.Seed(time.Now().UnixNano())
bag = append(bag, hat[rand.Intn(len(hat))])
}
s.ChannelMessageSend(m.ChannelID, strings.Join(bag, " "))
}
func MessageTalkback(s *discordgo.Session, m *discordgo.MessageCreate) { func MessageTalkback(s *discordgo.Session, m *discordgo.MessageCreate) {
if m.Author.ID == s.State.User.ID { if m.Author.ID == s.State.User.ID {
return return

View File

@ -34,6 +34,11 @@ func main() {
"*Display the available list of commands*", "*Display the available list of commands*",
"`/ggd [help|info]`", "`/ggd [help|info]`",
core.MessageHelp) core.MessageHelp)
core.SetCommand(
[]string{"/ggd hat", "/ggd chapeau", "/ggd chapo"},
"*Hand over a set of fancy hats*",
"`/ggd [hat|chapeau|chapo]`",
core.MessageHat)
discord.AddHandler(core.MessageHandler) discord.AddHandler(core.MessageHandler)
discord.AddHandler(core.MessageTalkback) discord.AddHandler(core.MessageTalkback)