Webhook DisplayName is lost through caching
Created by: spydacarnage
Make sure you familiarize yourself with our contributing guidelines.
Summary
When a call to DiscordChannel.GetMessagesAsync
returns multiple messages created by the same Webhook, they are all attributed to the same user/member, with the same Username / DisplayName, even if each author object returned from the Discord API contains a different username.
Details
No exceptions are thrown, and this bug is operating system independent. I am running in .NET Core 3.1.
An example is the best way to describe this, I think:
If the first message in the batch contains the following author
property:
"author": {
"bot": true,
"id": "123451234512345405",
"username": "Bob",
"avatar": null,
"discriminator": "0000"
},
and the next one contains:
"author": {
"bot": true,
"id": "123451234512345405",
"username": "Sarah",
"avatar": null,
"discriminator": "0000"
},
both DiscordMessage
objects in the returns List
both have the same DiscordMember
object, with the same Username
and DisplayName
(i.e. "Sarah").
The problem appears to be in DiscordApiClient.PrepareMessage
, where the DiscordUser
/ DiscordMember
is being retrieved from the cache based on the user's Id (which is always set to the Id of the webhook)
Notes
I've toyed around with adding a new WebhookName
property to DiscordMember
and then changing the DisplayName
property to be this.WebhookName ?? this.Nickname ?? this.Username
, and that appears to work, but I don't know if you have a better method of preserving this information than that.