modules/command: Implement "pgqadmin kick"

master
Luther Wen Xu 2020-01-12 18:04:36 +07:00
parent 76b7aaa01a
commit 6b0afb5f1d
Signed by: chanbakjsd
GPG Key ID: B7D77E3E9D102B70
1 changed files with 25 additions and 0 deletions

@ -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
}