aboutsummaryrefslogtreecommitdiff
path: root/commands/admin
diff options
context:
space:
mode:
authormax2323madcity <[email protected]>2024-11-21 17:50:28 +0000
committermax2323madcity <[email protected]>2024-11-21 17:50:28 +0000
commitc30fcaf5acbd511680d4adce362f55b7bbb62977 (patch)
treea849db7c957913d9e63863eea0e170fdb66c0656 /commands/admin
parenteb1cd6e687a0dc50b3c58ddea422b0973a2d97da (diff)
downloadyuzaki-c30fcaf5acbd511680d4adce362f55b7bbb62977.tar.xz
yuzaki-c30fcaf5acbd511680d4adce362f55b7bbb62977.zip
trails
Diffstat (limited to 'commands/admin')
-rw-r--r--commands/admin/kick.go50
1 files changed, 50 insertions, 0 deletions
diff --git a/commands/admin/kick.go b/commands/admin/kick.go
new file mode 100644
index 0000000..f7ab0d2
--- /dev/null
+++ b/commands/admin/kick.go
@@ -0,0 +1,50 @@
+package admin
+
+import (
+ //"fmt"
+ "log"
+ //"time"
+
+ "yuzaki/utils"
+
+ "github.com/bwmarrin/discordgo"
+)
+
+func KickMember(s *discordgo.Session, i *discordgo.InteractionCreate) {
+ err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
+ Type: discordgo.InteractionResponseDeferredChannelMessageWithSource,
+ Data: &discordgo.InteractionResponseData{
+ Flags: discordgo.MessageFlagsEphemeral,
+ },
+ })
+ if err != nil {
+ log.Printf("Error responding to interaction: %s. Interaction: purge. Interaction By: %s\n", err, i.Member.DisplayName())
+ return
+ }
+
+ options := i.ApplicationCommandData().Options
+ optionMap := make(map[string]*discordgo.ApplicationCommandInteractionDataOption, len(options))
+ for _, option := range options {
+ optionMap[option.Name] = option
+ }
+
+ option, ok := optionMap["target"]
+ if !ok {
+ utils.SendFollowUpMessage(s, i, "You must mention the user to kick!", true)
+ return
+ }
+
+ user := option.UserValue(s);
+ if user == nil {
+ utils.SendFollowUpMessage(s, i, "Invalid user", true)
+ return
+ }
+ err = s.GuildMemberDeleteWithReason(i.GuildID, user.ID, "Kicked by an admin")
+ if err != nil {
+ utils.SendFollowUpMessage(s, i, "Could not kick user", true)
+ return
+ }
+
+ utils.SendFollowUpMessage(s, i, "User kicked successfully!", true)
+
+} \ No newline at end of file