some small code improvements

This commit is contained in:
2024-03-10 11:22:03 +01:00
parent 044eeddb64
commit c5603e2cc0
4 changed files with 17 additions and 57 deletions

View File

@@ -173,7 +173,9 @@ var cmd_form Command = Command{
Style: discordgo.SuccessButton,
Label: "Submit",
Emoji: discordgo.ComponentEmoji{
Name: "📥",
Name: "anim_rocket",
ID: "1215740398706757743",
Animated: true,
},
},
},

View File

@@ -27,28 +27,7 @@ var cmd_sticky Command = Command{
Interact: func(s *discordgo.Session, i *discordgo.InteractionCreate) {
switch i.ApplicationCommandData().Options[0].Name {
case "add":
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseModal,
Data: &discordgo.InteractionResponseData{
CustomID: "sticky_modal",
Title: "Sticky message",
Components: []discordgo.MessageComponent{
discordgo.ActionsRow{
Components: []discordgo.MessageComponent{
discordgo.TextInput{
CustomID: "sticky_modal_text",
Label: "Text",
Style: discordgo.TextInputParagraph,
Placeholder: "The message you want to stick to the bottom of this channel",
Required: true,
MaxLength: 2000,
Value: "",
},
},
},
},
},
})
jsonStringShowModal(i.Interaction, "sticky_modal", "sticky_modal")
case "remove":
if hasSticky(i.GuildID, i.ChannelID) {
s.ChannelMessageDelete(i.ChannelID, getStickyMessageID(i.GuildID, i.ChannelID))

View File

@@ -52,40 +52,7 @@ var cmd_tag Command = Command{
case "get":
GetTagCommand(i, i.ApplicationCommandData().Options[0].Options[0])
case "add":
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseModal,
Data: &discordgo.InteractionResponseData{
CustomID: "tag_add_modal" + i.Interaction.Member.User.ID,
Title: "Add a custom tag command",
Components: []discordgo.MessageComponent{
discordgo.ActionsRow{
Components: []discordgo.MessageComponent{
discordgo.TextInput{
CustomID: "tag_add_modal_name",
Label: "Name",
Style: discordgo.TextInputShort,
Required: true,
MaxLength: 20,
Value: "",
},
},
},
discordgo.ActionsRow{
Components: []discordgo.MessageComponent{
discordgo.TextInput{
CustomID: "tag_add_modal_content",
Label: "Content",
Placeholder: "Content that gets returned when the tag will be run",
Style: discordgo.TextInputParagraph,
Required: true,
MaxLength: 2000,
Value: "",
},
},
},
},
},
})
jsonStringShowModal(i.Interaction, "tag_add_modal", "template_general")
case "remove":
removeTag(i.GuildID, i.ApplicationCommandData().Options[0].Options[0].StringValue())
respond(i.Interaction, "Tag removed!", true)

View File

@@ -0,0 +1,12 @@
{
"form_type": "template_general",
"title": "Add a Sticky message",
"form": [
{
"label": "Content",
"is_paragraph": true,
"required": true,
"max_length": 2000
}
]
}