renamed command variables and added autopublishing

This commit is contained in:
2024-03-05 14:05:17 +01:00
parent 4d02026f25
commit c90e2d59fc
11 changed files with 90 additions and 10 deletions

40
cmd_autopublish.go Normal file
View File

@@ -0,0 +1,40 @@
package main
import "github.com/bwmarrin/discordgo"
var cmd_autopublish Command = Command{
Definition: discordgo.ApplicationCommand{
Name: "autopublish",
Description: "Toggle automatically publishing every post in a announcement channel",
},
Interact: func(s *discordgo.Session, i *discordgo.InteractionCreate) {
channel, _ := s.State.Channel(i.ChannelID)
if channel.Type == discordgo.ChannelTypeGuildNews {
if toggleAutoPublish(i.GuildID, i.ChannelID) {
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: "Autopublishing is now disabled on <#" + i.ChannelID + ">",
Flags: discordgo.MessageFlagsEphemeral,
},
})
} else {
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: "Autopublishing is now enabled on <#" + i.ChannelID + ">",
Flags: discordgo.MessageFlagsEphemeral,
},
})
}
} else {
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: "This is not an announcement channel!",
Flags: discordgo.MessageFlagsEphemeral,
},
})
}
},
}