updated some packages. minor refactoring

This commit is contained in:
vel 2021-08-21 19:50:30 -07:00
parent b4515ad957
commit b3aad68fb6
Signed by: velvox
GPG Key ID: 1C8200C1D689CEF5
5 changed files with 16 additions and 16 deletions

View File

@ -149,13 +149,13 @@ func Start() {
} }
// Add the commandHandler to the list of user-defined handlers // Add the commandHandler to the list of user-defined handlers
AddHandler(commandHandler) AddDGOHandler(commandHandler)
// Add the slash command handler to the list of user-defined handlers // Add the slash command handler to the list of user-defined handlers
AddHandler(handleInteraction) AddDGOHandler(handleInteraction)
// Add the handlers to the session // Add the handlers to the session
addHandlers() addDGoHandlers()
// Log that the login succeeded // Log that the login succeeded
log.Infof("Bot logged in as \"" + Session.State.Ready.User.Username + "#" + Session.State.Ready.User.Discriminator + "\"") log.Infof("Bot logged in as \"" + Session.State.Ready.User.Username + "#" + Session.State.Ready.User.Discriminator + "\"")

View File

@ -50,7 +50,7 @@ type Guild struct {
var Guilds = make(map[string]*Guild) var Guilds = make(map[string]*Guild)
// currentProvider // currentProvider
// A reference to a function that provides the guild info system with a database // A reference to a struct of functions that provides the guild info system with a database
// Or similar system to save guild data. // Or similar system to save guild data.
var currentProvider GuildProvider var currentProvider GuildProvider
@ -699,7 +699,7 @@ func (g *Guild) EnableCommandInChannel(command string, channelId string) error {
// DisableCommandInChannel // DisableCommandInChannel
// Given a command and channel ID, add that command to that channel's list of blocked commands // Given a command and channel ID, add that command to that channel's list of blocked commands
func (g *Guild) DisableTriggerInChannel(command string, channelId string) error { func (g *Guild) DisableCommandInChannel(command string, channelId string) error {
cleanedId := CleanId(channelId) cleanedId := CleanId(channelId)
if cleanedId == "" { if cleanedId == "" {
return errors.New("provided channel ID is invalid") return errors.New("provided channel ID is invalid")
@ -741,7 +741,7 @@ func (g *Guild) SetResponseChannel(channelId string) error {
} }
// Kick // Kick
// Kick a member // Kicks a member
func (g *Guild) Kick(userId string, reason string) error { func (g *Guild) Kick(userId string, reason string) error {
// Make sure the member exists // Make sure the member exists
member, err := g.GetMember(userId) member, err := g.GetMember(userId)
@ -758,7 +758,7 @@ func (g *Guild) Kick(userId string, reason string) error {
} }
// Ban // Ban
// Ban a user, who may not be a member // Bans a user, who may not be a member
func (g *Guild) Ban(userId string, reason string, deleteDays int) error { func (g *Guild) Ban(userId string, reason string, deleteDays int) error {
// Make sure the USER exists, because they may not be a member // Make sure the USER exists, because they may not be a member
user, err := GetUser(userId) user, err := GetUser(userId)

View File

@ -1,29 +1,29 @@
package framework package framework
// handlers.go // handlers.go
// Everything required for commands to pass their own handlers to discordgo // Everything required for commands to pass their own handlers to discordgo and the framework itself.
// handlers // handlers
// This list stores all the handlers that can be added to the bot // This list stores all the handlers that can be added to the bot
// It's basically a passthroughs for discordgo.AddHandler, but having a list // It's basically a passthroughs for discordgo.AddHandler, but having a list
// allows them to be collected ahead of time and then added all at once // allows them to be collected ahead of time and then added all at once
var handlers []interface{} var dGOHandlers []interface{}
// AddHandler // AddDGOHandler
// This provides a way for commands to pass handler functions through to discorgo, // This provides a way for commands to pass handler functions through to discordgo,
// and have them added properly during bot startup // and have them added properly during bot startup
func AddHandler(handler interface{}) { func AddDGOHandler(handler interface{}) {
handlers = append(handlers, handler) dGOHandlers = append(dGOHandlers, handler)
} }
// addHandlers // addHandlers
// Given all the handlers that have been pre-added to the handlers list, add them to the discordgo session // Given all the handlers that have been pre-added to the handlers list, add them to the discordgo session
func addHandlers() { func addDGoHandlers() {
if len(handlers) == 0 { if len(dGOHandlers) == 0 {
return return
} }
for _, handler := range handlers { for _, handler := range dGOHandlers {
Session.AddHandler(handler) Session.AddHandler(handler)
} }
} }