-
-
Notifications
You must be signed in to change notification settings - Fork 741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add Member#isPending #1478
add Member#isPending #1478
Conversation
Does the Discord API also allow for checking if a Guild has rule screening enabled and for fetching/updating said rules? |
Yes, it's a guild feature: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My main concern is that it is not documented if there's an event when this gets changed
src/main/java/net/dv8tion/jda/api/events/guild/member/update/GuildMemberUpdatePendingEvent.java
Show resolved
Hide resolved
There's a pull request to document this, but Discord doesn't make breaking changes regardless of documentation status. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@kantenkugel i thought about adding membership screening details too, but as those are unfinished, and more types are going to be added in the future, i think it will be better to wait until it's completely finished |
Regarding latest commit: is PUBLIC gone now? |
yes, it's gone at least from the official docs |
And is there a replacement? cuz public basically meant discoverable/community |
yep, that's literally |
Looking through the diffs of doc state of this branch and the discord docs, there are a few differences tho:
JDA Docs have extra (apart from the 2 new ones):
I wouldn't touch the MORE_EMOJI tho, since i am not sure about whether it is still used for some special servers (and iirc it was always kinda hidden). The other 2 might be wise to add here, as this MR already touches that part of the docs anyways |
i've added community and featurable features in my community updates/rules channel pr. more_emoji is more about your decision as i don't see any issue with removing it |
Ah ok, sorry about that then |
I searched about 4k guilds and did not find the MORE_EMOJI feature https://canary.discord.com/channels/125227483518861312/169484473333710848/790942477443923968 I suggest that if it was to be removed it should be its own PR |
# Conflicts: # src/main/java/net/dv8tion/jda/api/hooks/ListenerAdapter.java
Something I noticed, but why isn't there a |
|
Still needs a |
Yes it does. the classwalker still needs reference methods to call. if the method is not defined, it won't be called |
I tried out the event and it's kinda odd. The role does exist and the ID used matches it, since I use it in other places too, where I need the role. Anyone else having an idea? Code snippet used: @Override
public void onGuildMemberUpdatePending(@Nonnull GuildMemberUpdatePendingEvent event){
if(!event.getGuild().getId().equals(IDs.GUILD)){ // Check against a specific Guild ID.
return;
}
Guild guild = event.getGuild();
if(!event.getNewPending()){ // Check if Member still isn't confirmed
return;
}
Role member = guild.getRoleById(IDs.MEMBER); // Get the member role
guild.modifyMemberRoles(event.getMember(), Collections.singletonList(member), null)
.reason("Member " + event.getMember().getEffectiveName() + " passed Member screening")
.queue();
} |
Member update events only work when the member is cached. |
That's the odd thing here. Since I only use the bot on one Guild do I have the Member caching set to all. jda = JDABuilder.createDefault(fileManager.getString("config", "bot-token"))
.enableIntents(
GatewayIntent.GUILD_MEMBERS,
GatewayIntent.GUILD_PRESENCES
)
.setMemberCachePolicy(MemberCachePolicy.ALL)
.setChunkingFilter(ChunkingFilter.ALL)
.addEventListeners(
new CommandListener(this, commandHandler),
new ReadyListener(this),
new MemberListener(this), // Event is used here
new ReactionListener(this),
new RoleListener(),
new MessageListener(this)
)
.build(); |
Why? It's not like In case of pending it doesn't make any sense, it's very important thing that we need the fact that member accepted community rules (current new value) even if it doesn't cached and we can't get the previous value (which will be false most likely). It must be always fired to get the current value IMO. The old pending value could be just nullable in case it isn't available in cache. |
it's not like the "pending event" is an event by itself. it's a guild member update event and in order to fire the pending event, jda has to compare the previous pending boolean against the "new" pending boolean. if the previous state "isn't cached", jda cannot assume it's the pending flag being updated |
@GoldRenard https://ci.dv8tion.net/job/JDA/javadoc/net/dv8tion/jda/api/events/guild/member/GuildMemberUpdateEvent.html Discord only sends an update with the new data, regardless of what changes. The library cannot figure out what changed without a cache of the previous state. See also discord/discord-api-docs#2137 |
Yeah I figured it out by myself after reading discord docs just before your comment. Huff... Wanted to edit my first comment but you was faster. |
Something I'm curious to know about is, what exact settings, such as Cache Flags, Chunking filter, etc, are needed for this to work. I currently think that this could perhaps require the CLIENT_STATUS flag, which is disabled in createDefault, to work? I really see no other reason as to why the even either doesn't get fired or doesn't give back updated values like the new boolean. |
Maybe it makes sense to add a Example: static MemberCachePolicy PENDING = Member::isPending; In theory, this should allow bots to handle pending without caching all members. |
I think I found my issue. I used the EDIT: Yes. The system works now when I inverted the boolean. |
src/main/java/net/dv8tion/jda/api/events/guild/member/update/GuildMemberUpdatePendingEvent.java
Show resolved
Hide resolved
Since it seems like discord is still trying to figure this out we might just want to mark all these things as |
src/main/java/net/dv8tion/jda/api/events/guild/member/update/GuildMemberUpdatePendingEvent.java
Outdated
Show resolved
Hide resolved
…uildMemberUpdatePendingEvent.java Co-authored-by: Florian Spieß <[email protected]>
Pull Request Etiquette
Changes
Closes Issue: NaN
Description
this PR adds Member#isPending and GuildMemberUpdatePendingEvent. i'm not really sure about the event name as it's a pretty much one-way event but.. yeah