From 2633a041f6ba2bb3e53144ae9e1fae68e9966728 Mon Sep 17 00:00:00 2001 From: Punarv Pawade Date: Sun, 3 Mar 2024 23:30:15 +0530 Subject: [PATCH] add help to slash commands --- app/commands/commands.go | 4 ++++ app/handlers/handlers.go | 36 ++++++++++++++++++------------------ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/app/commands/commands.go b/app/commands/commands.go index 19368fc..4bcb908 100644 --- a/app/commands/commands.go +++ b/app/commands/commands.go @@ -16,6 +16,10 @@ func RegisterCommands() []*discordgo.ApplicationCommand { }, }, }, + { + Name: "help", + Description: "Display available commands", + }, } return commands } diff --git a/app/handlers/handlers.go b/app/handlers/handlers.go index 9cbe5d9..231ed37 100644 --- a/app/handlers/handlers.go +++ b/app/handlers/handlers.go @@ -54,6 +54,24 @@ func AddHandlers(sess *discordgo.Session) { } }, + "help": func(s *discordgo.Session, i *discordgo.InteractionCreate) { + helpMessage := "Available commands:\n" + + "1. /generate : Generates text based on the provided prompt.\n" + + "2. !airbot upscale (in reply to an image): Upscales the replied image by the specified factor.\n" + + "3. !airbot variation (in reply to an image): Creates variations of the replied image.\n" + + "4. !airbot subtle (in reply to an image): Creates a subtly varied version of the replied image.\n" + + "5. !airbot region (in reply to an image): Creates a regionally varied version of the replied image.\n" + + "6. !airbot strong (in reply to an image): Creates a strongly varied version of the replied image.\n" + + "7. !airbot upscaleSubtle (in reply to an image): Upscales the replied image subtly.\n" + + "8. !airbot upscaleCreative (in reply to an image): Upscales the replied image creatively." + + "9. !airbot gpt : Generates a response using GPT based on the provided prompt.\n" + s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{ + Type: discordgo.InteractionResponseChannelMessageWithSource, + Data: &discordgo.InteractionResponseData{ + Content: helpMessage, + }, + }) + }, } const prefix = "!airbot" sess.AddHandler(func(s *discordgo.Session, i *discordgo.InteractionCreate) { @@ -204,23 +222,5 @@ func AddHandlers(sess *discordgo.Session) { return } } - - if args[1] == "help" { - const helpMessage = "Available commands:\n" + - "1. /generate : Generates text based on the provided prompt.\n" + - "2. /gpt : Generates a response using GPT based on the provided prompt.\n" + - "3. !airbot upscale (in reply to an image): Upscales the replied image by the specified factor.\n" + - "4. !airbot variation (in reply to an image): Creates variations of the replied image.\n" + - "5. !airbot subtle (in reply to an image): Creates a subtly varied version of the replied image.\n" + - "6. !airbot region (in reply to an image): Creates a regionally varied version of the replied image.\n" + - "7. !airbot strong (in reply to an image): Creates a strongly varied version of the replied image.\n" + - "8. !airbot upscaleSubtle (in reply to an image): Upscales the replied image subtly.\n" + - "9. !airbot upscaleCreative (in reply to an image): Upscales the replied image creatively." - - reply := &discordgo.MessageReference{ - MessageID: m.ID, - } - s.ChannelMessageSendReply(m.ChannelID, helpMessage, reply) - } }) }