mirror of https://github.com/hak5/scuzzy.git
Features: Add the ability for Admins to create user joinable roles.
parent
fc445de871
commit
8cc0c09db1
|
@ -1,7 +1,9 @@
|
||||||
package features
|
package features
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
discordgo "github.com/bwmarrin/discord.go"
|
discordgo "github.com/bwmarrin/discord.go"
|
||||||
|
"github.com/foxtrot/scuzzy/models"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -114,3 +116,35 @@ func (f *Features) handleLeaveCustomRole(s *discordgo.Session, m *discordgo.Mess
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *Features) handleAddCustomRole(s *discordgo.Session, m *discordgo.MessageCreate) error {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
if !f.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")
|
||||||
|
}
|
||||||
|
|
||||||
|
shortName := userInput[1]
|
||||||
|
shortName = strings.ToLower(shortName)
|
||||||
|
roleID := userInput[2]
|
||||||
|
|
||||||
|
customRole := models.CustomRole{
|
||||||
|
Name: "",
|
||||||
|
ShortName: shortName,
|
||||||
|
ID: roleID,
|
||||||
|
}
|
||||||
|
|
||||||
|
f.Config.CustomRoles = append(f.Config.CustomRoles, customRole)
|
||||||
|
|
||||||
|
err = f.handleSaveConfig(s, m)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
@ -56,6 +56,7 @@ func (f *Features) RegisterHandlers() {
|
||||||
f.RegisterCommand("getconfig", f.handleGetConfig)
|
f.RegisterCommand("getconfig", f.handleGetConfig)
|
||||||
f.RegisterCommand("saveconfig", f.handleSaveConfig)
|
f.RegisterCommand("saveconfig", f.handleSaveConfig)
|
||||||
f.RegisterCommand("reloadconfig", f.handleReloadConfig)
|
f.RegisterCommand("reloadconfig", f.handleReloadConfig)
|
||||||
|
f.RegisterCommand("addrole", f.handleAddCustomRole)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Features) ProcessCommand(s *discordgo.Session, m *discordgo.MessageCreate) error {
|
func (f *Features) ProcessCommand(s *discordgo.Session, m *discordgo.MessageCreate) error {
|
||||||
|
|
|
@ -326,6 +326,7 @@ func (f *Features) handleHelp(s *discordgo.Session, m *discordgo.MessageCreate)
|
||||||
desc += "`getconfig` - View the runtime configuration\n"
|
desc += "`getconfig` - View the runtime configuration\n"
|
||||||
desc += "`reloadconfig` - Reload configuration from disk\n"
|
desc += "`reloadconfig` - Reload configuration from disk\n"
|
||||||
desc += "`saveconfig` - Save the runtime configuration to disk\n"
|
desc += "`saveconfig` - Save the runtime configuration to disk\n"
|
||||||
|
desc += "`addrole` - Add a user joinable role\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
desc += "\n\nAll commands are prefixed with `" + f.Config.CommandKey + "`\n"
|
desc += "\n\nAll commands are prefixed with `" + f.Config.CommandKey + "`\n"
|
||||||
|
|
Loading…
Reference in New Issue