modules/command: Add `pgqadmin` command
This command currently only has one feature: To echo an arbitrary message to an arbitrary channel.master 0.9
parent
ec1657d398
commit
8b4a039ee1
@ -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
|
||||||
|
}
|
Reference in New Issue