Skip to content

Commit

Permalink
fix nil pointer issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sekaiwish committed Oct 28, 2024
1 parent db4120b commit 7eef020
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions server/channelserver/sys_discord.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package channelserver

import (
"erupe-ce/config"
"erupe-ce/utils/database"
"fmt"
"sort"
Expand Down Expand Up @@ -154,15 +155,15 @@ func (server *ChannelServer) onDiscordMessage(ds *discordgo.Session, m *discordg
}
}
func (server *ChannelServer) DiscordChannelSend(charName string, content string) {
if server.erupeConfig.Discord.Enabled && server.discordBot != nil {
if config.GetConfig().Discord.Enabled && server.discordBot != nil {
message := fmt.Sprintf("**%s**: %s", charName, content)
server.discordBot.RealtimeChannelSend(message)
}
}

func (server *ChannelServer) DiscordScreenShotSend(charName string, title string, description string, articleToken string) {
if server.erupeConfig.Discord.Enabled && server.discordBot != nil {
imageUrl := fmt.Sprintf("%s:%d/api/ss/bbs/%s", server.erupeConfig.Screenshots.Host, server.erupeConfig.Screenshots.Port, articleToken)
if config.GetConfig().Discord.Enabled && server.discordBot != nil {
imageUrl := fmt.Sprintf("%s:%d/api/ss/bbs/%s", config.GetConfig().Screenshots.Host, config.GetConfig().Screenshots.Port, articleToken)
message := fmt.Sprintf("**%s**: %s - %s %s", charName, title, description, imageUrl)
server.discordBot.RealtimeChannelSend(message)
}
Expand Down

0 comments on commit 7eef020

Please sign in to comment.