[Bug]: The MessageDeleted event does not return a message
MrAfitol opened this issue · 4 comments
MrAfitol commented
Check The Docs
- I double checked the docs and couldn't find any useful information.
Verify Issue Source
- I verified the issue was caused by Discord.Net.
Check your intents
- I double checked that I have the required intents.
Description
The MessageDeleted event does not return a message, although I have message caching enabled and everything is correct in the config
Version
3.10.0
Working Version
No response
Logs
A message () from Nickname#0000 was removed from the channel moderator-only ():
Sample
_client = new DiscordSocketClient(new DiscordSocketConfig { AlwaysDownloadUsers = true, MessageCacheSize = 10000, });
public async Task HandleMessageDelete(Cacheable<IMessage, ulong> cachedMessage, Cacheable<IMessageChannel, ulong> cachedChannel)
{
// check if the message exists in cache; if not, we cannot report what was removed
if (!cachedMessage.HasValue)
return;
// gets or downloads the channel if it's not in the cache
IMessageChannel channel = await cachedChannel.GetOrDownloadAsync();
var message = cachedMessage.Value;
Console.WriteLine(
$"A message ({message.Id}) from {message.Author} was removed from the channel {channel.Name} ({channel.Id}):"
+ Environment.NewLine
+ message.Content);
}
Packages
Discord.Net v3.10.0, Discord.Net.* v3.10.0, Microsoft.Extensions.DependencyInjection v8.0.0
MrAfitol commented
Misha-133 commented
You also need to specify intents in the DiscordSocketConfig
something like
new DiscordSocketConfig {
....
GatewayIntents = GatewayIntents.AllUnpriviliged | GatewayIntents.MessageContent
.....
}
MrAfitol commented
You also need to specify intents in the
DiscordSocketConfig
something likenew DiscordSocketConfig { .... GatewayIntents = GatewayIntents.AllUnpriviliged | GatewayIntents.MessageContent ..... }
It works, thank you very much
MrAfitol commented
You also need to specify intents in the
DiscordSocketConfig
something likenew DiscordSocketConfig { .... GatewayIntents = GatewayIntents.AllUnpriviliged | GatewayIntents.MessageContent ..... }
This fixed the problem, thank you very much!