This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
PermissionGacha/modules/commands/admin.go

62 lines
1.2 KiB
Go

package commands
import (
"fmt"
"strings"
"PermissionGacha/modules/config"
"github.com/bwmarrin/discordgo"
)
func handleAdminCommand(s *discordgo.Session, args []string, m *discordgo.MessageCreate) error {
if len(args) < 2 {
return nil
}
found := false
for _, v := range config.Admins {
if v == m.Author.ID {
found = true
break
}
}
if !found {
s.ChannelMessageSend(m.ChannelID, "**UNAUTHORIZED >** You cannot use this command!")
return nil
}
switch args[1] {
case "echo":
if len(args) < 5 {
return nil
}
msg, err := s.ChannelMessage(args[2], args[3])
if err != nil {
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
}