From a48e1c8db16105bdfd50d06d89098a35f150014b Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Wed, 11 Jul 2018 01:04:58 +0900 Subject: [PATCH] Fixed command invocation --- bots/discord/OnMessageCreate.go | 1 + bots/discord/commands/AnimeList.go | 2 +- bots/discord/commands/AnimeSearch.go | 2 +- bots/discord/commands/Play.go | 2 +- bots/discord/commands/Region.go | 12 ++++++------ bots/discord/commands/Roles.go | 25 +++++++++++++++++++++++++ 6 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 bots/discord/commands/Roles.go diff --git a/bots/discord/OnMessageCreate.go b/bots/discord/OnMessageCreate.go index 81660203..2cad66c6 100644 --- a/bots/discord/OnMessageCreate.go +++ b/bots/discord/OnMessageCreate.go @@ -15,6 +15,7 @@ var allCommands = []Command{ commands.Play, commands.RandomQuote, commands.Region, + commands.Roles, commands.Source, } diff --git a/bots/discord/commands/AnimeList.go b/bots/discord/commands/AnimeList.go index 17fac43b..6cf39b28 100644 --- a/bots/discord/commands/AnimeList.go +++ b/bots/discord/commands/AnimeList.go @@ -8,7 +8,7 @@ import ( // AnimeList shows the link for the anime list of a user. func AnimeList(s *discordgo.Session, msg *discordgo.MessageCreate) bool { - if strings.HasPrefix(msg.Content, "!animelist ") { + if !strings.HasPrefix(msg.Content, "!animelist ") { return false } diff --git a/bots/discord/commands/AnimeSearch.go b/bots/discord/commands/AnimeSearch.go index d2ed7cf9..87921bd1 100644 --- a/bots/discord/commands/AnimeSearch.go +++ b/bots/discord/commands/AnimeSearch.go @@ -9,7 +9,7 @@ import ( // AnimeSearch shows the link for the anime list of a user. func AnimeSearch(s *discordgo.Session, msg *discordgo.MessageCreate) bool { - if strings.HasPrefix(msg.Content, "!a ") { + if !strings.HasPrefix(msg.Content, "!a ") { return false } diff --git a/bots/discord/commands/Play.go b/bots/discord/commands/Play.go index 58bb1952..ca6ce2ff 100644 --- a/bots/discord/commands/Play.go +++ b/bots/discord/commands/Play.go @@ -8,7 +8,7 @@ import ( // Play changes the status of the bot. func Play(s *discordgo.Session, msg *discordgo.MessageCreate) bool { - if strings.HasPrefix(msg.Content, "!play ") { + if !strings.HasPrefix(msg.Content, "!play ") { return false } diff --git a/bots/discord/commands/Region.go b/bots/discord/commands/Region.go index c42a3e59..2fccb17c 100644 --- a/bots/discord/commands/Region.go +++ b/bots/discord/commands/Region.go @@ -7,16 +7,16 @@ import ( ) var regions = map[string]string{ - "africa": "465876853236826112", - "america": "465876808311635979", - "asia": "465876834031108096", - "australia": "465876893036707840", - "europe": "465876773029019659", + "africa": "465387147629953034", + "america": "465386843706359840", + "asia": "465386826006528001", + "australia": "465387169888862230", + "europe": "465386794914152448", } // Region sets the specific region role for the user. func Region(s *discordgo.Session, msg *discordgo.MessageCreate) bool { - if strings.HasPrefix(msg.Content, "!region ") { + if !strings.HasPrefix(msg.Content, "!region ") { return false } diff --git a/bots/discord/commands/Roles.go b/bots/discord/commands/Roles.go new file mode 100644 index 00000000..4cf544cd --- /dev/null +++ b/bots/discord/commands/Roles.go @@ -0,0 +1,25 @@ +package commands + +import ( + "fmt" + + "github.com/bwmarrin/discordgo" +) + +// Guild ID +const guildID = "134910939140063232" + +// Roles prints out all roles. +func Roles(s *discordgo.Session, msg *discordgo.MessageCreate) bool { + if msg.Content != "!roles" { + return false + } + + roles, _ := s.GuildRoles(guildID) + + for _, role := range roles { + s.ChannelMessageSend(msg.ChannelID, fmt.Sprintf("%s: %s", role.ID, role.Name)) + } + + return true +}