diff --git a/modules/commands/admin.go b/modules/commands/admin.go new file mode 100644 index 0000000..c708b6e --- /dev/null +++ b/modules/commands/admin.go @@ -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 +} diff --git a/modules/commands/commands.go b/modules/commands/commands.go index a73b6e9..860a13e 100644 --- a/modules/commands/commands.go +++ b/modules/commands/commands.go @@ -8,6 +8,10 @@ type command struct { } var list = []command{ + command{ + Name: "admin", + Handler: handleAdminCommand, + }, command{ Name: "level", Handler: handleLevelCommand, diff --git a/modules/config/config.go b/modules/config/config.go index 13f1d6b..0da36e8 100644 --- a/modules/config/config.go +++ b/modules/config/config.go @@ -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