updated some packages. minor refactoring
This commit is contained in:
parent
b4515ad957
commit
b3aad68fb6
6
core.go
6
core.go
|
|
@ -149,13 +149,13 @@ func Start() {
|
|||
}
|
||||
|
||||
// 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
|
||||
AddHandler(handleInteraction)
|
||||
AddDGOHandler(handleInteraction)
|
||||
|
||||
// Add the handlers to the session
|
||||
addHandlers()
|
||||
addDGoHandlers()
|
||||
|
||||
// Log that the login succeeded
|
||||
log.Infof("Bot logged in as \"" + Session.State.Ready.User.Username + "#" + Session.State.Ready.User.Discriminator + "\"")
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ type Guild struct {
|
|||
var Guilds = make(map[string]*Guild)
|
||||
|
||||
// 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.
|
||||
var currentProvider GuildProvider
|
||||
|
||||
|
|
@ -699,7 +699,7 @@ func (g *Guild) EnableCommandInChannel(command string, channelId string) error {
|
|||
|
||||
// DisableCommandInChannel
|
||||
// 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)
|
||||
if cleanedId == "" {
|
||||
return errors.New("provided channel ID is invalid")
|
||||
|
|
@ -741,7 +741,7 @@ func (g *Guild) SetResponseChannel(channelId string) error {
|
|||
}
|
||||
|
||||
// Kick
|
||||
// Kick a member
|
||||
// Kicks a member
|
||||
func (g *Guild) Kick(userId string, reason string) error {
|
||||
// Make sure the member exists
|
||||
member, err := g.GetMember(userId)
|
||||
|
|
@ -758,7 +758,7 @@ func (g *Guild) Kick(userId string, reason string) error {
|
|||
}
|
||||
|
||||
// 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 {
|
||||
// Make sure the USER exists, because they may not be a member
|
||||
user, err := GetUser(userId)
|
||||
|
|
|
|||
18
handlers.go
18
handlers.go
|
|
@ -1,29 +1,29 @@
|
|||
package framework
|
||||
|
||||
// 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
|
||||
// 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
|
||||
// allows them to be collected ahead of time and then added all at once
|
||||
var handlers []interface{}
|
||||
var dGOHandlers []interface{}
|
||||
|
||||
// AddHandler
|
||||
// This provides a way for commands to pass handler functions through to discorgo,
|
||||
// AddDGOHandler
|
||||
// This provides a way for commands to pass handler functions through to discordgo,
|
||||
// and have them added properly during bot startup
|
||||
func AddHandler(handler interface{}) {
|
||||
handlers = append(handlers, handler)
|
||||
func AddDGOHandler(handler interface{}) {
|
||||
dGOHandlers = append(dGOHandlers, handler)
|
||||
}
|
||||
|
||||
// addHandlers
|
||||
// Given all the handlers that have been pre-added to the handlers list, add them to the discordgo session
|
||||
func addHandlers() {
|
||||
if len(handlers) == 0 {
|
||||
func addDGoHandlers() {
|
||||
if len(dGOHandlers) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
for _, handler := range handlers {
|
||||
for _, handler := range dGOHandlers {
|
||||
Session.AddHandler(handler)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue