discord-net / Discord.Net

An unofficial .Net wrapper for the Discord API (https://discord.com/)
https://discordnet.dev
MIT License
3.34k stars 734 forks source link

GuildId is missing in SocketDiscordClient.MessageDeleted event #2863

Open bakirov-eldar opened 9 months ago

bakirov-eldar commented 9 months ago

image

public event Func<Cacheable<IMessage, ulong>, Cacheable<IMessageChannel, ulong>, Task> MessageDeleted

How can i get GuildId from this event?

Misha-133 commented 9 months ago
bakirov-eldar commented 9 months ago
  • Get the channel (call GetOrDownloadAsync() on the cacheable)
  • check whether the channel is a guild channel (if (channel is IGuildChannel guildChannel))
  • guildChannel.GuildId

Why would I need to load additional data if I just want to get the guild ID directly from the API event?

Misha-133 commented 9 months ago

That's a good question, but changing it at this point would be a breaking change. And most likely you have the channel cached already, so it won't download any additional data