From 9af0a242819c241a713c91763c9fdb554901828a Mon Sep 17 00:00:00 2001 From: Riley Date: Tue, 13 Jul 2021 12:27:47 -0700 Subject: [PATCH] remove package core, remove setstatus in core.go --- core/arguments.go => arguments.go | 2 +- core/commands.go => commands.go | 2 +- core/consts.go => consts.go | 2 +- core/core.go => core.go | 16 ++-------------- core/fs.go => fs.go | 2 +- core/guilds.go => guilds.go | 2 +- core/handlers.go => handlers.go | 2 +- core/interaction.go => interaction.go | 2 +- core/response.go => response.go | 2 +- core/util.go => util.go | 24 ++++++++++++++++++------ core/workers.go => workers.go | 2 +- 11 files changed, 29 insertions(+), 29 deletions(-) rename core/arguments.go => arguments.go (99%) rename core/commands.go => commands.go (99%) rename core/consts.go => consts.go (97%) rename core/core.go => core.go (94%) rename core/fs.go => fs.go (99%) rename core/guilds.go => guilds.go (99%) rename core/handlers.go => handlers.go (97%) rename core/interaction.go => interaction.go (99%) rename core/response.go => response.go (99%) rename core/util.go => util.go (94%) rename core/workers.go => workers.go (98%) diff --git a/core/arguments.go b/arguments.go similarity index 99% rename from core/arguments.go rename to arguments.go index 01c2510..f8c6dc2 100644 --- a/core/arguments.go +++ b/arguments.go @@ -1,4 +1,4 @@ -package core +package framework import ( "errors" diff --git a/core/commands.go b/commands.go similarity index 99% rename from core/commands.go rename to commands.go index 46d31c8..dd4e307 100644 --- a/core/commands.go +++ b/commands.go @@ -1,4 +1,4 @@ -package core +package framework import ( "github.com/QPixel/orderedmap" diff --git a/core/consts.go b/consts.go similarity index 97% rename from core/consts.go rename to consts.go index 18383f5..7b987a1 100644 --- a/core/consts.go +++ b/consts.go @@ -1,4 +1,4 @@ -package core +package framework import "github.com/dlclark/regexp2" diff --git a/core/core.go b/core.go similarity index 94% rename from core/core.go rename to core.go index 8e64932..75e2d2d 100644 --- a/core/core.go +++ b/core.go @@ -1,4 +1,4 @@ -package core +package framework import ( "github.com/bwmarrin/discordgo" @@ -137,19 +137,7 @@ func Start() { // Bot ready log.Info("Initialization complete! The bot is now ready.") - // Set the bots status - var timeSinceIdle = 91879201 - Session.UpdateStatusComplex(discordgo.UpdateStatusData{ - Activities: []*discordgo.Activity{ - { - Name: "Mega Man Battle Network", - Type: 0, - }, - }, - Status: "dnd", - AFK: true, - IdleSince: &timeSinceIdle, - }) + // Info about slash commands log.Info(<-slashChannel) // -- GRACEFUL TERMINATION -- // diff --git a/core/fs.go b/fs.go similarity index 99% rename from core/fs.go rename to fs.go index 7cdb4e6..7b49727 100644 --- a/core/fs.go +++ b/fs.go @@ -1,4 +1,4 @@ -package core +package framework import ( "encoding/json" diff --git a/core/guilds.go b/guilds.go similarity index 99% rename from core/guilds.go rename to guilds.go index e73d3c2..fa99f00 100644 --- a/core/guilds.go +++ b/guilds.go @@ -1,4 +1,4 @@ -package core +package framework import ( "errors" diff --git a/core/handlers.go b/handlers.go similarity index 97% rename from core/handlers.go rename to handlers.go index 41e2eda..5ee0d69 100644 --- a/core/handlers.go +++ b/handlers.go @@ -1,4 +1,4 @@ -package core +package framework // handlers.go // Everything required for commands to pass their own handlers to discordgo diff --git a/core/interaction.go b/interaction.go similarity index 99% rename from core/interaction.go rename to interaction.go index 8753808..bbcc08b 100644 --- a/core/interaction.go +++ b/interaction.go @@ -1,4 +1,4 @@ -package core +package framework import ( "github.com/bwmarrin/discordgo" diff --git a/core/response.go b/response.go similarity index 99% rename from core/response.go rename to response.go index 1b427bc..b3ff6ca 100644 --- a/core/response.go +++ b/response.go @@ -1,4 +1,4 @@ -package core +package framework import ( "fmt" diff --git a/core/util.go b/util.go similarity index 94% rename from core/util.go rename to util.go index 881f472..b9ee2cd 100644 --- a/core/util.go +++ b/util.go @@ -1,9 +1,9 @@ -package core +package framework import ( "errors" "github.com/bwmarrin/discordgo" - "regexp" + "github.com/dlclark/regexp2" "strconv" "strings" ) @@ -27,26 +27,38 @@ func RemoveItem(slice []string, delete string) []string { // Given a string, ensure it contains only numbers // This is useful for stripping letters and formatting characters from user/role pings func EnsureNumbers(in string) string { - reg, err := regexp.Compile("[^0-9]+") + reg, err := regexp2.Compile("[^0-9]+", 0) if err != nil { log.Errorf("An unrecoverable error occurred when compiling a regex expression: %s", err) return "" } - return reg.ReplaceAllString(in, "") + str, err := reg.Replace(in, "", 0, 0) + + if err != nil { + log.Errorf("Unable to replace text in EnsureNumbers") + return "" + } + return str } // EnsureLetters // Given a string, ensure it contains only letters // This is useful for stripping numbers from mute durations, and possibly other things func EnsureLetters(in string) string { - reg, err := regexp.Compile("[^a-zA-Z]+") + reg, err := regexp2.Compile("[^a-zA-Z]+", 0) if err != nil { log.Errorf("An unrecoverable error occurred when compiling a regex expression: %s", err) return "" } - return reg.ReplaceAllString(in, "") + str, err := reg.Replace(in, "", 0, 0) + + if err != nil { + log.Errorf("Unable to replace text in EnsureLetters") + return "" + } + return str } // CleanId diff --git a/core/workers.go b/workers.go similarity index 98% rename from core/workers.go rename to workers.go index f6ebcfd..614a31a 100644 --- a/core/workers.go +++ b/workers.go @@ -1,4 +1,4 @@ -package core +package framework import ( "sync"