added command for blocking polls

This commit is contained in:
2024-04-13 23:03:02 +02:00
parent e6da5dedd6
commit a1fd95cefe
4 changed files with 124 additions and 26 deletions

36
cmd_blockpolls.go Normal file
View File

@@ -0,0 +1,36 @@
package main
import (
"github.com/disgoorg/disgo/discord"
"github.com/disgoorg/disgo/events"
"github.com/sirupsen/logrus"
)
var cmd_blockpolls Command = Command{
Definition: discord.SlashCommandCreate{
Name: "block-polls",
Description: "Toggle blocking polls from beeing posted in this channel.",
Contexts: []discord.InteractionContextType{
discord.InteractionContextTypeGuild,
discord.InteractionContextTypePrivateChannel},
IntegrationTypes: []discord.ApplicationIntegrationType{
discord.ApplicationIntegrationTypeGuildInstall},
},
Interact: func(e *events.ApplicationCommandInteractionCreate) {
if toggleBlockPolls(e.GuildID().String(), e.Channel().ID().String()) {
err := e.CreateMessage(discord.NewMessageCreateBuilder().
SetContent("Polls are now unblocked in " + discord.ChannelMention(e.Channel().ID())).SetEphemeral(true).
Build())
if err != nil {
logrus.Error(err)
}
} else {
err := e.CreateMessage(discord.NewMessageCreateBuilder().
SetContent("Polls are now blocked in " + discord.ChannelMention(e.Channel().ID())).SetEphemeral(true).
Build())
if err != nil {
logrus.Error(err)
}
}
},
}