Updated discord.yml and Updated DiscordAddon.java - #34
Open
ItzErpandX wants to merge 4 commits into
Open
Conversation
Updated DiscordAddon.java
ItzErpandX
commented
Apr 10, 2025
| if (!DISCORD.getBoolean("create-thread", true)) return; | ||
| channel.createThreadChannel(DISCORD.getString("thread-name", "-"), message.getId()).queue(); | ||
| })); | ||
| Button.success("axir-accept:" + id, DISCORD.getString("messages.restore")), |
Author
There was a problem hiding this comment.
i don't know why it happened to be like this, i never added more spaces to this
ItzErpandX
commented
Apr 10, 2025
|
|
||
| public class DiscordAddon extends ListenerAdapter { | ||
| private JDA jda = null; | ||
| String requiredRoleId = DISCORD.getString("required-role-id"); |
Author
There was a problem hiding this comment.
while reviewing this i saw that i could have done it without this lol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What I did:
Switched from permission-based to role-based access control:
In discord.yml, I replaced the requirement for a specific permission with a requirement for a specific Discord role instead.
Fetched the required role ID from config:
In DiscordAddon.java, I added the following line:
String requiredRoleId = DISCORD.getString("required-role-id");This retrieves the role ID from discord.yml.
Changed the order of checks in button interaction logic:
Inside the
onButtonInteraction(@NotNull ButtonInteractionEvent event)method (line 99), I modified the logic so that it first:This fixes a bug where users without the proper permission could still click the "Accept" button. Although it would say they lacked permission, the action would still go through issuing the refund and giving items to the player. Now, the interaction is blocked entirely unless the user has the correct role.