From 73d905735bf7de51466c549052fc72bd4349cc47 Mon Sep 17 00:00:00 2001 From: Siwoo Jeon Date: Thu, 3 Apr 2025 21:30:38 +0900 Subject: [PATCH] feat: Add arguments in learn command --- commands/learn.go | 14 ++++++++++++++ configs/version.go | 2 +- handler/messageCreate.go | 12 +++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/commands/learn.go b/commands/learn.go index afbaa65..a610911 100644 --- a/commands/learn.go +++ b/commands/learn.go @@ -13,6 +13,14 @@ import ( "github.com/bwmarrin/discordgo" ) +var arguments = utils.InlineCode("{user.name}") + "\n" + + utils.InlineCode("{user.mention}") + "\n" + + utils.InlineCode("{user.globalName}") + "\n" + + utils.InlineCode("{user.id}") + "\n" + + utils.InlineCode("{muffin.version}") + "\n" + + utils.InlineCode("{muffin.updatedAt}") + "\n" + + utils.InlineCode("{muffin.statedAt}") + var LearnCommand *Command = &Command{ ApplicationCommand: &discordgo.ApplicationCommand{ Type: discordgo.ChatApplicationCommand, @@ -40,6 +48,7 @@ var LearnCommand *Command = &Command{ fmt.Sprintf("%s배워 안녕 안녕!", configs.Config.Bot.Prefix), fmt.Sprintf("%s배워 \"야 죽을래?\" \"아니요 ㅠㅠㅠ\"", configs.Config.Bot.Prefix), fmt.Sprintf("%s배워 미간은_누구야? 이봇의_개발자요", configs.Config.Bot.Prefix), + fmt.Sprintf("%s배워 \"나의 아이디를 알려줘\" \"너의 아이디는 {user.id}야.\"", configs.Config.Bot.Prefix), }, }, Category: Chattings, @@ -77,6 +86,11 @@ func learnRun(c *Command, s *discordgo.Session, m any, args *[]string) { Value: utils.InlineCode(c.DetailedDescription.Usage), Inline: true, }, + { + Name: "사용 가능한 인자", + Value: arguments, + Inline: true, + }, { Name: "예시", Value: utils.CodeBlockWithLanguage("md", strings.Join(addPrefix(c.DetailedDescription.Examples), "\n")), diff --git a/configs/version.go b/configs/version.go index 7233033..0032d8a 100644 --- a/configs/version.go +++ b/configs/version.go @@ -7,7 +7,7 @@ import ( "git.wh64.net/muffin/goMuffin/utils" ) -const MUFFIN_VERSION = "0.0.0-gopher_dev.250403a" +const MUFFIN_VERSION = "0.0.0-gopher_dev.250403b" var updatedString string = utils.Decimals.FindAllStringSubmatch(MUFFIN_VERSION, -1)[3][0] diff --git a/handler/messageCreate.go b/handler/messageCreate.go index 8c1800e..5e04e52 100644 --- a/handler/messageCreate.go +++ b/handler/messageCreate.go @@ -110,7 +110,17 @@ func MessageCreate(s *discordgo.Session, m *discordgo.MessageCreate) { if x > 2 && len(learnDatas) != 0 { data := learnDatas[rand.Intn(len(learnDatas))] user, _ := s.User(data.UserId) - s.ChannelMessageSendReply(m.ChannelID, fmt.Sprintf("%s\n%s", data.Result, utils.InlineCode(fmt.Sprintf("%s님이 알려주셨어요.", user.Username))), m.Reference()) + result := data.Result + + result = strings.ReplaceAll(result, "{user.name}", m.Author.Username) + result = strings.ReplaceAll(result, "{user.mention}", m.Author.Mention()) + result = strings.ReplaceAll(result, "{user.globalName}", m.Author.GlobalName) + result = strings.ReplaceAll(result, "{user.id}", m.Author.ID) + result = strings.ReplaceAll(result, "{muffin.version}", configs.MUFFIN_VERSION) + result = strings.ReplaceAll(result, "{muffin.updatedAt}", utils.TimeWithStyle(configs.UpdatedAt, utils.RelativeTime)) + result = strings.ReplaceAll(result, "{muffin.startedAt}", utils.TimeWithStyle(configs.StartedAt, utils.RelativeTime)) + + s.ChannelMessageSendReply(m.ChannelID, fmt.Sprintf("%s\n%s", result, utils.InlineCode(fmt.Sprintf("%s님이 알려주셨어요.", user.Username))), m.Reference()) return }