Allow for sending chats out from external chat submodule
This commit is contained in:
15
app/bot.go
15
app/bot.go
@@ -62,6 +62,14 @@ func (app *Bot) Initialize(cfg *core.Config) error {
|
||||
|
||||
app.Session = discord.New(cfg.Discord.ApplicationID, app.guildID, cfg.Discord.Token, app.Database)
|
||||
|
||||
// Intialize submodules
|
||||
for channelID, chats := range app.channelChats {
|
||||
channel := app.Session.NewChannelFromID(channelID)
|
||||
for _, chat := range chats {
|
||||
app.InitalizeExternalChat(channel, chat)
|
||||
}
|
||||
}
|
||||
|
||||
// Register Event Handlers
|
||||
app.Session.OnReady(app.onReady)
|
||||
app.Session.OnEventCreate(app.onEventCreate)
|
||||
@@ -167,8 +175,8 @@ func (app *Bot) onEventComplete(d *discord.Discord, event common.Event) {
|
||||
|
||||
}
|
||||
|
||||
func (app *Bot) onMessageRecieved(d *discord.Discord, channel string, user common.User, message string) {
|
||||
chats, ok := app.channelChats[channel]
|
||||
func (app *Bot) onMessageRecieved(d *discord.Discord, channelID string, user common.User, message string) {
|
||||
chats, ok := app.channelChats[channelID]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
@@ -181,6 +189,7 @@ func (app *Bot) onMessageRecieved(d *discord.Discord, channel string, user commo
|
||||
// NewBot creates a new bot instance
|
||||
func NewBot(db persistence.Database) *Bot {
|
||||
return &Bot{
|
||||
Database: db,
|
||||
Database: db,
|
||||
channelChats: make(map[string][]common.ExternalChatModule),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user