mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-22 07:32:32 +01:00
refactor: Move realtime channels to its own config
This commit is contained in:
@@ -110,7 +110,7 @@ func (s *Server) onInteraction(ds *discordgo.Session, i *discordgo.InteractionCr
|
||||
// onDiscordMessage handles receiving messages from discord and forwarding them ingame.
|
||||
func (s *Server) onDiscordMessage(ds *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
// Ignore messages from our bot, or ones that are not in the correct channel.
|
||||
if m.Author.Bot || m.ChannelID != s.erupeConfig.Discord.RealtimeChannelID {
|
||||
if m.Author.Bot || m.ChannelID != s.erupeConfig.Discord.RealTimeChannel.RealtimeChannelID {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,11 @@ func NewDiscordBot(options Options) (discordBot *DiscordBot, err error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
realtimeChannel, err := session.Channel(options.Config.Discord.RealtimeChannelID)
|
||||
var realtimeChannel *discordgo.Channel
|
||||
|
||||
if options.Config.Discord.RealTimeChannel.Enabled {
|
||||
realtimeChannel, err = session.Channel(options.Config.Discord.RealTimeChannel.RealtimeChannelID)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
options.Logger.Fatal("Discord failed to create realtimeChannel", zap.Error(err))
|
||||
@@ -74,6 +78,10 @@ func (bot *DiscordBot) NormalizeDiscordMessage(message string) string {
|
||||
}
|
||||
|
||||
func (bot *DiscordBot) RealtimeChannelSend(message string) (err error) {
|
||||
if bot.RealtimeChannel == nil {
|
||||
return
|
||||
}
|
||||
|
||||
_, err = bot.Session.ChannelMessageSend(bot.RealtimeChannel.ID, message)
|
||||
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user