feat: Add reload prompt command
This commit is contained in:
parent
a394624ac5
commit
bd2f1dfc06
9 changed files with 62 additions and 14 deletions
|
@ -29,7 +29,6 @@ const (
|
||||||
userLearn
|
userLearn
|
||||||
)
|
)
|
||||||
|
|
||||||
// var dataLengthCh chan chStruct = make(chan chStruct)
|
|
||||||
var dataLengthWg sync.WaitGroup
|
var dataLengthWg sync.WaitGroup
|
||||||
|
|
||||||
var DataLengthCommand *Command = &Command{
|
var DataLengthCommand *Command = &Command{
|
||||||
|
@ -42,7 +41,8 @@ var DataLengthCommand *Command = &Command{
|
||||||
DetailedDescription: &DetailedDescription{
|
DetailedDescription: &DetailedDescription{
|
||||||
Usage: fmt.Sprintf("%s학습데이터량", configs.Config.Bot.Prefix),
|
Usage: fmt.Sprintf("%s학습데이터량", configs.Config.Bot.Prefix),
|
||||||
},
|
},
|
||||||
Category: General,
|
Category: General,
|
||||||
|
RegisterApplicationCommand: true,
|
||||||
MessageRun: func(ctx *MsgContext) {
|
MessageRun: func(ctx *MsgContext) {
|
||||||
dataLengthRun(ctx.Msg.Session, ctx.Msg, ctx.Msg.Author.Username, ctx.Msg.Author.ID)
|
dataLengthRun(ctx.Msg.Session, ctx.Msg, ctx.Msg.Author.Username, ctx.Msg.Author.ID)
|
||||||
},
|
},
|
||||||
|
|
|
@ -29,7 +29,8 @@ var DeleteLearnedDataCommand *Command = &Command{
|
||||||
Usage: fmt.Sprintf("%s삭제 (삭제할 단어)", configs.Config.Bot.Prefix),
|
Usage: fmt.Sprintf("%s삭제 (삭제할 단어)", configs.Config.Bot.Prefix),
|
||||||
Examples: []string{fmt.Sprintf("%s삭제 머핀", configs.Config.Bot.Prefix)},
|
Examples: []string{fmt.Sprintf("%s삭제 머핀", configs.Config.Bot.Prefix)},
|
||||||
},
|
},
|
||||||
Category: Chatting,
|
Category: Chatting,
|
||||||
|
RegisterApplicationCommand: true,
|
||||||
MessageRun: func(ctx *MsgContext) {
|
MessageRun: func(ctx *MsgContext) {
|
||||||
command := strings.Join(*ctx.Args, " ")
|
command := strings.Join(*ctx.Args, " ")
|
||||||
if command == "" {
|
if command == "" {
|
||||||
|
|
|
@ -24,11 +24,12 @@ type DetailedDescription struct {
|
||||||
|
|
||||||
type Command struct {
|
type Command struct {
|
||||||
*discordgo.ApplicationCommand
|
*discordgo.ApplicationCommand
|
||||||
Aliases []string
|
Aliases []string
|
||||||
DetailedDescription *DetailedDescription
|
DetailedDescription *DetailedDescription
|
||||||
Category Category
|
Category Category
|
||||||
MessageRun messageRun
|
RegisterApplicationCommand bool
|
||||||
ChatInputRun chatInputRun
|
MessageRun messageRun
|
||||||
|
ChatInputRun chatInputRun
|
||||||
}
|
}
|
||||||
|
|
||||||
type DiscommandStruct struct {
|
type DiscommandStruct struct {
|
||||||
|
@ -70,8 +71,9 @@ type Modal struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Chatting Category = "채팅"
|
Chatting Category = "채팅"
|
||||||
General Category = "일반"
|
General Category = "일반"
|
||||||
|
DeveloperOnly Category = "개발자 전용"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -28,7 +28,8 @@ var HelpCommand *Command = &Command{
|
||||||
Usage: fmt.Sprintf("%s도움말 [명령어]", configs.Config.Bot.Prefix),
|
Usage: fmt.Sprintf("%s도움말 [명령어]", configs.Config.Bot.Prefix),
|
||||||
Examples: []string{fmt.Sprintf("%s도움말", configs.Config.Bot.Prefix), fmt.Sprintf("%s도움말 배워", configs.Config.Bot.Prefix)},
|
Examples: []string{fmt.Sprintf("%s도움말", configs.Config.Bot.Prefix), fmt.Sprintf("%s도움말 배워", configs.Config.Bot.Prefix)},
|
||||||
},
|
},
|
||||||
Category: General,
|
Category: General,
|
||||||
|
RegisterApplicationCommand: true,
|
||||||
MessageRun: func(ctx *MsgContext) {
|
MessageRun: func(ctx *MsgContext) {
|
||||||
helpRun(ctx.Msg.Session, ctx.Msg, strings.Join(*ctx.Args, " "))
|
helpRun(ctx.Msg.Session, ctx.Msg, strings.Join(*ctx.Args, " "))
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,7 +16,8 @@ var InformationCommand *Command = &Command{
|
||||||
DetailedDescription: &DetailedDescription{
|
DetailedDescription: &DetailedDescription{
|
||||||
Usage: fmt.Sprintf("%s정보", configs.Config.Bot.Prefix),
|
Usage: fmt.Sprintf("%s정보", configs.Config.Bot.Prefix),
|
||||||
},
|
},
|
||||||
Category: General,
|
Category: General,
|
||||||
|
RegisterApplicationCommand: true,
|
||||||
MessageRun: func(ctx *MsgContext) {
|
MessageRun: func(ctx *MsgContext) {
|
||||||
informationRun(ctx.Msg.Session, ctx.Msg)
|
informationRun(ctx.Msg.Session, ctx.Msg)
|
||||||
},
|
},
|
||||||
|
|
|
@ -56,7 +56,8 @@ var LearnCommand *Command = &Command{
|
||||||
fmt.Sprintf("%s배워 \"나의 아이디를 알려줘\" \"너의 아이디는 {user.id}야.\"", configs.Config.Bot.Prefix),
|
fmt.Sprintf("%s배워 \"나의 아이디를 알려줘\" \"너의 아이디는 {user.id}야.\"", configs.Config.Bot.Prefix),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Category: Chatting,
|
Category: Chatting,
|
||||||
|
RegisterApplicationCommand: true,
|
||||||
MessageRun: func(ctx *MsgContext) {
|
MessageRun: func(ctx *MsgContext) {
|
||||||
if len(*ctx.Args) < 2 {
|
if len(*ctx.Args) < 2 {
|
||||||
utils.NewMessageSender(ctx.Msg).
|
utils.NewMessageSender(ctx.Msg).
|
||||||
|
|
|
@ -56,7 +56,8 @@ var LearnedDataListCommand *Command = &Command{
|
||||||
fmt.Sprintf("%s리스트 대답:머핀", configs.Config.Bot.Prefix),
|
fmt.Sprintf("%s리스트 대답:머핀", configs.Config.Bot.Prefix),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Category: Chatting,
|
Category: Chatting,
|
||||||
|
RegisterApplicationCommand: true,
|
||||||
MessageRun: func(ctx *MsgContext) {
|
MessageRun: func(ctx *MsgContext) {
|
||||||
var length int
|
var length int
|
||||||
|
|
||||||
|
|
36
commands/reloadPrompt.go
Normal file
36
commands/reloadPrompt.go
Normal 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()
|
||||||
|
},
|
||||||
|
}
|
5
main.go
5
main.go
|
@ -26,6 +26,7 @@ func init() {
|
||||||
go commands.Discommand.LoadCommand(commands.LearnedDataListCommand)
|
go commands.Discommand.LoadCommand(commands.LearnedDataListCommand)
|
||||||
go commands.Discommand.LoadCommand(commands.InformationCommand)
|
go commands.Discommand.LoadCommand(commands.InformationCommand)
|
||||||
go commands.Discommand.LoadCommand(commands.DeleteLearnedDataCommand)
|
go commands.Discommand.LoadCommand(commands.DeleteLearnedDataCommand)
|
||||||
|
go commands.Discommand.LoadCommand(commands.ReloadPromptCommand)
|
||||||
|
|
||||||
go commands.Discommand.LoadComponent(components.DeleteLearnedDataComponent)
|
go commands.Discommand.LoadComponent(components.DeleteLearnedDataComponent)
|
||||||
go commands.Discommand.LoadComponent(components.PaginationEmbedComponent)
|
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)
|
go dg.ApplicationCommandCreate(dg.State.User.ID, "", cmd.ApplicationCommand)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue