mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-22 07:32:32 +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:
@@ -208,8 +208,8 @@ func (s *Server) Start() error {
|
||||
|
||||
// Start the discord bot for chat integration.
|
||||
if s.erupeConfig.Discord.Enabled && s.discordBot != nil {
|
||||
s.discordBot.Session.AddHandler(s.onDiscordMessage)
|
||||
s.discordBot.Session.AddHandler(s.onInteraction)
|
||||
s.discordBot.AddHandler(s.onDiscordMessage)
|
||||
s.discordBot.AddHandler(s.onInteraction)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user