Skip to content
This repository has been archived by the owner on Nov 9, 2021. It is now read-only.

[Birthdays] Guild chunking depreciation #43

Open
aikaterna opened this issue Dec 27, 2020 · 1 comment
Open

[Birthdays] Guild chunking depreciation #43

aikaterna opened this issue Dec 27, 2020 · 1 comment

Comments

@aikaterna
Copy link
Contributor

Hey there, I'm getting
/.../Red-DiscordBot/cogs/CogManager/cogs/birthdays/birthdays.py:171: DeprecationWarning: request_offline_members is deprecated, use Guild.chunk instead. in my console.

This may be able to be fixed by just using await guild.chunk on the affected guilds instead of

await self.bot.request_offline_members(guild)

but this may cause issues for bots without specific presences as chunking can take a very long time in certain circumstances.

I'm also not sure if a guild.chunked check needs to be considered for addition to:

if not guild.unavailable and guild.large:

Figured I'd open an issue to see how you'd like to go about changing that or if you have time to take a look. If not no big deal, I may be able to do some experimenting and see how this can work.

@ZeLarpMaster
Copy link
Owner

ZeLarpMaster commented Dec 27, 2020

I think the best thing to do would be to stop using those functions. The only reason why that was necessary was because maybe_update_guild was immediately followed by a guild.get_member for usage in role changes as seen here:

await self.maybe_update_guild(guild)
member = guild.get_member(user_id)
if member is not None and role is not None and role in member.roles:
# If the user and the role are still on the server and the user has the bday role
await member.remove_roles(role)

Both of those aren't necessary if we instead update the roles by ids. Unfortunately discord.py only has APIs through its classes so we'll need to bypass those to make it work, but I think that's a worthy price to pay considering discord.py's lack of alternative options... This also has the side effect of removing the request of guild members and thus not making the bot wait for that before removing roles.

If you have better suggestions, I'm open for discussion

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants