serenity
serenity copied to clipboard
guild_id field from the Message object returned by say() and send_message() is always None
The guild_id field from the Message object that's returned by say() and send_message() is always None, unlike the Message object given on commands or events.
Traced as far back as 0.8.0, but it may happen in older versions.
Reproducible code:
let m = msg.channel_id.send_message(&ctx, |m| m.content("test"))?;
assert!(m.guild_id == None);
let m = msg.channel_id.say(&ctx, "test")?;
assert!(m.guild_id == None);
I looked into this, and I'm not so sure it's a bug per se within serenity itself, more an issue/limitation of the discord api. If you look at the response body returned by the API on a message sent to a GuildChannel, you get something like this:
{"id": "703762060915507240", "type": 0, "content": "test", "channel_id": "681526530987524144", "author": {"id": "432683067019100160", "username": "BentBot", "avatar": "686c6f6cf670a504bb0ba85eabf504d4", "discriminator": "8648", "public_flags": 0, "bot": true}, "attachments": [], "embeds": [], "mentions": [], "mention_roles": [], "pinned": false, "mention_everyone": false, "tts": false, "timestamp": "2020-04-26T00:19:10.589000+00:00", "edited_timestamp": null, "flags": 0}
There is no guild_id, so it will always be None.
However, the case could be made that this is a problem with serenity's model and something else should instead be returned by send_message() and say().
~~I have requested to get the field when creating a message, see discord/discord-api-docs#2846.~~
It was rejected in discord/discord-api-docs#212.
@Lakelezz I believe this can be closed.
No, mentioning that guild_id is only got from the message event in the documentation should happen first. And if possible, the field could be filled from cache.
No, mentioning that guild_id is only got from the message event in the documentation should happen first. And if possible, the field could be filled from cache.
Done in #2151, issue can be closed