Skip to content

Updated discord.yml and Updated DiscordAddon.java - #34

Open
ItzErpandX wants to merge 4 commits into
Artillex-Studios:masterfrom
ItzErpandX:master
Open

Updated discord.yml and Updated DiscordAddon.java#34
ItzErpandX wants to merge 4 commits into
Artillex-Studios:masterfrom
ItzErpandX:master

Conversation

@ItzErpandX

Copy link
Copy Markdown

What I did:

  1. 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.

  2. 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.

  3. 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:

    • Checks if the member object is null.
    • Then verifies if the interacting user has the required role (based on the ID from discord.yml).

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.

Updated DiscordAddon.java
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")),

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't know why it happened to be like this, i never added more spaces to this


public class DiscordAddon extends ListenerAdapter {
private JDA jda = null;
String requiredRoleId = DISCORD.getString("required-role-id");

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while reviewing this i saw that i could have done it without this lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant