Fixed command invocation

This commit is contained in:
Eduard Urbach 2018-07-11 01:04:58 +09:00
parent 009449316e
commit a48e1c8db1
6 changed files with 35 additions and 9 deletions

View File

@ -15,6 +15,7 @@ var allCommands = []Command{
commands.Play,
commands.RandomQuote,
commands.Region,
commands.Roles,
commands.Source,
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}