added new tool function
This commit is contained in:
@@ -53,13 +53,7 @@ var cmd_autojoinroles Command = Command{
|
|||||||
} else if setAutoJoinRole(i.GuildID, option, role) {
|
} else if setAutoJoinRole(i.GuildID, option, role) {
|
||||||
content = "Deleted auto join role for " + option + "s"
|
content = "Deleted auto join role for " + option + "s"
|
||||||
}
|
}
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
respondEphemeral(s, i.Interaction, content)
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Content: content,
|
|
||||||
Flags: discordgo.MessageFlagsEphemeral,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
purgeUnusedAutoJoinRoles(i.GuildID)
|
purgeUnusedAutoJoinRoles(i.GuildID)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@@ -11,30 +11,12 @@ var cmd_autopublish Command = Command{
|
|||||||
channel, _ := s.State.Channel(i.ChannelID)
|
channel, _ := s.State.Channel(i.ChannelID)
|
||||||
if channel.Type == discordgo.ChannelTypeGuildNews {
|
if channel.Type == discordgo.ChannelTypeGuildNews {
|
||||||
if toggleAutoPublish(i.GuildID, i.ChannelID) {
|
if toggleAutoPublish(i.GuildID, i.ChannelID) {
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
respondEphemeral(s, i.Interaction, "Autopublishing is now disabled on <#"+i.ChannelID+">")
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Content: "Autopublishing is now disabled on <#" + i.ChannelID + ">",
|
|
||||||
Flags: discordgo.MessageFlagsEphemeral,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
respondEphemeral(s, i.Interaction, "Autopublishing is now enabled on <#"+i.ChannelID+">")
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Content: "Autopublishing is now enabled on <#" + i.ChannelID + ">",
|
|
||||||
Flags: discordgo.MessageFlagsEphemeral,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
respondEphemeral(s, i.Interaction, "This is not an announcement channel!")
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Content: "This is not an announcement channel!",
|
|
||||||
Flags: discordgo.MessageFlagsEphemeral,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
32
cmd_form.go
32
cmd_form.go
@@ -118,13 +118,7 @@ var cmd_form Command = Command{
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
case "custom":
|
case "custom":
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
respondEphemeral(s, i.Interaction, "Feature not available yet use `/form add` instead")
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Content: "Feature not available yet use `/form add` instead",
|
|
||||||
Flags: discordgo.MessageFlagsEphemeral,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
case "add":
|
case "add":
|
||||||
var title, formID, overwriteTitle, acceptChannelID string
|
var title, formID, overwriteTitle, acceptChannelID string
|
||||||
var modsCanComment bool
|
var modsCanComment bool
|
||||||
@@ -186,24 +180,12 @@ var cmd_form Command = Command{
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
addFormButton(i.GuildID, i.ChannelID, message.ID, formManageID.String(), formID, options.Options[0].ChannelValue(s).ID, overwriteTitle, acceptChannelID, modsCanComment)
|
addFormButton(i.GuildID, i.ChannelID, message.ID, formManageID.String(), formID, options.Options[0].ChannelValue(s).ID, overwriteTitle, acceptChannelID, modsCanComment)
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
respondEphemeral(s, i.Interaction, "Successfully added form button!")
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Content: "Successfully added form button!",
|
|
||||||
Flags: discordgo.MessageFlagsEphemeral,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ComponentInteract: func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
ComponentInteract: func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||||
if strings.HasPrefix(i.Interaction.MessageComponentData().CustomID, "form:") {
|
if strings.HasPrefix(i.Interaction.MessageComponentData().CustomID, "form:") {
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
respondEphemeral(s, i.Interaction, getFormType(strings.TrimPrefix(i.Interaction.MessageComponentData().CustomID, "form:")))
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Content: getFormType(strings.TrimPrefix(i.Interaction.MessageComponentData().CustomID, "form:")),
|
|
||||||
Flags: discordgo.MessageFlagsEphemeral,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
if i.Interaction.MessageComponentData().CustomID == "form_demo" {
|
if i.Interaction.MessageComponentData().CustomID == "form_demo" {
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||||
@@ -247,13 +229,7 @@ var cmd_form Command = Command{
|
|||||||
},
|
},
|
||||||
ModalIDs: getFormTypes(),
|
ModalIDs: getFormTypes(),
|
||||||
ModalSubmit: func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
ModalSubmit: func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
respondEphemeral(s, i.Interaction, "The form data would be send to a specified channel. 🤲")
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Content: "The form data would be send to a specified channel. 🤲",
|
|
||||||
Flags: discordgo.MessageFlagsEphemeral,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
Autocomplete: func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
Autocomplete: func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||||
choices := []*discordgo.ApplicationCommandOptionChoice{
|
choices := []*discordgo.ApplicationCommandOptionChoice{
|
||||||
|
@@ -53,21 +53,9 @@ var cmd_sticky Command = Command{
|
|||||||
if hasSticky(i.GuildID, i.ChannelID) {
|
if hasSticky(i.GuildID, i.ChannelID) {
|
||||||
s.ChannelMessageDelete(i.ChannelID, getStickyMessageID(i.GuildID, i.ChannelID))
|
s.ChannelMessageDelete(i.ChannelID, getStickyMessageID(i.GuildID, i.ChannelID))
|
||||||
removeSticky(i.GuildID, i.ChannelID)
|
removeSticky(i.GuildID, i.ChannelID)
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
respondEphemeral(s, i.Interaction, "The sticky message was removed from this channel!")
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Content: "The sticky message was removed from this channel!",
|
|
||||||
Flags: discordgo.MessageFlagsEphemeral,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
respondEphemeral(s, i.Interaction, "This channel has no sticky message!")
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Content: "This channel has no sticky message!",
|
|
||||||
Flags: discordgo.MessageFlagsEphemeral,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -86,21 +74,9 @@ var cmd_sticky Command = Command{
|
|||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
if addSticky(i.GuildID, i.ChannelID, text, message.ID) {
|
if addSticky(i.GuildID, i.ChannelID, text, message.ID) {
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
respondEphemeral(s, i.Interaction, "Sticky message in this channel was updated!")
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Content: "Sticky message in this channel was updated!",
|
|
||||||
Flags: discordgo.MessageFlagsEphemeral,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
respondEphemeral(s, i.Interaction, "Message sticked to the channel!")
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Content: "Message sticked to the channel!",
|
|
||||||
Flags: discordgo.MessageFlagsEphemeral,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
16
cmd_tag.go
16
cmd_tag.go
@@ -88,13 +88,7 @@ var cmd_tag Command = Command{
|
|||||||
})
|
})
|
||||||
case "remove":
|
case "remove":
|
||||||
removeTag(i.GuildID, i.ApplicationCommandData().Options[0].Options[0].StringValue())
|
removeTag(i.GuildID, i.ApplicationCommandData().Options[0].Options[0].StringValue())
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
respondEphemeral(s, i.Interaction, "Tag removed!")
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Content: "Tag removed!",
|
|
||||||
Flags: discordgo.MessageFlagsEphemeral,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ModalIDs: []string{"tag_add_modal"},
|
ModalIDs: []string{"tag_add_modal"},
|
||||||
@@ -102,13 +96,7 @@ var cmd_tag Command = Command{
|
|||||||
tagName := i.ModalSubmitData().Components[0].(*discordgo.ActionsRow).Components[0].(*discordgo.TextInput).Value
|
tagName := i.ModalSubmitData().Components[0].(*discordgo.ActionsRow).Components[0].(*discordgo.TextInput).Value
|
||||||
tagContent := i.ModalSubmitData().Components[1].(*discordgo.ActionsRow).Components[0].(*discordgo.TextInput).Value
|
tagContent := i.ModalSubmitData().Components[1].(*discordgo.ActionsRow).Components[0].(*discordgo.TextInput).Value
|
||||||
addTag(i.GuildID, tagName, tagContent)
|
addTag(i.GuildID, tagName, tagContent)
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
respondEphemeral(s, i.Interaction, "Tag \""+tagName+"\" added!")
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Content: "Tag \"" + tagName + "\" added!",
|
|
||||||
Flags: discordgo.MessageFlagsEphemeral,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
Autocomplete: func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
Autocomplete: func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||||
AutocompleteTag(s, i)
|
AutocompleteTag(s, i)
|
||||||
|
10
tool.go
10
tool.go
@@ -65,3 +65,13 @@ func hexToDecimal(hexColor string) int {
|
|||||||
}
|
}
|
||||||
return int(decimal)
|
return int(decimal)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func respondEphemeral(s *discordgo.Session, interaction *discordgo.Interaction, content string) {
|
||||||
|
s.InteractionRespond(interaction, &discordgo.InteractionResponse{
|
||||||
|
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||||
|
Data: &discordgo.InteractionResponseData{
|
||||||
|
Content: content,
|
||||||
|
Flags: discordgo.MessageFlagsEphemeral,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user