提交带图片链接的会导致崩溃
yoke1990 opened this issue · 2 comments
报错信息:
invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x863832]
goroutine 78 [running]:
wrap-midjourney/handlers.DiscordMsgUpdate(0xc000422380, 0xc0003a07a0)
/www/golang/wrap-midjourney/handlers/discord.go:91 +0x92
github.com/bwmarrin/discordgo.messageUpdateEventHandler.Handle(0xc000392370?, 0x58eff6?, {0x8fa6e0?, 0xc0003a07a0?})
/root/go/pkg/mod/github.com/bwmarrin/discordgo@v0.27.1/eventhandlers.go:873 +0x38
created by github.com/bwmarrin/discordgo.(*Session).handle
/root/go/pkg/mod/github.com/bwmarrin/discordgo@v0.27.1/event.go:171 +0x16a
报错的代码:
func DiscordMsgUpdate(s *discord.Session, m *discord.MessageUpdate) {
//......
if m.Author.ID == s.State.User.ID { //报错地方
fmt.Println("zi ji fa song")
return
}
分析:
这条报错了。大概逻辑就是 1.发送带图片链接魔法指令后 接收到 wait start 。2.紧接着 discord update时候,会获得特殊的机器人消息,把这个图片链接转为dicord链接的消息(猜测当带链接时候,discord不会发给mj服务器,而是自己转了链接后再发给mj服务器)。这个特殊的估计没有m.Author.ID
同样遇到这个问题