feat: Add arguments in learn command
This commit is contained in:
parent
4f4a02f30a
commit
73d905735b
3 changed files with 26 additions and 2 deletions
|
@ -13,6 +13,14 @@ import (
|
||||||
"github.com/bwmarrin/discordgo"
|
"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{
|
var LearnCommand *Command = &Command{
|
||||||
ApplicationCommand: &discordgo.ApplicationCommand{
|
ApplicationCommand: &discordgo.ApplicationCommand{
|
||||||
Type: discordgo.ChatApplicationCommand,
|
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배워 \"야 죽을래?\" \"아니요 ㅠㅠㅠ\"", 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,
|
Category: Chattings,
|
||||||
|
@ -77,6 +86,11 @@ func learnRun(c *Command, s *discordgo.Session, m any, args *[]string) {
|
||||||
Value: utils.InlineCode(c.DetailedDescription.Usage),
|
Value: utils.InlineCode(c.DetailedDescription.Usage),
|
||||||
Inline: true,
|
Inline: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "사용 가능한 인자",
|
||||||
|
Value: arguments,
|
||||||
|
Inline: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Name: "예시",
|
Name: "예시",
|
||||||
Value: utils.CodeBlockWithLanguage("md", strings.Join(addPrefix(c.DetailedDescription.Examples), "\n")),
|
Value: utils.CodeBlockWithLanguage("md", strings.Join(addPrefix(c.DetailedDescription.Examples), "\n")),
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"git.wh64.net/muffin/goMuffin/utils"
|
"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]
|
var updatedString string = utils.Decimals.FindAllStringSubmatch(MUFFIN_VERSION, -1)[3][0]
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,17 @@ func MessageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||||
if x > 2 && len(learnDatas) != 0 {
|
if x > 2 && len(learnDatas) != 0 {
|
||||||
data := learnDatas[rand.Intn(len(learnDatas))]
|
data := learnDatas[rand.Intn(len(learnDatas))]
|
||||||
user, _ := s.User(data.UserId)
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue