mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-24 08:33:41 +01:00
refactor(discordbot): introduce Session interface for testability
Extract a Session interface from *discordgo.Session so DiscordBot methods can be tested with a mock — no live Discord connection required. Add AddHandler, RegisterCommands, and UserID methods to DiscordBot so external callers (main.go, sys_channel_server.go) no longer reach through bot.Session directly. Rewrite tests with a mockSession, raising discordbot coverage from 12.5% to 66.7%.
This commit is contained in:
3
main.go
3
main.go
@@ -63,8 +63,7 @@ func setupDiscordBot(config *cfg.Config, logger *zap.Logger) *discordbot.Discord
|
||||
preventClose(config, fmt.Sprintf("Discord: Failed to start, %s", err.Error()))
|
||||
}
|
||||
|
||||
_, err = bot.Session.ApplicationCommandBulkOverwrite(bot.Session.State.User.ID, "", discordbot.Commands)
|
||||
if err != nil {
|
||||
if err = bot.RegisterCommands(); err != nil {
|
||||
preventClose(config, fmt.Sprintf("Discord: Failed to start, %s", err.Error()))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user