add a command to debug commands and output information about a provided command name

This commit is contained in:
lyx0 2023-03-04 05:00:00 +00:00
parent a3e3ee129c
commit b8625e1901
2 changed files with 41 additions and 0 deletions

View file

@ -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 // SetCommandHelp updates the `help` column of a given commands name in the
// database to the provided new help text. // database to the provided new help text.
func (app *Application) EditCommandHelp(name string, message twitch.PrivateMessage) { func (app *Application) EditCommandHelp(name string, message twitch.PrivateMessage) {

View file

@ -246,6 +246,7 @@ func (app *Application) handleCommand(message twitch.PrivateMessage) {
// 250 - VIP only // 250 - VIP only
//################# //#################
// ()debug user <username> // ()debug user <username>
// ()debug command <command name>
case "debug": case "debug":
if userLevel < 250 { if userLevel < 250 {
return return
@ -255,6 +256,9 @@ func (app *Application) handleCommand(message twitch.PrivateMessage) {
} else if cmdParams[1] == "user" { } else if cmdParams[1] == "user" {
app.DebugUser(cmdParams[2], message) app.DebugUser(cmdParams[2], message)
return return
} else if cmdParams[1] == "command" {
app.DebugCommand(cmdParams[2], message)
return
} else { } else {
return return
} }