modules/command: Add `pgqadmin` command

This command currently only has one feature: To echo an arbitrary
message to an arbitrary channel.
master 0.9
Luther Wen Xu 2020-01-04 22:15:50 +07:00
parent ec1657d398
commit 8b4a039ee1
Signed by: chanbakjsd
GPG Key ID: B7D77E3E9D102B70
3 changed files with 43 additions and 0 deletions

@ -0,0 +1,36 @@
package commands
import (
"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)
}
return nil
}

@ -8,6 +8,10 @@ type command struct {
}
var list = []command{
command{
Name: "admin",
Handler: handleAdminCommand,
},
command{
Name: "level",
Handler: handleLevelCommand,

@ -7,6 +7,7 @@ import (
type config struct {
ActiveNerf activeNerf `json:"activeNerf"`
Admins []string `json:"admin"`
CommandPrefix string `json:"prefix"`
GuildID string `json:"guildID"`
PrestigeRequirement int `json:"prestigeFactor"`
@ -42,6 +43,7 @@ func init() {
//Place everything into high level variables
GeneralChannelID = output.ActiveNerf.GeneralChannelID
NotInGeneralNerf = output.ActiveNerf.NotInGeneralNerf
Admins = output.Admins
CommandPrefix = output.CommandPrefix
GuildID = output.GuildID
PrestigeRequirement = output.PrestigeRequirement
@ -62,6 +64,7 @@ var (
GeneralChannelID string
NotInGeneralNerf int
)
var Admins []string
var CommandPrefix string
var GuildID string
var PrestigeRequirement int