From 6b0afb5f1dbe232483640b7a9c53242be929a0cd Mon Sep 17 00:00:00 2001 From: Luther Wen Xu Date: Sun, 12 Jan 2020 18:04:36 +0800 Subject: [PATCH] modules/command: Implement "pgqadmin kick" --- modules/commands/admin.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/modules/commands/admin.go b/modules/commands/admin.go index c708b6e..952a4be 100644 --- a/modules/commands/admin.go +++ b/modules/commands/admin.go @@ -1,6 +1,9 @@ package commands import ( + "fmt" + "strings" + "PermissionGacha/modules/config" "github.com/bwmarrin/discordgo" @@ -31,6 +34,28 @@ func handleAdminCommand(s *discordgo.Session, args []string, m *discordgo.Messag return err } s.ChannelMessageSend(args[4], msg.Content) + case "kick": + separator := -1 + for k, v := range args { + if v == "|" { + separator = k + break + } + } + if separator == -1 { + return nil + } + kickReason := strings.Join(args[2:separator], " ") + for i := separator + 1; i < len(args); i++ { + channel, err := s.UserChannelCreate(args[i]) + if err != nil { + s.ChannelMessageSend( + channel.ID, + fmt.Sprintf("**SYSTEM MESSAGE >** You've been kicked for the following reason: \n%s", kickReason), + ) + } + s.GuildMemberDeleteWithReason(config.GuildID, args[i], kickReason) + } } return nil }