feat: Add reload prompt command

This commit is contained in:
Siwoo Jeon 2025-06-01 13:23:05 +09:00
parent a394624ac5
commit bd2f1dfc06
Signed by: migan
GPG key ID: 036E9A8C5E8E48DA
9 changed files with 62 additions and 14 deletions

View file

@ -29,7 +29,6 @@ const (
userLearn
)
// var dataLengthCh chan chStruct = make(chan chStruct)
var dataLengthWg sync.WaitGroup
var DataLengthCommand *Command = &Command{
@ -43,6 +42,7 @@ var DataLengthCommand *Command = &Command{
Usage: fmt.Sprintf("%s학습데이터량", configs.Config.Bot.Prefix),
},
Category: General,
RegisterApplicationCommand: true,
MessageRun: func(ctx *MsgContext) {
dataLengthRun(ctx.Msg.Session, ctx.Msg, ctx.Msg.Author.Username, ctx.Msg.Author.ID)
},

View file

@ -30,6 +30,7 @@ var DeleteLearnedDataCommand *Command = &Command{
Examples: []string{fmt.Sprintf("%s삭제 머핀", configs.Config.Bot.Prefix)},
},
Category: Chatting,
RegisterApplicationCommand: true,
MessageRun: func(ctx *MsgContext) {
command := strings.Join(*ctx.Args, " ")
if command == "" {

View file

@ -27,6 +27,7 @@ type Command struct {
Aliases []string
DetailedDescription *DetailedDescription
Category Category
RegisterApplicationCommand bool
MessageRun messageRun
ChatInputRun chatInputRun
}
@ -72,6 +73,7 @@ type Modal struct {
const (
Chatting Category = "채팅"
General Category = "일반"
DeveloperOnly Category = "개발자 전용"
)
var (

View file

@ -29,6 +29,7 @@ var HelpCommand *Command = &Command{
Examples: []string{fmt.Sprintf("%s도움말", configs.Config.Bot.Prefix), fmt.Sprintf("%s도움말 배워", configs.Config.Bot.Prefix)},
},
Category: General,
RegisterApplicationCommand: true,
MessageRun: func(ctx *MsgContext) {
helpRun(ctx.Msg.Session, ctx.Msg, strings.Join(*ctx.Args, " "))
},

View file

@ -17,6 +17,7 @@ var InformationCommand *Command = &Command{
Usage: fmt.Sprintf("%s정보", configs.Config.Bot.Prefix),
},
Category: General,
RegisterApplicationCommand: true,
MessageRun: func(ctx *MsgContext) {
informationRun(ctx.Msg.Session, ctx.Msg)
},

View file

@ -57,6 +57,7 @@ var LearnCommand *Command = &Command{
},
},
Category: Chatting,
RegisterApplicationCommand: true,
MessageRun: func(ctx *MsgContext) {
if len(*ctx.Args) < 2 {
utils.NewMessageSender(ctx.Msg).

View file

@ -57,6 +57,7 @@ var LearnedDataListCommand *Command = &Command{
},
},
Category: Chatting,
RegisterApplicationCommand: true,
MessageRun: func(ctx *MsgContext) {
var length int

36
commands/reloadPrompt.go Normal file
View file

@ -0,0 +1,36 @@
package commands
import (
"log"
"git.wh64.net/muffin/goMuffin/chatbot"
"git.wh64.net/muffin/goMuffin/utils"
"github.com/bwmarrin/discordgo"
)
var ReloadPromptCommand *Command = &Command{
ApplicationCommand: &discordgo.ApplicationCommand{
Name: "프롬프트재설정",
Description: "프롬프트를 다시 불러와요.",
},
Category: DeveloperOnly,
RegisterApplicationCommand: false,
MessageRun: func(ctx *MsgContext) {
err := chatbot.ChatBot.ReloadPrompt()
if err != nil {
log.Fatalln(err)
utils.NewMessageSender(ctx.Msg).
AddComponents(utils.GetErrorContainer(discordgo.TextDisplay{Content: "프롬프트를 다시 불러오는 데 문제가 생겼어요."})).
SetComponentsV2(true).
SetReply(true).
Send()
return
}
utils.NewMessageSender(ctx.Msg).
AddComponents(utils.GetSuccessContainer(discordgo.TextDisplay{Content: "프롬프트를 다시 불러왔어요."})).
SetComponentsV2(true).
SetReply(true).
Send()
},
}

View file

@ -26,6 +26,7 @@ func init() {
go commands.Discommand.LoadCommand(commands.LearnedDataListCommand)
go commands.Discommand.LoadCommand(commands.InformationCommand)
go commands.Discommand.LoadCommand(commands.DeleteLearnedDataCommand)
go commands.Discommand.LoadCommand(commands.ReloadPromptCommand)
go commands.Discommand.LoadComponent(components.DeleteLearnedDataComponent)
go commands.Discommand.LoadComponent(components.PaginationEmbedComponent)
@ -120,6 +121,10 @@ func main() {
}
}
if !cmd.RegisterApplicationCommand {
continue
}
go dg.ApplicationCommandCreate(dg.State.User.ID, "", cmd.ApplicationCommand)
}