diff --git a/cmd/bot/command.go b/cmd/bot/command.go index b694ae5..e0bfe05 100644 --- a/cmd/bot/command.go +++ b/cmd/bot/command.go @@ -157,6 +157,43 @@ func (app *Application) EditCommandCategory(name, category string, message twitc } } +// DebugCommand checks if a command with the provided name exists in the database +// and outputs information about it in the chat. +func (app *Application) DebugCommand(name string, message twitch.PrivateMessage) { + // Query the database for a command with the provided name + cmd, err := app.Models.Commands.Get(name) + if err != nil { + reply := fmt.Sprintf("Something went wrong FeelsBadMan %s", err) + common.Send(message.Channel, reply, app.TwitchClient) + return + } else if cmd.Category == "ascii" { + // If the command is in the ascii category don't post the Text field + // otherwise it becomes too spammy and won't fit in the max message length. + reply := fmt.Sprintf("ID %v: Name %v, Level: %v, Category: %v Help: %v", + cmd.ID, + cmd.Name, + cmd.Level, + cmd.Category, + cmd.Help, + ) + + common.Send(message.Channel, reply, app.TwitchClient) + return + } else { + reply := fmt.Sprintf("ID %v: Name %v, Level: %v, Category: %v, Text: %v, Help: %v", + cmd.ID, + cmd.Name, + cmd.Level, + cmd.Category, + cmd.Text, + cmd.Help, + ) + + common.Send(message.Channel, reply, app.TwitchClient) + return + } +} + // SetCommandHelp updates the `help` column of a given commands name in the // database to the provided new help text. func (app *Application) EditCommandHelp(name string, message twitch.PrivateMessage) { diff --git a/cmd/bot/commands.go b/cmd/bot/commands.go index 2f8c2f2..45be700 100644 --- a/cmd/bot/commands.go +++ b/cmd/bot/commands.go @@ -246,6 +246,7 @@ func (app *Application) handleCommand(message twitch.PrivateMessage) { // 250 - VIP only //################# // ()debug user + // ()debug command case "debug": if userLevel < 250 { return @@ -255,6 +256,9 @@ func (app *Application) handleCommand(message twitch.PrivateMessage) { } else if cmdParams[1] == "user" { app.DebugUser(cmdParams[2], message) return + } else if cmdParams[1] == "command" { + app.DebugCommand(cmdParams[2], message) + return } else { return }