This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
2020-01-04 14:15:50 +07:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
2020-01-12 10:04:36 +07:00
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
|
2020-01-04 14:15:50 +07:00
|
|
|
"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)
|
2020-01-12 10:04:36 +07:00
|
|
|
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)
|
|
|
|
}
|
2020-01-04 14:15:50 +07:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|