serenity icon indicating copy to clipboard operation
serenity copied to clipboard

guild_id field from the Message object returned by say() and send_message() is always None

Open vicky5124 opened this issue 4 years ago • 4 comments

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);

vicky5124 avatar Apr 15 '20 02:04 vicky5124

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().

Th3-M4jor avatar Apr 26 '20 00:04 Th3-M4jor

~~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.

HarmoGlace avatar Apr 24 '21 22:04 HarmoGlace

@Lakelezz I believe this can be closed.

teotwaki avatar Sep 27 '21 20:09 teotwaki

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.

vicky5124 avatar Sep 27 '21 20:09 vicky5124

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

kangalio avatar Oct 25 '22 23:10 kangalio