serenity-rs / serenity

A Rust library for the Discord API.
https://discord.gg/serenity-rs
ISC License
4.65k stars 571 forks source link

I don't receive the GuildCreate and GuildDelete events (for when the bot joins / gets kicked from a guild) #2896

Closed Stay1444 closed 2 months ago

Stay1444 commented 2 months ago

I'm trying to receive the GuildCreate and GuildDelete events to do some stuff when the bot joins or leaves a guild. I'm currently just seeing which events come through, like dbg!(&event), and I see stuff like Ready, ShardReady and GuildMemberRemoved when the bot exists a guild, but I'm not getting the GuildCreate and GuildDelete ones. (I'm obviously adding the bot to a new server and kicking it)

Any ideas?

jamesbt365 commented 2 months ago

You do not have the associated intents. https://docs.rs/serenity/latest/serenity/model/gateway/struct.GatewayIntents.html#associatedconstant.GUILDS

Stay1444 commented 2 months ago

That was it, i thought GatewayIntents::privileged() included that, thank you.

jamesbt365 commented 2 months ago

privileged only enabled the intents that require Discord to whitelist the bot (when your bot is verified), non_privileged does the opposite, If you are unsure what intents do what, everything is documented on that page.

You can also see Discord's documentation directly.