mirror of https://github.com/hak5/scuzzy.git
master
parent
1538b3b65c
commit
e75100d985
|
@ -68,11 +68,6 @@ func (f *Features) RegisterHandlers() {
|
||||||
f.RegisterCommand("saveconfig", "Save Configuration to Disk", true, f.handleSaveConfig)
|
f.RegisterCommand("saveconfig", "Save Configuration to Disk", true, f.handleSaveConfig)
|
||||||
f.RegisterCommand("reloadconfig", "Reload Configuration", true, f.handleReloadConfig)
|
f.RegisterCommand("reloadconfig", "Reload Configuration", true, f.handleReloadConfig)
|
||||||
f.RegisterCommand("addrole", "Add a joinable role", true, f.handleAddCustomRole)
|
f.RegisterCommand("addrole", "Add a joinable role", true, f.handleAddCustomRole)
|
||||||
|
|
||||||
sort.Slice(f.ScuzzyCommandsByIndex, func(i, j int) bool {
|
|
||||||
return f.ScuzzyCommandsByIndex[i].Index > f.ScuzzyCommandsByIndex[j].Index
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Features) ProcessCommand(s *discordgo.Session, m *discordgo.MessageCreate) error {
|
func (f *Features) ProcessCommand(s *discordgo.Session, m *discordgo.MessageCreate) error {
|
||||||
|
|
|
@ -4,14 +4,16 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/bwmarrin/discordgo"
|
|
||||||
"github.com/foxtrot/scuzzy/models"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/bwmarrin/discordgo"
|
||||||
|
"github.com/foxtrot/scuzzy/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (f *Features) handleSetConfig(s *discordgo.Session, m *discordgo.MessageCreate) error {
|
func (f *Features) handleSetConfig(s *discordgo.Session, m *discordgo.MessageCreate) error {
|
||||||
|
@ -288,8 +290,20 @@ func (f *Features) handleInfo(s *discordgo.Session, m *discordgo.MessageCreate)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Features) handleHelp(s *discordgo.Session, m *discordgo.MessageCreate) error {
|
func (f *Features) handleHelp(s *discordgo.Session, m *discordgo.MessageCreate) error {
|
||||||
|
keys := make([]int, 0, len(f.ScuzzyCommands))
|
||||||
|
for _, cmd := range f.ScuzzyCommands {
|
||||||
|
keys = append(keys, cmd.Index)
|
||||||
|
}
|
||||||
|
sort.Ints(keys)
|
||||||
|
|
||||||
|
for _, k := range keys {
|
||||||
|
fmt.Println(k, f.ScuzzyCommandsByIndex[k])
|
||||||
|
}
|
||||||
|
|
||||||
desc := "**Available Commands**\n"
|
desc := "**Available Commands**\n"
|
||||||
for _, command := range f.ScuzzyCommandsByIndex {
|
for _, k := range keys {
|
||||||
|
command := f.ScuzzyCommandsByIndex[k]
|
||||||
|
|
||||||
if !command.AdminOnly && command.Description != "" {
|
if !command.AdminOnly && command.Description != "" {
|
||||||
desc += "`" + command.Name + "` - " + command.Description + "\n"
|
desc += "`" + command.Name + "` - " + command.Description + "\n"
|
||||||
}
|
}
|
||||||
|
@ -298,7 +312,9 @@ func (f *Features) handleHelp(s *discordgo.Session, m *discordgo.MessageCreate)
|
||||||
if f.Permissions.CheckAdminRole(m.Member) {
|
if f.Permissions.CheckAdminRole(m.Member) {
|
||||||
desc += "\n"
|
desc += "\n"
|
||||||
desc += "**Admin Commands**\n"
|
desc += "**Admin Commands**\n"
|
||||||
for _, command := range f.ScuzzyCommandsByIndex {
|
for _, k := range keys {
|
||||||
|
command := f.ScuzzyCommandsByIndex[k]
|
||||||
|
|
||||||
if command.AdminOnly {
|
if command.AdminOnly {
|
||||||
desc += "`" + command.Name + "` - " + command.Description + "\n"
|
desc += "`" + command.Name + "` - " + command.Description + "\n"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue