Skip to content
This repository was archived by the owner on Mar 13, 2023. It is now read-only.

feat 💥: differentiate an unavailable guild coming back online #667

Merged
merged 2 commits into from
Oct 21, 2022

Conversation

LordOfPolls
Copy link
Member

What type of pull request is this?

  • Non-breaking code change
  • Breaking code change
  • Documentation change/addition
  • Tests change

Description

This allows NAFF to differentiate between GUILDCREATE events for new joins and unavailable guilds returning.
Breaking as this changes when GuildJoin is dispatched... but im pretty sure this behaviour isn’t desirable anyways

Changes

  • Check if the guild is already cached, if so, it was almost certainly an unavailable guild
  • Adds a new event: GuildAvailable which is dispatched when a guild comes back online, instead of GuildJoin

Checklist

  • I've formatted my code with Black
  • I've ensured my code works on Python 3.10.x
  • I've tested my code

@LordOfPolls LordOfPolls added Improvement Something that is already implemented but can be done better New Feature::Library A new feature for the library labels Oct 15, 2022
@Kigstn
Copy link
Member

Kigstn commented Oct 18, 2022

Not sure I like this, since behaviour would depend on user configs / cache state. I just fear that this will lead to confusion because the same guilds will trigger different events depending on the state. Additionally, the name of the events does imo not reflect that the logic behind it is basically a glorified guess and not a fact.

@LordOfPolls
Copy link
Member Author

LordOfPolls commented Oct 19, 2022

The issue is; discord gives no way for a library to determine if a GUILDCREATE event is a new guild or not. This is because library's/apps are expected to keep a cache of their guilds to handle that. While yes NAFF gives you the option to not do that, it should be anticipated it will cause issues.

With that in mind, even though a user could break this by disabling the guild cache, id argue any bot with a disabled guild cache shouldn''t be expecting accurate guild state events.

Its the same principle that you shouldn't be checking for changes in roles if you disable the role cache. Or message edits without a message cache.

Regarding the event naming, I think you're stretching there. The names are accurate regardless of how the state is determined,

@LordOfPolls LordOfPolls merged commit b73b92f into 2.x Oct 21, 2022
@LordOfPolls LordOfPolls deleted the guild_available branch October 21, 2022 16:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Improvement Something that is already implemented but can be done better New Feature::Library A new feature for the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants