scuzzy/commands/misc.go

718 lines
17 KiB
Go
Raw Normal View History

2021-05-29 12:17:01 +00:00
package commands
Create Scuzzy Features: Hastily add usercolor feature Main: Show prefix in bot status Features: add cat Main/Features/Auth: Add basic Role Name/ID based command authentication and bot configuration. Main: Sanity check for missing flags. Features: Implement command deletion and tag-responses Misc: Add cmd/main to .gitignore Misc: Delete built binary Main: Refactor main.go - Use log.Fatal instead of fmt.Printf and os.Exit - Move Config reading into seperate function - Parse command line flags in main() - Instantiate Features.go struct inside main() - Use simple ticker to set bot status every 15 minutes Auth: Refactor auth - Return early when building Admin role list - Move CheckAdminrole() into auth.go, remove roles.go Features: Refactor features - Remove New() function - Move help.go, ping.go functionality into misc.go Features: Add bot control feature to set status. Features: Implement helper function for embeds, return errors. Main: Rename config file to bot_config.json Features: Use success embed for user color. Features: Add purge messages feature. Main: Add status_text property to config, use it for Bot Status. Features: Send welcome message to new users, implement auto-join roles. Main: Use complex user status Main: Reduce ticker interval to 10 minutes for bot status update. Main: Create helper function for complex custom embeds. Features: Implement info command. Features: Convert requested user color to lowercase. Features: Add markdown helper Features: Fix markdown helper typo Features: Use error embed for handleSetStatus incorrect permissions. Features: Add strikethrough and spoilers information to markdown info. Features: Add info and md to help text. Features: Use backtick instead of single quote for command prefix in help text. Features: Remove markdown info message after 15 seconds. Features: Fix typo in status setting permission error. Features: Add commands to convert between Celsius and Farenheit Features: Update help to include temperature conversion commands. Features/Models/Main: Load color roles from JSON config. Auth/Main/Features/Models: Implement config-based channel white/blacklisting. Main/Models: Remove unused admin_only config field. Features: Simplify error handling. Auth: Remove leftover AdminOnly field. Features: Use command restriction for usercolor commands. Main: Update default config to restrict color and colors commands. Auth/Features: Return true for undefined commands in restrictions list by default. Features: Use better error messages for channel white/blacklist Auth: Improve channel white/blacklist behavior. Main: Replace broken ticker for status updates Features: Get bot avatar via Discord for embed. Features: Delete requesting message for markdown info. Features: Handle potential error in deleting help requester message.
2020-04-11 14:16:09 +00:00
import (
"encoding/json"
Create Scuzzy Features: Hastily add usercolor feature Main: Show prefix in bot status Features: add cat Main/Features/Auth: Add basic Role Name/ID based command authentication and bot configuration. Main: Sanity check for missing flags. Features: Implement command deletion and tag-responses Misc: Add cmd/main to .gitignore Misc: Delete built binary Main: Refactor main.go - Use log.Fatal instead of fmt.Printf and os.Exit - Move Config reading into seperate function - Parse command line flags in main() - Instantiate Features.go struct inside main() - Use simple ticker to set bot status every 15 minutes Auth: Refactor auth - Return early when building Admin role list - Move CheckAdminrole() into auth.go, remove roles.go Features: Refactor features - Remove New() function - Move help.go, ping.go functionality into misc.go Features: Add bot control feature to set status. Features: Implement helper function for embeds, return errors. Main: Rename config file to bot_config.json Features: Use success embed for user color. Features: Add purge messages feature. Main: Add status_text property to config, use it for Bot Status. Features: Send welcome message to new users, implement auto-join roles. Main: Use complex user status Main: Reduce ticker interval to 10 minutes for bot status update. Main: Create helper function for complex custom embeds. Features: Implement info command. Features: Convert requested user color to lowercase. Features: Add markdown helper Features: Fix markdown helper typo Features: Use error embed for handleSetStatus incorrect permissions. Features: Add strikethrough and spoilers information to markdown info. Features: Add info and md to help text. Features: Use backtick instead of single quote for command prefix in help text. Features: Remove markdown info message after 15 seconds. Features: Fix typo in status setting permission error. Features: Add commands to convert between Celsius and Farenheit Features: Update help to include temperature conversion commands. Features/Models/Main: Load color roles from JSON config. Auth/Main/Features/Models: Implement config-based channel white/blacklisting. Main/Models: Remove unused admin_only config field. Features: Simplify error handling. Auth: Remove leftover AdminOnly field. Features: Use command restriction for usercolor commands. Main: Update default config to restrict color and colors commands. Auth/Features: Return true for undefined commands in restrictions list by default. Features: Use better error messages for channel white/blacklist Auth: Improve channel white/blacklist behavior. Main: Replace broken ticker for status updates Features: Get bot avatar via Discord for embed. Features: Delete requesting message for markdown info. Features: Handle potential error in deleting help requester message.
2020-04-11 14:16:09 +00:00
"errors"
"fmt"
"io/ioutil"
2022-08-16 12:32:53 +00:00
"net/url"
"os"
"reflect"
2021-05-28 18:46:05 +00:00
"sort"
Create Scuzzy Features: Hastily add usercolor feature Main: Show prefix in bot status Features: add cat Main/Features/Auth: Add basic Role Name/ID based command authentication and bot configuration. Main: Sanity check for missing flags. Features: Implement command deletion and tag-responses Misc: Add cmd/main to .gitignore Misc: Delete built binary Main: Refactor main.go - Use log.Fatal instead of fmt.Printf and os.Exit - Move Config reading into seperate function - Parse command line flags in main() - Instantiate Features.go struct inside main() - Use simple ticker to set bot status every 15 minutes Auth: Refactor auth - Return early when building Admin role list - Move CheckAdminrole() into auth.go, remove roles.go Features: Refactor features - Remove New() function - Move help.go, ping.go functionality into misc.go Features: Add bot control feature to set status. Features: Implement helper function for embeds, return errors. Main: Rename config file to bot_config.json Features: Use success embed for user color. Features: Add purge messages feature. Main: Add status_text property to config, use it for Bot Status. Features: Send welcome message to new users, implement auto-join roles. Main: Use complex user status Main: Reduce ticker interval to 10 minutes for bot status update. Main: Create helper function for complex custom embeds. Features: Implement info command. Features: Convert requested user color to lowercase. Features: Add markdown helper Features: Fix markdown helper typo Features: Use error embed for handleSetStatus incorrect permissions. Features: Add strikethrough and spoilers information to markdown info. Features: Add info and md to help text. Features: Use backtick instead of single quote for command prefix in help text. Features: Remove markdown info message after 15 seconds. Features: Fix typo in status setting permission error. Features: Add commands to convert between Celsius and Farenheit Features: Update help to include temperature conversion commands. Features/Models/Main: Load color roles from JSON config. Auth/Main/Features/Models: Implement config-based channel white/blacklisting. Main/Models: Remove unused admin_only config field. Features: Simplify error handling. Auth: Remove leftover AdminOnly field. Features: Use command restriction for usercolor commands. Main: Update default config to restrict color and colors commands. Auth/Features: Return true for undefined commands in restrictions list by default. Features: Use better error messages for channel white/blacklist Auth: Improve channel white/blacklist behavior. Main: Replace broken ticker for status updates Features: Get bot avatar via Discord for embed. Features: Delete requesting message for markdown info. Features: Handle potential error in deleting help requester message.
2020-04-11 14:16:09 +00:00
"strconv"
"strings"
"time"
2021-05-28 18:46:05 +00:00
"github.com/bwmarrin/discordgo"
"github.com/foxtrot/scuzzy/models"
Create Scuzzy Features: Hastily add usercolor feature Main: Show prefix in bot status Features: add cat Main/Features/Auth: Add basic Role Name/ID based command authentication and bot configuration. Main: Sanity check for missing flags. Features: Implement command deletion and tag-responses Misc: Add cmd/main to .gitignore Misc: Delete built binary Main: Refactor main.go - Use log.Fatal instead of fmt.Printf and os.Exit - Move Config reading into seperate function - Parse command line flags in main() - Instantiate Features.go struct inside main() - Use simple ticker to set bot status every 15 minutes Auth: Refactor auth - Return early when building Admin role list - Move CheckAdminrole() into auth.go, remove roles.go Features: Refactor features - Remove New() function - Move help.go, ping.go functionality into misc.go Features: Add bot control feature to set status. Features: Implement helper function for embeds, return errors. Main: Rename config file to bot_config.json Features: Use success embed for user color. Features: Add purge messages feature. Main: Add status_text property to config, use it for Bot Status. Features: Send welcome message to new users, implement auto-join roles. Main: Use complex user status Main: Reduce ticker interval to 10 minutes for bot status update. Main: Create helper function for complex custom embeds. Features: Implement info command. Features: Convert requested user color to lowercase. Features: Add markdown helper Features: Fix markdown helper typo Features: Use error embed for handleSetStatus incorrect permissions. Features: Add strikethrough and spoilers information to markdown info. Features: Add info and md to help text. Features: Use backtick instead of single quote for command prefix in help text. Features: Remove markdown info message after 15 seconds. Features: Fix typo in status setting permission error. Features: Add commands to convert between Celsius and Farenheit Features: Update help to include temperature conversion commands. Features/Models/Main: Load color roles from JSON config. Auth/Main/Features/Models: Implement config-based channel white/blacklisting. Main/Models: Remove unused admin_only config field. Features: Simplify error handling. Auth: Remove leftover AdminOnly field. Features: Use command restriction for usercolor commands. Main: Update default config to restrict color and colors commands. Auth/Features: Return true for undefined commands in restrictions list by default. Features: Use better error messages for channel white/blacklist Auth: Improve channel white/blacklist behavior. Main: Replace broken ticker for status updates Features: Get bot avatar via Discord for embed. Features: Delete requesting message for markdown info. Features: Handle potential error in deleting help requester message.
2020-04-11 14:16:09 +00:00
)
2021-05-29 12:17:01 +00:00
func (c *Commands) handleSetConfig(s *discordgo.Session, m *discordgo.MessageCreate) error {
configArgs := strings.Split(m.Content, " ")
if len(configArgs) != 3 {
2021-05-29 12:17:01 +00:00
return errors.New("Invalid arguments supplied. Usage: " + c.Config.CommandKey + "setconfig <key> <value>")
}
configKey := configArgs[1]
configVal := configArgs[2]
2021-05-29 12:17:01 +00:00
rt := reflect.TypeOf(c.Config)
for i := 0; i < rt.NumField(); i++ {
x := rt.Field(i)
tagVal := strings.Split(x.Tag.Get("json"), ",")[0]
tagName := x.Name
if tagVal == configKey {
2021-05-29 12:17:01 +00:00
prop := reflect.ValueOf(&c.Config).Elem().FieldByName(tagName)
switch prop.Interface().(type) {
case string:
prop.SetString(configVal)
break
case int:
intVal, err := strconv.ParseInt(configVal, 10, 64)
if err != nil {
return err
}
prop.SetInt(intVal)
break
case float64:
floatVal, err := strconv.ParseFloat(configVal, 64)
if err != nil {
return err
}
prop.SetFloat(floatVal)
break
case bool:
boolVal, err := strconv.ParseBool(configVal)
if err != nil {
return err
}
prop.SetBool(boolVal)
break
default:
return errors.New("Unsupported key value type")
}
2021-05-29 12:17:01 +00:00
msgE := c.CreateDefinedEmbed("Set Configuration", "Successfully set property '"+configKey+"'!", "success", m.Author)
_, err := s.ChannelMessageSendEmbed(m.ChannelID, msgE)
if err != nil {
return err
}
return nil
}
}
return errors.New("Unknown key specified")
}
2021-05-29 12:17:01 +00:00
func (c *Commands) handleGetConfig(s *discordgo.Session, m *discordgo.MessageCreate) error {
//TODO: Handle printing of slices (check the Type, loop accordingly)
configArgs := strings.Split(m.Content, " ")
configKey := "all"
if len(configArgs) == 2 {
configKey = configArgs[1]
}
msg := ""
rt := reflect.TypeOf(*c.Config)
for i := 0; i < rt.NumField(); i++ {
x := rt.Field(i)
tagVal := strings.Split(x.Tag.Get("json"), ",")[0]
tagName := x.Name
prop := reflect.ValueOf(c.Config).Elem().FieldByName(tagName)
if configKey == "all" {
switch prop.Interface().(type) {
case string:
if len(prop.String()) > 256 {
// Truncate large values.
msg += "`" + tagName + "` - " + "Truncated...\n"
} else {
msg += "`" + tagName + "` - `" + prop.String() + "`\n"
}
break
default:
// Ignore non strings for now...
msg += "`" + tagName + "` - Skipped Value\n"
continue
}
} else {
if tagVal == configKey {
switch prop.Interface().(type) {
case string:
msg += "`" + tagName + "` - `" + prop.String() + "`\n"
default:
// Ignore non strings for now...
msg += "`" + tagName + "` - Skipped Value\n"
}
2021-05-29 12:17:01 +00:00
eMsg := c.CreateDefinedEmbed("Get Configuration", msg, "success", m.Author)
_, err := s.ChannelMessageSendEmbed(m.ChannelID, eMsg)
if err != nil {
return err
}
return nil
}
}
}
if msg == "" {
return errors.New("Unknown key specified")
}
2021-05-29 12:17:01 +00:00
eMsg := c.CreateDefinedEmbed("Get Configuration", msg, "success", m.Author)
_, err := s.ChannelMessageSendEmbed(m.ChannelID, eMsg)
if err != nil {
return err
}
return nil
}
2021-05-29 12:17:01 +00:00
func (c *Commands) handleReloadConfig(s *discordgo.Session, m *discordgo.MessageCreate) error {
fBuf, err := ioutil.ReadFile(c.Config.ConfigPath)
if err != nil {
return err
}
conf := &models.Configuration{}
err = json.Unmarshal(fBuf, &conf)
if err != nil {
return err
}
2021-05-29 12:17:01 +00:00
c.Config = conf
c.Permissions.Config = conf
2021-05-29 12:17:01 +00:00
eMsg := c.CreateDefinedEmbed("Reload Configuration", "Successfully reloaded configuration from disk", "success", m.Author)
_, err = s.ChannelMessageSendEmbed(m.ChannelID, eMsg)
if err != nil {
return err
}
return nil
}
2021-05-29 12:17:01 +00:00
func (c *Commands) handleSaveConfig(s *discordgo.Session, m *discordgo.MessageCreate) error {
j, err := json.Marshal(c.Config)
if err != nil {
return err
}
2021-05-29 12:17:01 +00:00
err = ioutil.WriteFile(c.Config.ConfigPath, j, os.ModePerm)
if err != nil {
return err
}
2021-05-29 12:17:01 +00:00
eMsg := c.CreateDefinedEmbed("Save Configuration", "Saved runtime configuration successfully", "success", m.Author)
_, err = s.ChannelMessageSendEmbed(m.ChannelID, eMsg)
if err != nil {
return err
}
return nil
}
2021-05-29 12:17:01 +00:00
func (c *Commands) handleCat(s *discordgo.Session, m *discordgo.MessageCreate) error {
2020-04-26 20:05:39 +00:00
_, err := s.ChannelMessageSend(m.ChannelID, "https://giphy.com/gifs/cat-cute-no-rCxogJBzaeZuU")
if err != nil {
return err
}
err = s.ChannelMessageDelete(m.ChannelID, m.ID)
if err != nil {
return err
Create Scuzzy Features: Hastily add usercolor feature Main: Show prefix in bot status Features: add cat Main/Features/Auth: Add basic Role Name/ID based command authentication and bot configuration. Main: Sanity check for missing flags. Features: Implement command deletion and tag-responses Misc: Add cmd/main to .gitignore Misc: Delete built binary Main: Refactor main.go - Use log.Fatal instead of fmt.Printf and os.Exit - Move Config reading into seperate function - Parse command line flags in main() - Instantiate Features.go struct inside main() - Use simple ticker to set bot status every 15 minutes Auth: Refactor auth - Return early when building Admin role list - Move CheckAdminrole() into auth.go, remove roles.go Features: Refactor features - Remove New() function - Move help.go, ping.go functionality into misc.go Features: Add bot control feature to set status. Features: Implement helper function for embeds, return errors. Main: Rename config file to bot_config.json Features: Use success embed for user color. Features: Add purge messages feature. Main: Add status_text property to config, use it for Bot Status. Features: Send welcome message to new users, implement auto-join roles. Main: Use complex user status Main: Reduce ticker interval to 10 minutes for bot status update. Main: Create helper function for complex custom embeds. Features: Implement info command. Features: Convert requested user color to lowercase. Features: Add markdown helper Features: Fix markdown helper typo Features: Use error embed for handleSetStatus incorrect permissions. Features: Add strikethrough and spoilers information to markdown info. Features: Add info and md to help text. Features: Use backtick instead of single quote for command prefix in help text. Features: Remove markdown info message after 15 seconds. Features: Fix typo in status setting permission error. Features: Add commands to convert between Celsius and Farenheit Features: Update help to include temperature conversion commands. Features/Models/Main: Load color roles from JSON config. Auth/Main/Features/Models: Implement config-based channel white/blacklisting. Main/Models: Remove unused admin_only config field. Features: Simplify error handling. Auth: Remove leftover AdminOnly field. Features: Use command restriction for usercolor commands. Main: Update default config to restrict color and colors commands. Auth/Features: Return true for undefined commands in restrictions list by default. Features: Use better error messages for channel white/blacklist Auth: Improve channel white/blacklist behavior. Main: Replace broken ticker for status updates Features: Get bot avatar via Discord for embed. Features: Delete requesting message for markdown info. Features: Handle potential error in deleting help requester message.
2020-04-11 14:16:09 +00:00
}
return nil
}
2021-05-29 12:17:01 +00:00
func (c *Commands) handlePing(s *discordgo.Session, m *discordgo.MessageCreate) error {
Create Scuzzy Features: Hastily add usercolor feature Main: Show prefix in bot status Features: add cat Main/Features/Auth: Add basic Role Name/ID based command authentication and bot configuration. Main: Sanity check for missing flags. Features: Implement command deletion and tag-responses Misc: Add cmd/main to .gitignore Misc: Delete built binary Main: Refactor main.go - Use log.Fatal instead of fmt.Printf and os.Exit - Move Config reading into seperate function - Parse command line flags in main() - Instantiate Features.go struct inside main() - Use simple ticker to set bot status every 15 minutes Auth: Refactor auth - Return early when building Admin role list - Move CheckAdminrole() into auth.go, remove roles.go Features: Refactor features - Remove New() function - Move help.go, ping.go functionality into misc.go Features: Add bot control feature to set status. Features: Implement helper function for embeds, return errors. Main: Rename config file to bot_config.json Features: Use success embed for user color. Features: Add purge messages feature. Main: Add status_text property to config, use it for Bot Status. Features: Send welcome message to new users, implement auto-join roles. Main: Use complex user status Main: Reduce ticker interval to 10 minutes for bot status update. Main: Create helper function for complex custom embeds. Features: Implement info command. Features: Convert requested user color to lowercase. Features: Add markdown helper Features: Fix markdown helper typo Features: Use error embed for handleSetStatus incorrect permissions. Features: Add strikethrough and spoilers information to markdown info. Features: Add info and md to help text. Features: Use backtick instead of single quote for command prefix in help text. Features: Remove markdown info message after 15 seconds. Features: Fix typo in status setting permission error. Features: Add commands to convert between Celsius and Farenheit Features: Update help to include temperature conversion commands. Features/Models/Main: Load color roles from JSON config. Auth/Main/Features/Models: Implement config-based channel white/blacklisting. Main/Models: Remove unused admin_only config field. Features: Simplify error handling. Auth: Remove leftover AdminOnly field. Features: Use command restriction for usercolor commands. Main: Update default config to restrict color and colors commands. Auth/Features: Return true for undefined commands in restrictions list by default. Features: Use better error messages for channel white/blacklist Auth: Improve channel white/blacklist behavior. Main: Replace broken ticker for status updates Features: Get bot avatar via Discord for embed. Features: Delete requesting message for markdown info. Features: Handle potential error in deleting help requester message.
2020-04-11 14:16:09 +00:00
var r *discordgo.Message
var err error
2021-06-01 00:47:27 +00:00
msg := c.CreateDefinedEmbed("Ping", "Pong", "success", m.Author)
r, err = s.ChannelMessageSendEmbed(m.ChannelID, msg)
if err != nil {
return err
Create Scuzzy Features: Hastily add usercolor feature Main: Show prefix in bot status Features: add cat Main/Features/Auth: Add basic Role Name/ID based command authentication and bot configuration. Main: Sanity check for missing flags. Features: Implement command deletion and tag-responses Misc: Add cmd/main to .gitignore Misc: Delete built binary Main: Refactor main.go - Use log.Fatal instead of fmt.Printf and os.Exit - Move Config reading into seperate function - Parse command line flags in main() - Instantiate Features.go struct inside main() - Use simple ticker to set bot status every 15 minutes Auth: Refactor auth - Return early when building Admin role list - Move CheckAdminrole() into auth.go, remove roles.go Features: Refactor features - Remove New() function - Move help.go, ping.go functionality into misc.go Features: Add bot control feature to set status. Features: Implement helper function for embeds, return errors. Main: Rename config file to bot_config.json Features: Use success embed for user color. Features: Add purge messages feature. Main: Add status_text property to config, use it for Bot Status. Features: Send welcome message to new users, implement auto-join roles. Main: Use complex user status Main: Reduce ticker interval to 10 minutes for bot status update. Main: Create helper function for complex custom embeds. Features: Implement info command. Features: Convert requested user color to lowercase. Features: Add markdown helper Features: Fix markdown helper typo Features: Use error embed for handleSetStatus incorrect permissions. Features: Add strikethrough and spoilers information to markdown info. Features: Add info and md to help text. Features: Use backtick instead of single quote for command prefix in help text. Features: Remove markdown info message after 15 seconds. Features: Fix typo in status setting permission error. Features: Add commands to convert between Celsius and Farenheit Features: Update help to include temperature conversion commands. Features/Models/Main: Load color roles from JSON config. Auth/Main/Features/Models: Implement config-based channel white/blacklisting. Main/Models: Remove unused admin_only config field. Features: Simplify error handling. Auth: Remove leftover AdminOnly field. Features: Use command restriction for usercolor commands. Main: Update default config to restrict color and colors commands. Auth/Features: Return true for undefined commands in restrictions list by default. Features: Use better error messages for channel white/blacklist Auth: Improve channel white/blacklist behavior. Main: Replace broken ticker for status updates Features: Get bot avatar via Discord for embed. Features: Delete requesting message for markdown info. Features: Handle potential error in deleting help requester message.
2020-04-11 14:16:09 +00:00
}
time.Sleep(5 * time.Second)
err = s.ChannelMessageDelete(m.ChannelID, r.ID)
if err != nil {
return err
}
err = s.ChannelMessageDelete(m.ChannelID, m.ID)
if err != nil {
return err
}
return nil
}
2021-05-29 12:17:01 +00:00
func (c *Commands) handleInfo(s *discordgo.Session, m *discordgo.MessageCreate) error {
Create Scuzzy Features: Hastily add usercolor feature Main: Show prefix in bot status Features: add cat Main/Features/Auth: Add basic Role Name/ID based command authentication and bot configuration. Main: Sanity check for missing flags. Features: Implement command deletion and tag-responses Misc: Add cmd/main to .gitignore Misc: Delete built binary Main: Refactor main.go - Use log.Fatal instead of fmt.Printf and os.Exit - Move Config reading into seperate function - Parse command line flags in main() - Instantiate Features.go struct inside main() - Use simple ticker to set bot status every 15 minutes Auth: Refactor auth - Return early when building Admin role list - Move CheckAdminrole() into auth.go, remove roles.go Features: Refactor features - Remove New() function - Move help.go, ping.go functionality into misc.go Features: Add bot control feature to set status. Features: Implement helper function for embeds, return errors. Main: Rename config file to bot_config.json Features: Use success embed for user color. Features: Add purge messages feature. Main: Add status_text property to config, use it for Bot Status. Features: Send welcome message to new users, implement auto-join roles. Main: Use complex user status Main: Reduce ticker interval to 10 minutes for bot status update. Main: Create helper function for complex custom embeds. Features: Implement info command. Features: Convert requested user color to lowercase. Features: Add markdown helper Features: Fix markdown helper typo Features: Use error embed for handleSetStatus incorrect permissions. Features: Add strikethrough and spoilers information to markdown info. Features: Add info and md to help text. Features: Use backtick instead of single quote for command prefix in help text. Features: Remove markdown info message after 15 seconds. Features: Fix typo in status setting permission error. Features: Add commands to convert between Celsius and Farenheit Features: Update help to include temperature conversion commands. Features/Models/Main: Load color roles from JSON config. Auth/Main/Features/Models: Implement config-based channel white/blacklisting. Main/Models: Remove unused admin_only config field. Features: Simplify error handling. Auth: Remove leftover AdminOnly field. Features: Use command restriction for usercolor commands. Main: Update default config to restrict color and colors commands. Auth/Features: Return true for undefined commands in restrictions list by default. Features: Use better error messages for channel white/blacklist Auth: Improve channel white/blacklist behavior. Main: Replace broken ticker for status updates Features: Get bot avatar via Discord for embed. Features: Delete requesting message for markdown info. Features: Handle potential error in deleting help requester message.
2020-04-11 14:16:09 +00:00
desc := "**Source**: https://github.com/foxtrot/scuzzy\n"
desc += "**Language**: Go\n"
2021-05-29 12:17:01 +00:00
desc += "**Commands**: See `" + c.Config.CommandKey + "help`\n\n\n"
Create Scuzzy Features: Hastily add usercolor feature Main: Show prefix in bot status Features: add cat Main/Features/Auth: Add basic Role Name/ID based command authentication and bot configuration. Main: Sanity check for missing flags. Features: Implement command deletion and tag-responses Misc: Add cmd/main to .gitignore Misc: Delete built binary Main: Refactor main.go - Use log.Fatal instead of fmt.Printf and os.Exit - Move Config reading into seperate function - Parse command line flags in main() - Instantiate Features.go struct inside main() - Use simple ticker to set bot status every 15 minutes Auth: Refactor auth - Return early when building Admin role list - Move CheckAdminrole() into auth.go, remove roles.go Features: Refactor features - Remove New() function - Move help.go, ping.go functionality into misc.go Features: Add bot control feature to set status. Features: Implement helper function for embeds, return errors. Main: Rename config file to bot_config.json Features: Use success embed for user color. Features: Add purge messages feature. Main: Add status_text property to config, use it for Bot Status. Features: Send welcome message to new users, implement auto-join roles. Main: Use complex user status Main: Reduce ticker interval to 10 minutes for bot status update. Main: Create helper function for complex custom embeds. Features: Implement info command. Features: Convert requested user color to lowercase. Features: Add markdown helper Features: Fix markdown helper typo Features: Use error embed for handleSetStatus incorrect permissions. Features: Add strikethrough and spoilers information to markdown info. Features: Add info and md to help text. Features: Use backtick instead of single quote for command prefix in help text. Features: Remove markdown info message after 15 seconds. Features: Fix typo in status setting permission error. Features: Add commands to convert between Celsius and Farenheit Features: Update help to include temperature conversion commands. Features/Models/Main: Load color roles from JSON config. Auth/Main/Features/Models: Implement config-based channel white/blacklisting. Main/Models: Remove unused admin_only config field. Features: Simplify error handling. Auth: Remove leftover AdminOnly field. Features: Use command restriction for usercolor commands. Main: Update default config to restrict color and colors commands. Auth/Features: Return true for undefined commands in restrictions list by default. Features: Use better error messages for channel white/blacklist Auth: Improve channel white/blacklist behavior. Main: Replace broken ticker for status updates Features: Get bot avatar via Discord for embed. Features: Delete requesting message for markdown info. Features: Handle potential error in deleting help requester message.
2020-04-11 14:16:09 +00:00
2021-05-29 12:17:01 +00:00
gm, err := s.GuildMember(c.Config.GuildID, s.State.User.ID)
Create Scuzzy Features: Hastily add usercolor feature Main: Show prefix in bot status Features: add cat Main/Features/Auth: Add basic Role Name/ID based command authentication and bot configuration. Main: Sanity check for missing flags. Features: Implement command deletion and tag-responses Misc: Add cmd/main to .gitignore Misc: Delete built binary Main: Refactor main.go - Use log.Fatal instead of fmt.Printf and os.Exit - Move Config reading into seperate function - Parse command line flags in main() - Instantiate Features.go struct inside main() - Use simple ticker to set bot status every 15 minutes Auth: Refactor auth - Return early when building Admin role list - Move CheckAdminrole() into auth.go, remove roles.go Features: Refactor features - Remove New() function - Move help.go, ping.go functionality into misc.go Features: Add bot control feature to set status. Features: Implement helper function for embeds, return errors. Main: Rename config file to bot_config.json Features: Use success embed for user color. Features: Add purge messages feature. Main: Add status_text property to config, use it for Bot Status. Features: Send welcome message to new users, implement auto-join roles. Main: Use complex user status Main: Reduce ticker interval to 10 minutes for bot status update. Main: Create helper function for complex custom embeds. Features: Implement info command. Features: Convert requested user color to lowercase. Features: Add markdown helper Features: Fix markdown helper typo Features: Use error embed for handleSetStatus incorrect permissions. Features: Add strikethrough and spoilers information to markdown info. Features: Add info and md to help text. Features: Use backtick instead of single quote for command prefix in help text. Features: Remove markdown info message after 15 seconds. Features: Fix typo in status setting permission error. Features: Add commands to convert between Celsius and Farenheit Features: Update help to include temperature conversion commands. Features/Models/Main: Load color roles from JSON config. Auth/Main/Features/Models: Implement config-based channel white/blacklisting. Main/Models: Remove unused admin_only config field. Features: Simplify error handling. Auth: Remove leftover AdminOnly field. Features: Use command restriction for usercolor commands. Main: Update default config to restrict color and colors commands. Auth/Features: Return true for undefined commands in restrictions list by default. Features: Use better error messages for channel white/blacklist Auth: Improve channel white/blacklist behavior. Main: Replace broken ticker for status updates Features: Get bot avatar via Discord for embed. Features: Delete requesting message for markdown info. Features: Handle potential error in deleting help requester message.
2020-04-11 14:16:09 +00:00
if err != nil {
return err
}
d := models.CustomEmbed{
Title: "Scuzzy Information",
Desc: desc,
ImageURL: "",
ImageH: 100,
ImageW: 100,
Color: 0xFFA500,
URL: "",
Type: "",
Timestamp: "",
FooterText: "Made with ❤ by Foxtrot",
FooterImageURL: "https://cdn.discordapp.com/avatars/514163441548656641/a_ac5e022e77e62e7793711ebde8cdf4a1.gif",
Create Scuzzy Features: Hastily add usercolor feature Main: Show prefix in bot status Features: add cat Main/Features/Auth: Add basic Role Name/ID based command authentication and bot configuration. Main: Sanity check for missing flags. Features: Implement command deletion and tag-responses Misc: Add cmd/main to .gitignore Misc: Delete built binary Main: Refactor main.go - Use log.Fatal instead of fmt.Printf and os.Exit - Move Config reading into seperate function - Parse command line flags in main() - Instantiate Features.go struct inside main() - Use simple ticker to set bot status every 15 minutes Auth: Refactor auth - Return early when building Admin role list - Move CheckAdminrole() into auth.go, remove roles.go Features: Refactor features - Remove New() function - Move help.go, ping.go functionality into misc.go Features: Add bot control feature to set status. Features: Implement helper function for embeds, return errors. Main: Rename config file to bot_config.json Features: Use success embed for user color. Features: Add purge messages feature. Main: Add status_text property to config, use it for Bot Status. Features: Send welcome message to new users, implement auto-join roles. Main: Use complex user status Main: Reduce ticker interval to 10 minutes for bot status update. Main: Create helper function for complex custom embeds. Features: Implement info command. Features: Convert requested user color to lowercase. Features: Add markdown helper Features: Fix markdown helper typo Features: Use error embed for handleSetStatus incorrect permissions. Features: Add strikethrough and spoilers information to markdown info. Features: Add info and md to help text. Features: Use backtick instead of single quote for command prefix in help text. Features: Remove markdown info message after 15 seconds. Features: Fix typo in status setting permission error. Features: Add commands to convert between Celsius and Farenheit Features: Update help to include temperature conversion commands. Features/Models/Main: Load color roles from JSON config. Auth/Main/Features/Models: Implement config-based channel white/blacklisting. Main/Models: Remove unused admin_only config field. Features: Simplify error handling. Auth: Remove leftover AdminOnly field. Features: Use command restriction for usercolor commands. Main: Update default config to restrict color and colors commands. Auth/Features: Return true for undefined commands in restrictions list by default. Features: Use better error messages for channel white/blacklist Auth: Improve channel white/blacklist behavior. Main: Replace broken ticker for status updates Features: Get bot avatar via Discord for embed. Features: Delete requesting message for markdown info. Features: Handle potential error in deleting help requester message.
2020-04-11 14:16:09 +00:00
ThumbnailURL: gm.User.AvatarURL(""),
ThumbnailH: 150,
ThumbnailW: 150,
ProviderURL: "",
ProviderText: "",
AuthorText: "",
AuthorURL: "",
AuthorImageURL: "",
}
2021-05-29 12:17:01 +00:00
msg := c.CreateCustomEmbed(&d)
Create Scuzzy Features: Hastily add usercolor feature Main: Show prefix in bot status Features: add cat Main/Features/Auth: Add basic Role Name/ID based command authentication and bot configuration. Main: Sanity check for missing flags. Features: Implement command deletion and tag-responses Misc: Add cmd/main to .gitignore Misc: Delete built binary Main: Refactor main.go - Use log.Fatal instead of fmt.Printf and os.Exit - Move Config reading into seperate function - Parse command line flags in main() - Instantiate Features.go struct inside main() - Use simple ticker to set bot status every 15 minutes Auth: Refactor auth - Return early when building Admin role list - Move CheckAdminrole() into auth.go, remove roles.go Features: Refactor features - Remove New() function - Move help.go, ping.go functionality into misc.go Features: Add bot control feature to set status. Features: Implement helper function for embeds, return errors. Main: Rename config file to bot_config.json Features: Use success embed for user color. Features: Add purge messages feature. Main: Add status_text property to config, use it for Bot Status. Features: Send welcome message to new users, implement auto-join roles. Main: Use complex user status Main: Reduce ticker interval to 10 minutes for bot status update. Main: Create helper function for complex custom embeds. Features: Implement info command. Features: Convert requested user color to lowercase. Features: Add markdown helper Features: Fix markdown helper typo Features: Use error embed for handleSetStatus incorrect permissions. Features: Add strikethrough and spoilers information to markdown info. Features: Add info and md to help text. Features: Use backtick instead of single quote for command prefix in help text. Features: Remove markdown info message after 15 seconds. Features: Fix typo in status setting permission error. Features: Add commands to convert between Celsius and Farenheit Features: Update help to include temperature conversion commands. Features/Models/Main: Load color roles from JSON config. Auth/Main/Features/Models: Implement config-based channel white/blacklisting. Main/Models: Remove unused admin_only config field. Features: Simplify error handling. Auth: Remove leftover AdminOnly field. Features: Use command restriction for usercolor commands. Main: Update default config to restrict color and colors commands. Auth/Features: Return true for undefined commands in restrictions list by default. Features: Use better error messages for channel white/blacklist Auth: Improve channel white/blacklist behavior. Main: Replace broken ticker for status updates Features: Get bot avatar via Discord for embed. Features: Delete requesting message for markdown info. Features: Handle potential error in deleting help requester message.
2020-04-11 14:16:09 +00:00
_, err = s.ChannelMessageSendEmbed(m.ChannelID, msg)
if err != nil {
return err
}
return nil
}
2021-05-29 12:17:01 +00:00
func (c *Commands) handleHelp(s *discordgo.Session, m *discordgo.MessageCreate) error {
keys := make([]int, 0, len(c.ScuzzyCommands))
for _, cmd := range c.ScuzzyCommands {
2021-05-28 18:46:05 +00:00
keys = append(keys, cmd.Index)
}
sort.Ints(keys)
for _, k := range keys {
2021-05-29 12:17:01 +00:00
fmt.Println(k, c.ScuzzyCommandsByIndex[k])
2021-05-28 18:46:05 +00:00
}
Create Scuzzy Features: Hastily add usercolor feature Main: Show prefix in bot status Features: add cat Main/Features/Auth: Add basic Role Name/ID based command authentication and bot configuration. Main: Sanity check for missing flags. Features: Implement command deletion and tag-responses Misc: Add cmd/main to .gitignore Misc: Delete built binary Main: Refactor main.go - Use log.Fatal instead of fmt.Printf and os.Exit - Move Config reading into seperate function - Parse command line flags in main() - Instantiate Features.go struct inside main() - Use simple ticker to set bot status every 15 minutes Auth: Refactor auth - Return early when building Admin role list - Move CheckAdminrole() into auth.go, remove roles.go Features: Refactor features - Remove New() function - Move help.go, ping.go functionality into misc.go Features: Add bot control feature to set status. Features: Implement helper function for embeds, return errors. Main: Rename config file to bot_config.json Features: Use success embed for user color. Features: Add purge messages feature. Main: Add status_text property to config, use it for Bot Status. Features: Send welcome message to new users, implement auto-join roles. Main: Use complex user status Main: Reduce ticker interval to 10 minutes for bot status update. Main: Create helper function for complex custom embeds. Features: Implement info command. Features: Convert requested user color to lowercase. Features: Add markdown helper Features: Fix markdown helper typo Features: Use error embed for handleSetStatus incorrect permissions. Features: Add strikethrough and spoilers information to markdown info. Features: Add info and md to help text. Features: Use backtick instead of single quote for command prefix in help text. Features: Remove markdown info message after 15 seconds. Features: Fix typo in status setting permission error. Features: Add commands to convert between Celsius and Farenheit Features: Update help to include temperature conversion commands. Features/Models/Main: Load color roles from JSON config. Auth/Main/Features/Models: Implement config-based channel white/blacklisting. Main/Models: Remove unused admin_only config field. Features: Simplify error handling. Auth: Remove leftover AdminOnly field. Features: Use command restriction for usercolor commands. Main: Update default config to restrict color and colors commands. Auth/Features: Return true for undefined commands in restrictions list by default. Features: Use better error messages for channel white/blacklist Auth: Improve channel white/blacklist behavior. Main: Replace broken ticker for status updates Features: Get bot avatar via Discord for embed. Features: Delete requesting message for markdown info. Features: Handle potential error in deleting help requester message.
2020-04-11 14:16:09 +00:00
desc := "**Available Commands**\n"
2021-05-28 18:46:05 +00:00
for _, k := range keys {
2021-05-29 12:17:01 +00:00
command := c.ScuzzyCommandsByIndex[k]
2021-05-28 18:46:05 +00:00
2021-05-28 17:14:06 +00:00
if !command.AdminOnly && command.Description != "" {
desc += "`" + command.Name + "` - " + command.Description + "\n"
}
}
Create Scuzzy Features: Hastily add usercolor feature Main: Show prefix in bot status Features: add cat Main/Features/Auth: Add basic Role Name/ID based command authentication and bot configuration. Main: Sanity check for missing flags. Features: Implement command deletion and tag-responses Misc: Add cmd/main to .gitignore Misc: Delete built binary Main: Refactor main.go - Use log.Fatal instead of fmt.Printf and os.Exit - Move Config reading into seperate function - Parse command line flags in main() - Instantiate Features.go struct inside main() - Use simple ticker to set bot status every 15 minutes Auth: Refactor auth - Return early when building Admin role list - Move CheckAdminrole() into auth.go, remove roles.go Features: Refactor features - Remove New() function - Move help.go, ping.go functionality into misc.go Features: Add bot control feature to set status. Features: Implement helper function for embeds, return errors. Main: Rename config file to bot_config.json Features: Use success embed for user color. Features: Add purge messages feature. Main: Add status_text property to config, use it for Bot Status. Features: Send welcome message to new users, implement auto-join roles. Main: Use complex user status Main: Reduce ticker interval to 10 minutes for bot status update. Main: Create helper function for complex custom embeds. Features: Implement info command. Features: Convert requested user color to lowercase. Features: Add markdown helper Features: Fix markdown helper typo Features: Use error embed for handleSetStatus incorrect permissions. Features: Add strikethrough and spoilers information to markdown info. Features: Add info and md to help text. Features: Use backtick instead of single quote for command prefix in help text. Features: Remove markdown info message after 15 seconds. Features: Fix typo in status setting permission error. Features: Add commands to convert between Celsius and Farenheit Features: Update help to include temperature conversion commands. Features/Models/Main: Load color roles from JSON config. Auth/Main/Features/Models: Implement config-based channel white/blacklisting. Main/Models: Remove unused admin_only config field. Features: Simplify error handling. Auth: Remove leftover AdminOnly field. Features: Use command restriction for usercolor commands. Main: Update default config to restrict color and colors commands. Auth/Features: Return true for undefined commands in restrictions list by default. Features: Use better error messages for channel white/blacklist Auth: Improve channel white/blacklist behavior. Main: Replace broken ticker for status updates Features: Get bot avatar via Discord for embed. Features: Delete requesting message for markdown info. Features: Handle potential error in deleting help requester message.
2020-04-11 14:16:09 +00:00
2021-05-29 12:17:01 +00:00
if c.Permissions.CheckAdminRole(m.Member) {
Create Scuzzy Features: Hastily add usercolor feature Main: Show prefix in bot status Features: add cat Main/Features/Auth: Add basic Role Name/ID based command authentication and bot configuration. Main: Sanity check for missing flags. Features: Implement command deletion and tag-responses Misc: Add cmd/main to .gitignore Misc: Delete built binary Main: Refactor main.go - Use log.Fatal instead of fmt.Printf and os.Exit - Move Config reading into seperate function - Parse command line flags in main() - Instantiate Features.go struct inside main() - Use simple ticker to set bot status every 15 minutes Auth: Refactor auth - Return early when building Admin role list - Move CheckAdminrole() into auth.go, remove roles.go Features: Refactor features - Remove New() function - Move help.go, ping.go functionality into misc.go Features: Add bot control feature to set status. Features: Implement helper function for embeds, return errors. Main: Rename config file to bot_config.json Features: Use success embed for user color. Features: Add purge messages feature. Main: Add status_text property to config, use it for Bot Status. Features: Send welcome message to new users, implement auto-join roles. Main: Use complex user status Main: Reduce ticker interval to 10 minutes for bot status update. Main: Create helper function for complex custom embeds. Features: Implement info command. Features: Convert requested user color to lowercase. Features: Add markdown helper Features: Fix markdown helper typo Features: Use error embed for handleSetStatus incorrect permissions. Features: Add strikethrough and spoilers information to markdown info. Features: Add info and md to help text. Features: Use backtick instead of single quote for command prefix in help text. Features: Remove markdown info message after 15 seconds. Features: Fix typo in status setting permission error. Features: Add commands to convert between Celsius and Farenheit Features: Update help to include temperature conversion commands. Features/Models/Main: Load color roles from JSON config. Auth/Main/Features/Models: Implement config-based channel white/blacklisting. Main/Models: Remove unused admin_only config field. Features: Simplify error handling. Auth: Remove leftover AdminOnly field. Features: Use command restriction for usercolor commands. Main: Update default config to restrict color and colors commands. Auth/Features: Return true for undefined commands in restrictions list by default. Features: Use better error messages for channel white/blacklist Auth: Improve channel white/blacklist behavior. Main: Replace broken ticker for status updates Features: Get bot avatar via Discord for embed. Features: Delete requesting message for markdown info. Features: Handle potential error in deleting help requester message.
2020-04-11 14:16:09 +00:00
desc += "\n"
desc += "**Admin Commands**\n"
2021-05-28 18:46:05 +00:00
for _, k := range keys {
2021-05-29 12:17:01 +00:00
command := c.ScuzzyCommandsByIndex[k]
2021-05-28 18:46:05 +00:00
2021-05-28 17:14:06 +00:00
if command.AdminOnly {
desc += "`" + command.Name + "` - " + command.Description + "\n"
}
}
Create Scuzzy Features: Hastily add usercolor feature Main: Show prefix in bot status Features: add cat Main/Features/Auth: Add basic Role Name/ID based command authentication and bot configuration. Main: Sanity check for missing flags. Features: Implement command deletion and tag-responses Misc: Add cmd/main to .gitignore Misc: Delete built binary Main: Refactor main.go - Use log.Fatal instead of fmt.Printf and os.Exit - Move Config reading into seperate function - Parse command line flags in main() - Instantiate Features.go struct inside main() - Use simple ticker to set bot status every 15 minutes Auth: Refactor auth - Return early when building Admin role list - Move CheckAdminrole() into auth.go, remove roles.go Features: Refactor features - Remove New() function - Move help.go, ping.go functionality into misc.go Features: Add bot control feature to set status. Features: Implement helper function for embeds, return errors. Main: Rename config file to bot_config.json Features: Use success embed for user color. Features: Add purge messages feature. Main: Add status_text property to config, use it for Bot Status. Features: Send welcome message to new users, implement auto-join roles. Main: Use complex user status Main: Reduce ticker interval to 10 minutes for bot status update. Main: Create helper function for complex custom embeds. Features: Implement info command. Features: Convert requested user color to lowercase. Features: Add markdown helper Features: Fix markdown helper typo Features: Use error embed for handleSetStatus incorrect permissions. Features: Add strikethrough and spoilers information to markdown info. Features: Add info and md to help text. Features: Use backtick instead of single quote for command prefix in help text. Features: Remove markdown info message after 15 seconds. Features: Fix typo in status setting permission error. Features: Add commands to convert between Celsius and Farenheit Features: Update help to include temperature conversion commands. Features/Models/Main: Load color roles from JSON config. Auth/Main/Features/Models: Implement config-based channel white/blacklisting. Main/Models: Remove unused admin_only config field. Features: Simplify error handling. Auth: Remove leftover AdminOnly field. Features: Use command restriction for usercolor commands. Main: Update default config to restrict color and colors commands. Auth/Features: Return true for undefined commands in restrictions list by default. Features: Use better error messages for channel white/blacklist Auth: Improve channel white/blacklist behavior. Main: Replace broken ticker for status updates Features: Get bot avatar via Discord for embed. Features: Delete requesting message for markdown info. Features: Handle potential error in deleting help requester message.
2020-04-11 14:16:09 +00:00
}
2021-05-29 12:17:01 +00:00
desc += "\n\nAll commands are prefixed with `" + c.Config.CommandKey + "`\n"
Create Scuzzy Features: Hastily add usercolor feature Main: Show prefix in bot status Features: add cat Main/Features/Auth: Add basic Role Name/ID based command authentication and bot configuration. Main: Sanity check for missing flags. Features: Implement command deletion and tag-responses Misc: Add cmd/main to .gitignore Misc: Delete built binary Main: Refactor main.go - Use log.Fatal instead of fmt.Printf and os.Exit - Move Config reading into seperate function - Parse command line flags in main() - Instantiate Features.go struct inside main() - Use simple ticker to set bot status every 15 minutes Auth: Refactor auth - Return early when building Admin role list - Move CheckAdminrole() into auth.go, remove roles.go Features: Refactor features - Remove New() function - Move help.go, ping.go functionality into misc.go Features: Add bot control feature to set status. Features: Implement helper function for embeds, return errors. Main: Rename config file to bot_config.json Features: Use success embed for user color. Features: Add purge messages feature. Main: Add status_text property to config, use it for Bot Status. Features: Send welcome message to new users, implement auto-join roles. Main: Use complex user status Main: Reduce ticker interval to 10 minutes for bot status update. Main: Create helper function for complex custom embeds. Features: Implement info command. Features: Convert requested user color to lowercase. Features: Add markdown helper Features: Fix markdown helper typo Features: Use error embed for handleSetStatus incorrect permissions. Features: Add strikethrough and spoilers information to markdown info. Features: Add info and md to help text. Features: Use backtick instead of single quote for command prefix in help text. Features: Remove markdown info message after 15 seconds. Features: Fix typo in status setting permission error. Features: Add commands to convert between Celsius and Farenheit Features: Update help to include temperature conversion commands. Features/Models/Main: Load color roles from JSON config. Auth/Main/Features/Models: Implement config-based channel white/blacklisting. Main/Models: Remove unused admin_only config field. Features: Simplify error handling. Auth: Remove leftover AdminOnly field. Features: Use command restriction for usercolor commands. Main: Update default config to restrict color and colors commands. Auth/Features: Return true for undefined commands in restrictions list by default. Features: Use better error messages for channel white/blacklist Auth: Improve channel white/blacklist behavior. Main: Replace broken ticker for status updates Features: Get bot avatar via Discord for embed. Features: Delete requesting message for markdown info. Features: Handle potential error in deleting help requester message.
2020-04-11 14:16:09 +00:00
2021-05-29 12:17:01 +00:00
msg := c.CreateDefinedEmbed("Help", desc, "", m.Author)
Create Scuzzy Features: Hastily add usercolor feature Main: Show prefix in bot status Features: add cat Main/Features/Auth: Add basic Role Name/ID based command authentication and bot configuration. Main: Sanity check for missing flags. Features: Implement command deletion and tag-responses Misc: Add cmd/main to .gitignore Misc: Delete built binary Main: Refactor main.go - Use log.Fatal instead of fmt.Printf and os.Exit - Move Config reading into seperate function - Parse command line flags in main() - Instantiate Features.go struct inside main() - Use simple ticker to set bot status every 15 minutes Auth: Refactor auth - Return early when building Admin role list - Move CheckAdminrole() into auth.go, remove roles.go Features: Refactor features - Remove New() function - Move help.go, ping.go functionality into misc.go Features: Add bot control feature to set status. Features: Implement helper function for embeds, return errors. Main: Rename config file to bot_config.json Features: Use success embed for user color. Features: Add purge messages feature. Main: Add status_text property to config, use it for Bot Status. Features: Send welcome message to new users, implement auto-join roles. Main: Use complex user status Main: Reduce ticker interval to 10 minutes for bot status update. Main: Create helper function for complex custom embeds. Features: Implement info command. Features: Convert requested user color to lowercase. Features: Add markdown helper Features: Fix markdown helper typo Features: Use error embed for handleSetStatus incorrect permissions. Features: Add strikethrough and spoilers information to markdown info. Features: Add info and md to help text. Features: Use backtick instead of single quote for command prefix in help text. Features: Remove markdown info message after 15 seconds. Features: Fix typo in status setting permission error. Features: Add commands to convert between Celsius and Farenheit Features: Update help to include temperature conversion commands. Features/Models/Main: Load color roles from JSON config. Auth/Main/Features/Models: Implement config-based channel white/blacklisting. Main/Models: Remove unused admin_only config field. Features: Simplify error handling. Auth: Remove leftover AdminOnly field. Features: Use command restriction for usercolor commands. Main: Update default config to restrict color and colors commands. Auth/Features: Return true for undefined commands in restrictions list by default. Features: Use better error messages for channel white/blacklist Auth: Improve channel white/blacklist behavior. Main: Replace broken ticker for status updates Features: Get bot avatar via Discord for embed. Features: Delete requesting message for markdown info. Features: Handle potential error in deleting help requester message.
2020-04-11 14:16:09 +00:00
_, err := s.ChannelMessageSendEmbed(m.ChannelID, msg)
if err != nil {
return err
}
err = s.ChannelMessageDelete(m.ChannelID, m.ID)
if err != nil {
return err
}
return nil
}
2021-05-29 12:17:01 +00:00
func (c *Commands) handleRules(s *discordgo.Session, m *discordgo.MessageCreate) error {
msg := c.Config.RulesText
embedTitle := "Rules (" + c.Config.GuildName + ")"
embed := c.CreateDefinedEmbed(embedTitle, msg, "success", m.Author)
_, err := s.ChannelMessageSendEmbed(m.ChannelID, embed)
if err != nil {
return err
}
return nil
}
2021-05-29 12:17:01 +00:00
func (c *Commands) handleMarkdownInfo(s *discordgo.Session, m *discordgo.MessageCreate) error {
cleanup := true
args := strings.Split(m.Content, " ")
if len(args) == 2 {
2021-05-29 12:17:01 +00:00
if args[1] == "stay" && c.Permissions.CheckAdminRole(m.Member) {
cleanup = false
}
}
Create Scuzzy Features: Hastily add usercolor feature Main: Show prefix in bot status Features: add cat Main/Features/Auth: Add basic Role Name/ID based command authentication and bot configuration. Main: Sanity check for missing flags. Features: Implement command deletion and tag-responses Misc: Add cmd/main to .gitignore Misc: Delete built binary Main: Refactor main.go - Use log.Fatal instead of fmt.Printf and os.Exit - Move Config reading into seperate function - Parse command line flags in main() - Instantiate Features.go struct inside main() - Use simple ticker to set bot status every 15 minutes Auth: Refactor auth - Return early when building Admin role list - Move CheckAdminrole() into auth.go, remove roles.go Features: Refactor features - Remove New() function - Move help.go, ping.go functionality into misc.go Features: Add bot control feature to set status. Features: Implement helper function for embeds, return errors. Main: Rename config file to bot_config.json Features: Use success embed for user color. Features: Add purge messages feature. Main: Add status_text property to config, use it for Bot Status. Features: Send welcome message to new users, implement auto-join roles. Main: Use complex user status Main: Reduce ticker interval to 10 minutes for bot status update. Main: Create helper function for complex custom embeds. Features: Implement info command. Features: Convert requested user color to lowercase. Features: Add markdown helper Features: Fix markdown helper typo Features: Use error embed for handleSetStatus incorrect permissions. Features: Add strikethrough and spoilers information to markdown info. Features: Add info and md to help text. Features: Use backtick instead of single quote for command prefix in help text. Features: Remove markdown info message after 15 seconds. Features: Fix typo in status setting permission error. Features: Add commands to convert between Celsius and Farenheit Features: Update help to include temperature conversion commands. Features/Models/Main: Load color roles from JSON config. Auth/Main/Features/Models: Implement config-based channel white/blacklisting. Main/Models: Remove unused admin_only config field. Features: Simplify error handling. Auth: Remove leftover AdminOnly field. Features: Use command restriction for usercolor commands. Main: Update default config to restrict color and colors commands. Auth/Features: Return true for undefined commands in restrictions list by default. Features: Use better error messages for channel white/blacklist Auth: Improve channel white/blacklist behavior. Main: Replace broken ticker for status updates Features: Get bot avatar via Discord for embed. Features: Delete requesting message for markdown info. Features: Handle potential error in deleting help requester message.
2020-04-11 14:16:09 +00:00
desc := "*Italic* text goes between `*single asterisks*`\n"
desc += "**Bold** text goes between `**double asterisks**`\n"
desc += "***Bold and Italic*** text goes between `***triple asterisks***`\n"
desc += "__Underlined__ text goes between `__double underscore__`\n"
desc += "~~Strikethrough~~ text goes between `~~double tilde~~`\n"
desc += "||Spoilers|| go between `|| double pipe ||`\n\n"
desc += "You can combine the above styles.\n\n"
desc += "Inline Code Blocks start and end with a single `````\n"
desc += "Multi line Code Blocks start and end with ```````\n"
desc += "Multi line Code Blocks can also specify a language with `````language`` at the start\n\n"
desc += "Single line quotes start with `>`\n"
desc += "Multi line quotes start with `>>>`\n"
2021-05-29 12:17:01 +00:00
msg := c.CreateDefinedEmbed("Discord Markdown", desc, "", m.Author)
Create Scuzzy Features: Hastily add usercolor feature Main: Show prefix in bot status Features: add cat Main/Features/Auth: Add basic Role Name/ID based command authentication and bot configuration. Main: Sanity check for missing flags. Features: Implement command deletion and tag-responses Misc: Add cmd/main to .gitignore Misc: Delete built binary Main: Refactor main.go - Use log.Fatal instead of fmt.Printf and os.Exit - Move Config reading into seperate function - Parse command line flags in main() - Instantiate Features.go struct inside main() - Use simple ticker to set bot status every 15 minutes Auth: Refactor auth - Return early when building Admin role list - Move CheckAdminrole() into auth.go, remove roles.go Features: Refactor features - Remove New() function - Move help.go, ping.go functionality into misc.go Features: Add bot control feature to set status. Features: Implement helper function for embeds, return errors. Main: Rename config file to bot_config.json Features: Use success embed for user color. Features: Add purge messages feature. Main: Add status_text property to config, use it for Bot Status. Features: Send welcome message to new users, implement auto-join roles. Main: Use complex user status Main: Reduce ticker interval to 10 minutes for bot status update. Main: Create helper function for complex custom embeds. Features: Implement info command. Features: Convert requested user color to lowercase. Features: Add markdown helper Features: Fix markdown helper typo Features: Use error embed for handleSetStatus incorrect permissions. Features: Add strikethrough and spoilers information to markdown info. Features: Add info and md to help text. Features: Use backtick instead of single quote for command prefix in help text. Features: Remove markdown info message after 15 seconds. Features: Fix typo in status setting permission error. Features: Add commands to convert between Celsius and Farenheit Features: Update help to include temperature conversion commands. Features/Models/Main: Load color roles from JSON config. Auth/Main/Features/Models: Implement config-based channel white/blacklisting. Main/Models: Remove unused admin_only config field. Features: Simplify error handling. Auth: Remove leftover AdminOnly field. Features: Use command restriction for usercolor commands. Main: Update default config to restrict color and colors commands. Auth/Features: Return true for undefined commands in restrictions list by default. Features: Use better error messages for channel white/blacklist Auth: Improve channel white/blacklist behavior. Main: Replace broken ticker for status updates Features: Get bot avatar via Discord for embed. Features: Delete requesting message for markdown info. Features: Handle potential error in deleting help requester message.
2020-04-11 14:16:09 +00:00
r, err := s.ChannelMessageSendEmbed(m.ChannelID, msg)
if err != nil {
return err
}
if cleanup {
time.Sleep(15 * time.Second)
Create Scuzzy Features: Hastily add usercolor feature Main: Show prefix in bot status Features: add cat Main/Features/Auth: Add basic Role Name/ID based command authentication and bot configuration. Main: Sanity check for missing flags. Features: Implement command deletion and tag-responses Misc: Add cmd/main to .gitignore Misc: Delete built binary Main: Refactor main.go - Use log.Fatal instead of fmt.Printf and os.Exit - Move Config reading into seperate function - Parse command line flags in main() - Instantiate Features.go struct inside main() - Use simple ticker to set bot status every 15 minutes Auth: Refactor auth - Return early when building Admin role list - Move CheckAdminrole() into auth.go, remove roles.go Features: Refactor features - Remove New() function - Move help.go, ping.go functionality into misc.go Features: Add bot control feature to set status. Features: Implement helper function for embeds, return errors. Main: Rename config file to bot_config.json Features: Use success embed for user color. Features: Add purge messages feature. Main: Add status_text property to config, use it for Bot Status. Features: Send welcome message to new users, implement auto-join roles. Main: Use complex user status Main: Reduce ticker interval to 10 minutes for bot status update. Main: Create helper function for complex custom embeds. Features: Implement info command. Features: Convert requested user color to lowercase. Features: Add markdown helper Features: Fix markdown helper typo Features: Use error embed for handleSetStatus incorrect permissions. Features: Add strikethrough and spoilers information to markdown info. Features: Add info and md to help text. Features: Use backtick instead of single quote for command prefix in help text. Features: Remove markdown info message after 15 seconds. Features: Fix typo in status setting permission error. Features: Add commands to convert between Celsius and Farenheit Features: Update help to include temperature conversion commands. Features/Models/Main: Load color roles from JSON config. Auth/Main/Features/Models: Implement config-based channel white/blacklisting. Main/Models: Remove unused admin_only config field. Features: Simplify error handling. Auth: Remove leftover AdminOnly field. Features: Use command restriction for usercolor commands. Main: Update default config to restrict color and colors commands. Auth/Features: Return true for undefined commands in restrictions list by default. Features: Use better error messages for channel white/blacklist Auth: Improve channel white/blacklist behavior. Main: Replace broken ticker for status updates Features: Get bot avatar via Discord for embed. Features: Delete requesting message for markdown info. Features: Handle potential error in deleting help requester message.
2020-04-11 14:16:09 +00:00
err = s.ChannelMessageDelete(m.ChannelID, r.ID)
if err != nil {
return err
}
err = s.ChannelMessageDelete(m.ChannelID, m.ID)
if err != nil {
return err
}
Create Scuzzy Features: Hastily add usercolor feature Main: Show prefix in bot status Features: add cat Main/Features/Auth: Add basic Role Name/ID based command authentication and bot configuration. Main: Sanity check for missing flags. Features: Implement command deletion and tag-responses Misc: Add cmd/main to .gitignore Misc: Delete built binary Main: Refactor main.go - Use log.Fatal instead of fmt.Printf and os.Exit - Move Config reading into seperate function - Parse command line flags in main() - Instantiate Features.go struct inside main() - Use simple ticker to set bot status every 15 minutes Auth: Refactor auth - Return early when building Admin role list - Move CheckAdminrole() into auth.go, remove roles.go Features: Refactor features - Remove New() function - Move help.go, ping.go functionality into misc.go Features: Add bot control feature to set status. Features: Implement helper function for embeds, return errors. Main: Rename config file to bot_config.json Features: Use success embed for user color. Features: Add purge messages feature. Main: Add status_text property to config, use it for Bot Status. Features: Send welcome message to new users, implement auto-join roles. Main: Use complex user status Main: Reduce ticker interval to 10 minutes for bot status update. Main: Create helper function for complex custom embeds. Features: Implement info command. Features: Convert requested user color to lowercase. Features: Add markdown helper Features: Fix markdown helper typo Features: Use error embed for handleSetStatus incorrect permissions. Features: Add strikethrough and spoilers information to markdown info. Features: Add info and md to help text. Features: Use backtick instead of single quote for command prefix in help text. Features: Remove markdown info message after 15 seconds. Features: Fix typo in status setting permission error. Features: Add commands to convert between Celsius and Farenheit Features: Update help to include temperature conversion commands. Features/Models/Main: Load color roles from JSON config. Auth/Main/Features/Models: Implement config-based channel white/blacklisting. Main/Models: Remove unused admin_only config field. Features: Simplify error handling. Auth: Remove leftover AdminOnly field. Features: Use command restriction for usercolor commands. Main: Update default config to restrict color and colors commands. Auth/Features: Return true for undefined commands in restrictions list by default. Features: Use better error messages for channel white/blacklist Auth: Improve channel white/blacklist behavior. Main: Replace broken ticker for status updates Features: Get bot avatar via Discord for embed. Features: Delete requesting message for markdown info. Features: Handle potential error in deleting help requester message.
2020-04-11 14:16:09 +00:00
}
return nil
}
2021-05-29 12:17:01 +00:00
func (c *Commands) handleCtoF(s *discordgo.Session, m *discordgo.MessageCreate) error {
Create Scuzzy Features: Hastily add usercolor feature Main: Show prefix in bot status Features: add cat Main/Features/Auth: Add basic Role Name/ID based command authentication and bot configuration. Main: Sanity check for missing flags. Features: Implement command deletion and tag-responses Misc: Add cmd/main to .gitignore Misc: Delete built binary Main: Refactor main.go - Use log.Fatal instead of fmt.Printf and os.Exit - Move Config reading into seperate function - Parse command line flags in main() - Instantiate Features.go struct inside main() - Use simple ticker to set bot status every 15 minutes Auth: Refactor auth - Return early when building Admin role list - Move CheckAdminrole() into auth.go, remove roles.go Features: Refactor features - Remove New() function - Move help.go, ping.go functionality into misc.go Features: Add bot control feature to set status. Features: Implement helper function for embeds, return errors. Main: Rename config file to bot_config.json Features: Use success embed for user color. Features: Add purge messages feature. Main: Add status_text property to config, use it for Bot Status. Features: Send welcome message to new users, implement auto-join roles. Main: Use complex user status Main: Reduce ticker interval to 10 minutes for bot status update. Main: Create helper function for complex custom embeds. Features: Implement info command. Features: Convert requested user color to lowercase. Features: Add markdown helper Features: Fix markdown helper typo Features: Use error embed for handleSetStatus incorrect permissions. Features: Add strikethrough and spoilers information to markdown info. Features: Add info and md to help text. Features: Use backtick instead of single quote for command prefix in help text. Features: Remove markdown info message after 15 seconds. Features: Fix typo in status setting permission error. Features: Add commands to convert between Celsius and Farenheit Features: Update help to include temperature conversion commands. Features/Models/Main: Load color roles from JSON config. Auth/Main/Features/Models: Implement config-based channel white/blacklisting. Main/Models: Remove unused admin_only config field. Features: Simplify error handling. Auth: Remove leftover AdminOnly field. Features: Use command restriction for usercolor commands. Main: Update default config to restrict color and colors commands. Auth/Features: Return true for undefined commands in restrictions list by default. Features: Use better error messages for channel white/blacklist Auth: Improve channel white/blacklist behavior. Main: Replace broken ticker for status updates Features: Get bot avatar via Discord for embed. Features: Delete requesting message for markdown info. Features: Handle potential error in deleting help requester message.
2020-04-11 14:16:09 +00:00
inS := strings.Split(m.Content, " ")
if len(inS) < 2 {
return errors.New("You did not specify a temperature")
}
in := inS[1]
inF, err := strconv.ParseFloat(in, 2)
if err != nil {
return errors.New("You did not specify a valid number")
}
cels := (inF * 9.0 / 5.0) + 32.0
celsF := float64(cels)
msg := fmt.Sprintf("`%.1f°c` is `%.1f°f`", inF, celsF)
2021-05-29 12:17:01 +00:00
e := c.CreateDefinedEmbed("Celsius to Farenheit", msg, "", m.Author)
Create Scuzzy Features: Hastily add usercolor feature Main: Show prefix in bot status Features: add cat Main/Features/Auth: Add basic Role Name/ID based command authentication and bot configuration. Main: Sanity check for missing flags. Features: Implement command deletion and tag-responses Misc: Add cmd/main to .gitignore Misc: Delete built binary Main: Refactor main.go - Use log.Fatal instead of fmt.Printf and os.Exit - Move Config reading into seperate function - Parse command line flags in main() - Instantiate Features.go struct inside main() - Use simple ticker to set bot status every 15 minutes Auth: Refactor auth - Return early when building Admin role list - Move CheckAdminrole() into auth.go, remove roles.go Features: Refactor features - Remove New() function - Move help.go, ping.go functionality into misc.go Features: Add bot control feature to set status. Features: Implement helper function for embeds, return errors. Main: Rename config file to bot_config.json Features: Use success embed for user color. Features: Add purge messages feature. Main: Add status_text property to config, use it for Bot Status. Features: Send welcome message to new users, implement auto-join roles. Main: Use complex user status Main: Reduce ticker interval to 10 minutes for bot status update. Main: Create helper function for complex custom embeds. Features: Implement info command. Features: Convert requested user color to lowercase. Features: Add markdown helper Features: Fix markdown helper typo Features: Use error embed for handleSetStatus incorrect permissions. Features: Add strikethrough and spoilers information to markdown info. Features: Add info and md to help text. Features: Use backtick instead of single quote for command prefix in help text. Features: Remove markdown info message after 15 seconds. Features: Fix typo in status setting permission error. Features: Add commands to convert between Celsius and Farenheit Features: Update help to include temperature conversion commands. Features/Models/Main: Load color roles from JSON config. Auth/Main/Features/Models: Implement config-based channel white/blacklisting. Main/Models: Remove unused admin_only config field. Features: Simplify error handling. Auth: Remove leftover AdminOnly field. Features: Use command restriction for usercolor commands. Main: Update default config to restrict color and colors commands. Auth/Features: Return true for undefined commands in restrictions list by default. Features: Use better error messages for channel white/blacklist Auth: Improve channel white/blacklist behavior. Main: Replace broken ticker for status updates Features: Get bot avatar via Discord for embed. Features: Delete requesting message for markdown info. Features: Handle potential error in deleting help requester message.
2020-04-11 14:16:09 +00:00
_, err = s.ChannelMessageSendEmbed(m.ChannelID, e)
if err != nil {
return err
}
return nil
}
2021-05-29 12:17:01 +00:00
func (c *Commands) handleFtoC(s *discordgo.Session, m *discordgo.MessageCreate) error {
Create Scuzzy Features: Hastily add usercolor feature Main: Show prefix in bot status Features: add cat Main/Features/Auth: Add basic Role Name/ID based command authentication and bot configuration. Main: Sanity check for missing flags. Features: Implement command deletion and tag-responses Misc: Add cmd/main to .gitignore Misc: Delete built binary Main: Refactor main.go - Use log.Fatal instead of fmt.Printf and os.Exit - Move Config reading into seperate function - Parse command line flags in main() - Instantiate Features.go struct inside main() - Use simple ticker to set bot status every 15 minutes Auth: Refactor auth - Return early when building Admin role list - Move CheckAdminrole() into auth.go, remove roles.go Features: Refactor features - Remove New() function - Move help.go, ping.go functionality into misc.go Features: Add bot control feature to set status. Features: Implement helper function for embeds, return errors. Main: Rename config file to bot_config.json Features: Use success embed for user color. Features: Add purge messages feature. Main: Add status_text property to config, use it for Bot Status. Features: Send welcome message to new users, implement auto-join roles. Main: Use complex user status Main: Reduce ticker interval to 10 minutes for bot status update. Main: Create helper function for complex custom embeds. Features: Implement info command. Features: Convert requested user color to lowercase. Features: Add markdown helper Features: Fix markdown helper typo Features: Use error embed for handleSetStatus incorrect permissions. Features: Add strikethrough and spoilers information to markdown info. Features: Add info and md to help text. Features: Use backtick instead of single quote for command prefix in help text. Features: Remove markdown info message after 15 seconds. Features: Fix typo in status setting permission error. Features: Add commands to convert between Celsius and Farenheit Features: Update help to include temperature conversion commands. Features/Models/Main: Load color roles from JSON config. Auth/Main/Features/Models: Implement config-based channel white/blacklisting. Main/Models: Remove unused admin_only config field. Features: Simplify error handling. Auth: Remove leftover AdminOnly field. Features: Use command restriction for usercolor commands. Main: Update default config to restrict color and colors commands. Auth/Features: Return true for undefined commands in restrictions list by default. Features: Use better error messages for channel white/blacklist Auth: Improve channel white/blacklist behavior. Main: Replace broken ticker for status updates Features: Get bot avatar via Discord for embed. Features: Delete requesting message for markdown info. Features: Handle potential error in deleting help requester message.
2020-04-11 14:16:09 +00:00
inS := strings.Split(m.Content, " ")
if len(inS) < 2 {
return errors.New("You did not specify a temperature")
}
in := inS[1]
inF, err := strconv.ParseFloat(in, 2)
if err != nil {
return errors.New("You did not specify a valid number")
}
faren := (inF - 32) * 5 / 9
farenF := float64(faren)
msg := fmt.Sprintf("`%.1f°f` is `%.1f°c`", inF, farenF)
2021-05-29 12:17:01 +00:00
e := c.CreateDefinedEmbed("Farenheit to Celsius", msg, "", m.Author)
Create Scuzzy Features: Hastily add usercolor feature Main: Show prefix in bot status Features: add cat Main/Features/Auth: Add basic Role Name/ID based command authentication and bot configuration. Main: Sanity check for missing flags. Features: Implement command deletion and tag-responses Misc: Add cmd/main to .gitignore Misc: Delete built binary Main: Refactor main.go - Use log.Fatal instead of fmt.Printf and os.Exit - Move Config reading into seperate function - Parse command line flags in main() - Instantiate Features.go struct inside main() - Use simple ticker to set bot status every 15 minutes Auth: Refactor auth - Return early when building Admin role list - Move CheckAdminrole() into auth.go, remove roles.go Features: Refactor features - Remove New() function - Move help.go, ping.go functionality into misc.go Features: Add bot control feature to set status. Features: Implement helper function for embeds, return errors. Main: Rename config file to bot_config.json Features: Use success embed for user color. Features: Add purge messages feature. Main: Add status_text property to config, use it for Bot Status. Features: Send welcome message to new users, implement auto-join roles. Main: Use complex user status Main: Reduce ticker interval to 10 minutes for bot status update. Main: Create helper function for complex custom embeds. Features: Implement info command. Features: Convert requested user color to lowercase. Features: Add markdown helper Features: Fix markdown helper typo Features: Use error embed for handleSetStatus incorrect permissions. Features: Add strikethrough and spoilers information to markdown info. Features: Add info and md to help text. Features: Use backtick instead of single quote for command prefix in help text. Features: Remove markdown info message after 15 seconds. Features: Fix typo in status setting permission error. Features: Add commands to convert between Celsius and Farenheit Features: Update help to include temperature conversion commands. Features/Models/Main: Load color roles from JSON config. Auth/Main/Features/Models: Implement config-based channel white/blacklisting. Main/Models: Remove unused admin_only config field. Features: Simplify error handling. Auth: Remove leftover AdminOnly field. Features: Use command restriction for usercolor commands. Main: Update default config to restrict color and colors commands. Auth/Features: Return true for undefined commands in restrictions list by default. Features: Use better error messages for channel white/blacklist Auth: Improve channel white/blacklist behavior. Main: Replace broken ticker for status updates Features: Get bot avatar via Discord for embed. Features: Delete requesting message for markdown info. Features: Handle potential error in deleting help requester message.
2020-04-11 14:16:09 +00:00
_, err = s.ChannelMessageSendEmbed(m.ChannelID, e)
if err != nil {
return err
}
return nil
}
2021-05-29 12:17:01 +00:00
func (c *Commands) handleMetersToFeet(s *discordgo.Session, m *discordgo.MessageCreate) error {
inS := strings.Split(m.Content, " ")
if len(inS) < 2 {
return errors.New("You did not specify a distance")
}
in := inS[1]
inF, err := strconv.ParseFloat(in, 2)
if err != nil {
return errors.New("You did not specify a valid number")
}
meters := inF * 3.28
metersF := float64(meters)
msg := fmt.Sprintf("`%.1fm` is `%.1fft`", inF, metersF)
2021-05-29 12:17:01 +00:00
e := c.CreateDefinedEmbed("Meters to Feet", msg, "", m.Author)
_, err = s.ChannelMessageSendEmbed(m.ChannelID, e)
if err != nil {
return err
}
return nil
}
2021-05-29 12:17:01 +00:00
func (c *Commands) handleFeetToMeters(s *discordgo.Session, m *discordgo.MessageCreate) error {
inS := strings.Split(m.Content, " ")
if len(inS) < 2 {
return errors.New("You did not specify a distance")
}
in := inS[1]
inF, err := strconv.ParseFloat(in, 2)
if err != nil {
return errors.New("You did not specify a valid number")
}
feet := inF / 3.28
feetF := float64(feet)
msg := fmt.Sprintf("`%.1fft` is `%.1fm`", inF, feetF)
2021-05-29 12:17:01 +00:00
e := c.CreateDefinedEmbed("Feet to Meters", msg, "", m.Author)
_, err = s.ChannelMessageSendEmbed(m.ChannelID, e)
if err != nil {
return err
}
return nil
}
2021-05-29 12:17:01 +00:00
func (c *Commands) handleCentimeterToInch(s *discordgo.Session, m *discordgo.MessageCreate) error {
inS := strings.Split(m.Content, " ")
if len(inS) < 2 {
return errors.New("You did not specify a distance")
}
in := inS[1]
inF, err := strconv.ParseFloat(in, 2)
if err != nil {
return errors.New("You did not specify a valid number")
}
inch := inF / 2.54
inchF := float64(inch)
msg := fmt.Sprintf("`%.1fcm` is `%.1fin`", inF, inchF)
2021-05-29 12:17:01 +00:00
e := c.CreateDefinedEmbed("Centimeter To Inch", msg, "", m.Author)
_, err = s.ChannelMessageSendEmbed(m.ChannelID, e)
if err != nil {
return err
}
return nil
}
2021-05-29 12:17:01 +00:00
func (c *Commands) handleInchToCentimeter(s *discordgo.Session, m *discordgo.MessageCreate) error {
inS := strings.Split(m.Content, " ")
if len(inS) < 2 {
return errors.New("You did not specify a distance")
}
in := inS[1]
inF, err := strconv.ParseFloat(in, 2)
if err != nil {
return errors.New("You did not specify a valid number")
}
cm := inF * 2.54
cmF := float64(cm)
msg := fmt.Sprintf("`%.1fin` is `%.1fcm`", inF, cmF)
2021-05-29 12:17:01 +00:00
e := c.CreateDefinedEmbed("Inch to Centimeter", msg, "", m.Author)
_, err = s.ChannelMessageSendEmbed(m.ChannelID, e)
if err != nil {
return err
}
return nil
}
2020-04-24 16:18:17 +00:00
2021-05-29 12:17:01 +00:00
func (c *Commands) handleUserInfo(s *discordgo.Session, m *discordgo.MessageCreate) error {
2020-04-24 16:18:17 +00:00
var (
mHandle *discordgo.Member
requester *discordgo.Member
err error
2020-04-24 16:18:17 +00:00
)
userSplit := strings.Split(m.Content, " ")
if len(userSplit) < 2 {
2021-05-29 12:17:01 +00:00
mHandle, err = s.GuildMember(c.Config.GuildID, m.Author.ID)
requester = mHandle
2020-04-24 16:18:17 +00:00
if err != nil {
return err
}
} else {
idStr := strings.ReplaceAll(userSplit[1], "<@!", "")
idStr = strings.ReplaceAll(idStr, "<@", "")
idStr = strings.ReplaceAll(idStr, ">", "")
2021-05-29 12:17:01 +00:00
mHandle, err = s.GuildMember(c.Config.GuildID, idStr)
2020-04-24 16:18:17 +00:00
if err != nil {
return err
}
2021-05-29 12:17:01 +00:00
requester, err = s.GuildMember(c.Config.GuildID, m.Author.ID)
if err != nil {
return err
}
2020-04-24 16:18:17 +00:00
}
rUserID := mHandle.User.ID
rUserNick := mHandle.Nick
rUsername := mHandle.User.Username
rUserDiscrim := mHandle.User.Discriminator
rUserAvatar := mHandle.User.AvatarURL("4096")
rJoinTime := mHandle.JoinedAt
rRoles := mHandle.Roles
if len(rUserNick) == 0 {
rUserNick = "No Nickname"
}
rJoinTimeP, err := rJoinTime.Parse()
if err != nil {
return err
}
rRolesTidy := ""
if len(rRoles) == 0 {
rRolesTidy = "No Roles"
} else {
for _, role := range rRoles {
rRolesTidy += "<@&" + role + "> "
}
}
msg := "**User ID**: `" + rUserID + "`\n"
msg += "**User Name**: `" + rUsername + "`\n"
msg += "**User Nick**: `" + rUserNick + "`\n"
msg += "**User Discrim**: `#" + rUserDiscrim + "`\n"
msg += "**User Join**: `" + rJoinTimeP.String() + "`\n"
msg += "**User Roles**: " + rRolesTidy + "\n"
2020-04-24 16:18:17 +00:00
embedData := models.CustomEmbed{
URL: "",
Title: "User Info (" + rUsername + ")",
Desc: msg,
Type: "",
Timestamp: time.Now().Format(time.RFC3339),
2020-04-24 16:18:17 +00:00
Color: 0xFFA500,
FooterText: "Requested by " + requester.User.Username + "#" + requester.User.Discriminator,
FooterImageURL: "",
2020-04-24 16:18:17 +00:00
ImageURL: "",
ImageH: 0,
ImageW: 0,
ThumbnailURL: rUserAvatar,
ThumbnailH: 512,
ThumbnailW: 512,
ProviderURL: "",
ProviderText: "",
AuthorText: "",
AuthorURL: "",
AuthorImageURL: "",
}
2021-05-29 12:17:01 +00:00
embed := c.CreateCustomEmbed(&embedData)
2020-04-24 16:18:17 +00:00
_, err = s.ChannelMessageSendEmbed(m.ChannelID, embed)
if err != nil {
return err
}
return nil
}
2020-05-04 20:50:17 +00:00
2021-05-29 12:17:01 +00:00
func (c *Commands) handleServerInfo(s *discordgo.Session, m *discordgo.MessageCreate) error {
g, err := s.Guild(c.Config.GuildID)
if err != nil {
return err
}
2021-05-29 12:17:01 +00:00
sID := c.Config.GuildID
sName := c.Config.GuildName
2021-05-29 12:17:01 +00:00
chans, _ := s.GuildChannels(c.Config.GuildID)
sChannels := strconv.Itoa(len(chans))
sEmojis := strconv.Itoa(len(g.Emojis))
sRoles := strconv.Itoa(len(g.Roles))
sRegion := g.Region
2020-12-29 21:41:18 +00:00
2021-05-29 12:17:01 +00:00
iID, _ := strconv.Atoi(c.Config.GuildID)
2020-12-29 21:41:18 +00:00
createdMSecs := ((iID / 4194304) + 1420070400000) / 1000
sCreatedAt := time.Unix(int64(createdMSecs), 0).Format(time.RFC1123)
sIconURL := g.IconURL()
2020-05-04 20:50:17 +00:00
user := m.Author
desc := "**Server ID**: `" + sID + "`\n"
desc += "**Server Name**: `" + sName + "`\n"
desc += "**Server Channels**: `" + sChannels + "`\n"
desc += "**Server Emojis**: `" + sEmojis + "`\n"
desc += "**Server Roles**: `" + sRoles + "`\n"
desc += "**Server Region**: `" + sRegion + "`\n"
2020-12-29 21:41:18 +00:00
desc += "**Server Creation**: `" + sCreatedAt + "`\n"
2020-05-04 20:50:17 +00:00
embedData := models.CustomEmbed{
URL: "",
Title: "Server Info (" + sName + ")",
Desc: desc,
Type: "",
Timestamp: time.Now().Format(time.RFC3339),
Color: 0xFFA500,
FooterText: "Requested by " + user.Username + "#" + user.Discriminator,
FooterImageURL: "",
2020-05-04 20:50:17 +00:00
ImageURL: "",
ImageH: 0,
ImageW: 0,
ThumbnailURL: sIconURL,
ThumbnailH: 256,
ThumbnailW: 256,
ProviderURL: "",
ProviderText: "",
AuthorText: "",
AuthorURL: "",
AuthorImageURL: "",
}
2021-05-29 12:17:01 +00:00
msg := c.CreateCustomEmbed(&embedData)
2020-05-04 20:50:17 +00:00
_, err = s.ChannelMessageSendEmbed(m.ChannelID, msg)
2020-05-04 20:50:17 +00:00
if err != nil {
return err
}
return nil
}
2022-08-16 12:32:53 +00:00
func (c *Commands) handleGoogle4U(s *discordgo.Session, m *discordgo.MessageCreate) error {
args := strings.Split(m.Content, " ")
if len(args) < 2 {
return errors.New("You did not specify anything to google")
}
input := m.Content[strings.Index(m.Content, " "):len(m.Content)]
desc := "https://letmegooglethat.com/?q=" + url.QueryEscape(input)
msg := c.CreateDefinedEmbed("Google", desc, "", m.Author)
_, err := s.ChannelMessageSendEmbed(m.ChannelID, msg)
if err != nil {
return err
}
err = s.ChannelMessageDelete(m.ChannelID, m.ID)
if err != nil {
return err
}
return nil
}