You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As per the title: If you paste a URL to an image as a message in the discord client, the client will re-render the URL as the image. My guess is this causes the discord client to not populate the GuildID field of the Message struct - I'm not sure if that's a problem on discord client end or discordgo library's end. I've worked around this in my code with the following:
funcEnsureGuildID(s*discordgo.Session, m*discordgo.Message) {
ifm.GuildID=="" {
c, err:=s.Channel(m.ChannelID)
iferr!=nil {
log.Fatalf("unable to get GuildID from Channel: %v", err)
}
m.GuildID=c.GuildIDlog.Printf("Added Guild %s to Message %s in Channel %s", m.GuildID, m.ID, m.ChannelID)
}
}
Other messages don't appear to cause this issue, just image URLs that have been converted to images. I imagine this is going to be tough to get fixed upstream; do we want to fix this in the library for now?
Is GuildID something we can rely on being set in the Message struct? I see that the struct tag implies it can be omitted if empty:
typeMessagestruct {
...// The ID of the guild in which the message was sent.GuildIDstring`json:"guild_id,omitempty"`...
}
The text was updated successfully, but these errors were encountered:
azekeil
changed the title
Using discord's client, pasting an image URL as the only content for a message causes the GuildID to be missing from the Message struct
Using discord's client, pasting an image URL as the only content for a message causes GuildID to be missing from the Message struct
Sep 30, 2024
As per the title: If you paste a URL to an image as a message in the discord client, the client will re-render the URL as the image. My guess is this causes the discord client to not populate the
GuildID
field of theMessage
struct - I'm not sure if that's a problem on discord client end or discordgo library's end. I've worked around this in my code with the following:Other messages don't appear to cause this issue, just image URLs that have been converted to images. I imagine this is going to be tough to get fixed upstream; do we want to fix this in the library for now?
Is GuildID something we can rely on being set in the Message struct? I see that the struct tag implies it can be omitted if empty:
The text was updated successfully, but these errors were encountered: