From 81b44b2721b75f3291e05c08240c530f6e92f565 Mon Sep 17 00:00:00 2001 From: Marc Date: Tue, 1 Jun 2021 01:47:27 +0100 Subject: [PATCH] remove now-unneeded perm checks --- commands/bot.go | 12 ------------ commands/customroles.go | 4 ---- commands/misc.go | 32 ++++---------------------------- commands/moderation.go | 24 ------------------------ 4 files changed, 4 insertions(+), 68 deletions(-) diff --git a/commands/bot.go b/commands/bot.go index 738bf97..73e9e27 100644 --- a/commands/bot.go +++ b/commands/bot.go @@ -10,10 +10,6 @@ import ( ) func (c *Commands) handleSetStatus(s *discordgo.Session, m *discordgo.MessageCreate) error { - if !c.Permissions.CheckAdminRole(m.Member) { - return errors.New("You do not have permissions to use that command.") - } - stSplit := strings.SplitN(m.Content, " ", 2) if len(stSplit) < 2 { return errors.New("You did not specify a status.") @@ -36,10 +32,6 @@ func (c *Commands) handleSetStatus(s *discordgo.Session, m *discordgo.MessageCre } func (c *Commands) handleDisconnect(s *discordgo.Session, m *discordgo.MessageCreate) error { - if !c.Permissions.CheckAdminRole(m.Member) { - return errors.New("I'm sorry Dave, I'm afraid I can't do that.") - } - msg := c.CreateDefinedEmbed("Disconnect", "Attempting Disconnect...", "", m.Author) _, err := s.ChannelMessageSendEmbed(m.ChannelID, msg) if err != nil { @@ -57,10 +49,6 @@ func (c *Commands) handleDisconnect(s *discordgo.Session, m *discordgo.MessageCr } func (c *Commands) handleReconnect(s *discordgo.Session, m *discordgo.MessageCreate) error { - if !c.Permissions.CheckAdminRole(m.Member) { - return errors.New("You do not have permissions to use that command.") - } - t := time.Now() err := s.Close() diff --git a/commands/customroles.go b/commands/customroles.go index 765049b..9b84602 100644 --- a/commands/customroles.go +++ b/commands/customroles.go @@ -120,10 +120,6 @@ func (c *Commands) handleLeaveCustomRole(s *discordgo.Session, m *discordgo.Mess func (c *Commands) handleAddCustomRole(s *discordgo.Session, m *discordgo.MessageCreate) error { var err error - if !c.Permissions.CheckAdminRole(m.Member) { - return errors.New("You do not have permissions to use that command.") - } - userInput := strings.Split(m.Content, " ") if len(userInput) < 3 { return errors.New("Expected Arguments: short_name role_id") diff --git a/commands/misc.go b/commands/misc.go index b05ec6a..66e7d7a 100644 --- a/commands/misc.go +++ b/commands/misc.go @@ -17,10 +17,6 @@ import ( ) func (c *Commands) handleSetConfig(s *discordgo.Session, m *discordgo.MessageCreate) error { - if !c.Permissions.CheckAdminRole(m.Member) { - return errors.New("You do not have permissions to use that command.") - } - configArgs := strings.Split(m.Content, " ") if len(configArgs) != 3 { @@ -84,10 +80,6 @@ func (c *Commands) handleSetConfig(s *discordgo.Session, m *discordgo.MessageCre func (c *Commands) handleGetConfig(s *discordgo.Session, m *discordgo.MessageCreate) error { //TODO: Handle printing of slices (check the Type, loop accordingly) - if !c.Permissions.CheckAdminRole(m.Member) { - return errors.New("You do not have permissions to use that command.") - } - configArgs := strings.Split(m.Content, " ") configKey := "all" if len(configArgs) == 2 { @@ -153,10 +145,6 @@ func (c *Commands) handleGetConfig(s *discordgo.Session, m *discordgo.MessageCre } func (c *Commands) handleReloadConfig(s *discordgo.Session, m *discordgo.MessageCreate) error { - if !c.Permissions.CheckAdminRole(m.Member) { - return errors.New("You do not have permissions to use this command.") - } - fBuf, err := ioutil.ReadFile(c.Config.ConfigPath) if err != nil { return err @@ -182,10 +170,6 @@ func (c *Commands) handleReloadConfig(s *discordgo.Session, m *discordgo.Message } func (c *Commands) handleSaveConfig(s *discordgo.Session, m *discordgo.MessageCreate) error { - if !c.Permissions.CheckAdminRole(m.Member) { - return errors.New("You do not have permissions to use this command.") - } - j, err := json.Marshal(c.Config) if err != nil { return err @@ -223,14 +207,10 @@ func (c *Commands) handlePing(s *discordgo.Session, m *discordgo.MessageCreate) var r *discordgo.Message var err error - if !c.Permissions.CheckAdminRole(m.Member) { - return errors.New("You do not have permissions to use that command.") - } else { - msg := c.CreateDefinedEmbed("Ping", "Pong", "success", m.Author) - r, err = s.ChannelMessageSendEmbed(m.ChannelID, msg) - if err != nil { - return err - } + msg := c.CreateDefinedEmbed("Ping", "Pong", "success", m.Author) + r, err = s.ChannelMessageSendEmbed(m.ChannelID, msg) + if err != nil { + return err } time.Sleep(5 * time.Second) @@ -338,10 +318,6 @@ func (c *Commands) handleHelp(s *discordgo.Session, m *discordgo.MessageCreate) } func (c *Commands) handleRules(s *discordgo.Session, m *discordgo.MessageCreate) error { - if !c.Permissions.CheckAdminRole(m.Member) { - return errors.New("You do not have permissions to use that command.") - } - msg := c.Config.RulesText embedTitle := "Rules (" + c.Config.GuildName + ")" embed := c.CreateDefinedEmbed(embedTitle, msg, "success", m.Author) diff --git a/commands/moderation.go b/commands/moderation.go index 32ec273..0e4c890 100644 --- a/commands/moderation.go +++ b/commands/moderation.go @@ -9,10 +9,6 @@ import ( ) func (c *Commands) handleSetSlowmode(s *discordgo.Session, m *discordgo.MessageCreate) error { - if !c.Permissions.CheckAdminRole(m.Member) { - return errors.New("You do not have permissions to use that command.") - } - slowmodeSplit := strings.Split(m.Content, " ") if len(slowmodeSplit) < 2 { return errors.New("You must supply at least an amount of time") @@ -56,10 +52,6 @@ func (c *Commands) handleSetSlowmode(s *discordgo.Session, m *discordgo.MessageC } func (c *Commands) handleUnsetSlowmode(s *discordgo.Session, m *discordgo.MessageCreate) error { - if !c.Permissions.CheckAdminRole(m.Member) { - return errors.New("You do not have permissions to use that command.") - } - slowmodeSplit := strings.Split(m.Content, " ") if len(slowmodeSplit) == 2 { @@ -94,10 +86,6 @@ func (c *Commands) handleUnsetSlowmode(s *discordgo.Session, m *discordgo.Messag } func (c *Commands) handlePurgeChannel(s *discordgo.Session, m *discordgo.MessageCreate) error { - if !c.Permissions.CheckAdminRole(m.Member) { - return errors.New("You do not have permissions to use that command.") - } - purgeSplit := strings.SplitN(m.Content, " ", 2) if len(purgeSplit) < 2 { return errors.New("No message count supplied") @@ -194,10 +182,6 @@ func (c *Commands) handleKickUser(s *discordgo.Session, m *discordgo.MessageCrea } func (c *Commands) handleBanUser(s *discordgo.Session, m *discordgo.MessageCreate) error { - if !c.Permissions.CheckAdminRole(m.Member) { - return errors.New("You do not have permissions to use this command.") - } - var ( mHandle *discordgo.User banReason string @@ -241,10 +225,6 @@ func (c *Commands) handleBanUser(s *discordgo.Session, m *discordgo.MessageCreat } func (c *Commands) handleIgnoreUser(s *discordgo.Session, m *discordgo.MessageCreate) error { - if !c.Permissions.CheckAdminRole(m.Member) { - return errors.New("You do not have permissions to use this command.") - } - ignArgs := strings.Split(m.Content, " ") if len(ignArgs) < 2 { return errors.New("You did not specify a user.") @@ -272,10 +252,6 @@ func (c *Commands) handleIgnoreUser(s *discordgo.Session, m *discordgo.MessageCr } func (c *Commands) handleUnIgnoreUser(s *discordgo.Session, m *discordgo.MessageCreate) error { - if !c.Permissions.CheckAdminRole(m.Member) { - return errors.New("You do not have permissions to use this command.") - } - ignArgs := strings.Split(m.Content, " ") if len(ignArgs) < 2 { return errors.New("You did not specify a user.")