Skip to content

Commit

Permalink
minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jrhackett committed Sep 22, 2018
1 parent 5c7605e commit 06528ed
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,24 @@ func readyHandler(discord *discordgo.Session, ready *discordgo.Ready) {
}

func commandHandler(discord *discordgo.Session, message *discordgo.MessageCreate) {
user := message.Author
if user.ID == botID || user.Bot {
//Do nothing because the bot is talking
if message.Author.ID == botID || message.Author.Bot {
// Do nothing because the bot is talking
return
} else if strings.HasPrefix(message.Content, "!") {
split := strings.Split(message.Content, " ")
switch split[0] {
case "!register":
if len(split) > 1 {
discord.ChannelMessageSend(message.ChannelID, "Registered "+split[1])
} else {
discord.ChannelMessageSend(message.ChannelID, "Need to specify a username to register")
}
registerTwitchHandler(discord, message, split)
case "!status":
discord.ChannelMessageSend(message.ChannelID, "Status is WIP")
}
}
}

func registerTwitchHandler(discord *discordgo.Session, message *discordgo.MessageCreate, splitMessage []string) {
if len(splitMessage) > 1 {
discord.ChannelMessageSend(message.ChannelID, "Registered "+splitMessage[1])
} else {
discord.ChannelMessageSend(message.ChannelID, "Need to specify a username to register")
}
}

0 comments on commit 06528ed

Please sign in to comment.