hypherionmc / sdlink

A simple to use Minecraft to Discord Chat linker with Whitelisting
MIT License
23 stars 7 forks source link

[BUG] access control not working #114

Closed Rockiecraft closed 5 months ago

Rockiecraft commented 7 months ago

none of the access control is working and the message like "you need this role" keep coming up, also when i verify/unverify my account i do not get the role added or removed that i have set.

ver 3.0.1 forge

Rockiecraft commented 7 months ago

idk why it fixed it or how it fixed me not being able to join. but i installed 3.0.0, then reinstalled 3.0.1 and now its working just fine. i'm not sure what other details i could give you, no logs say anything to indicate something. i'm able to join but still not given or removed the role set in config.

i'm gonna leave it open just in case it happens to someone else so they can leave a comment here.

hypherionmc commented 7 months ago

So the issue of role not setting/removing, is most likely because of discord role hierarchy.

What this means, is that a person/bot, who has a role lower than yours, cannot add or remove roles from you.

So let's say your discord has the following roles:

You have the Owner role, while your bot only has the Bots role. In this case, your bot cannot add and remove roles from you, because it has a role lower than yours.

The way to fix that, is to move the role specifically assigned to the bot (if you open the bot profile, you will see there is an additional role added to your bot, that usually matches the name of your bot), above your highest role. That way, the bot can add and remove roles from you. This is something we still have to document.

Rockiecraft commented 7 months ago

changing the roles around doesn't seem to work. i tested it on my other accounts with lower roles just to be extra sure. verifying works and i can join but the bot giving the roles is not happening.

hypherionmc commented 7 months ago

That's weird. Normally that is the major cause, and the other being the bot not having permissions to manage roles.

Smaller possibility is that the roles didn't load on startup for some reason, but that, and the not having permissions part should be printed to your log very clearly, unless your hosting provider is one of those that hide big chunks of text from the console.

What does your access control part of the config look like?

Rockiecraft commented 7 months ago
    #Enable Access Control
    enabled = true
    #Does the player need to be a member of your discord to join
    requireDiscordMembership = false
    #Can players verify multiple Minecraft Accounts
    allowMultipleAccounts = true
    #Optional: The player requires any of these roles to be able to join your server
    requiredRoles = []
    #Optional: Players with these roles will never be allowed access to your server
    deniedRoles = []
    #Optional: Role name or ID to assign to verified player accounts
    verifiedRole = ""
    #Should players with verified accounts, be banned from Minecraft if they get banned on discord
    banPlayerOnDiscordBan = false
    #Should members with verified accounts, be banned from discord when they are banned on Minecraft
    banMemberOnMinecraftBan = false

its the one that's generated, i have the role id in the verifiedRole = "" but it never gives the role. i don't put anything in the required roles option since it won't give the roles yet.

Rockiecraft commented 7 months ago

i forgot to add that sometimes, it does work after restarting the server. and other times doesn't. i'm not sure why it's going back and forth. the provider i have makes the server automatically restart at like 3 am

hypherionmc commented 6 months ago

This sounds like a case of the role not being loaded properly into the cache. Will have to check this out.

hypherionmc commented 6 months ago

Alright, looked over the code now while fixing and changing some stuff, and I don't see any reason for the roles not to load.

However, I discovered that some important error logging are hidden behind the debugging flag, so they will never make it to your console, unless you have debugging enabled in the config.

This could help you discover why this happens. I changed the code now to always log these errors, as they should

hypherionmc commented 5 months ago

I don't think this is fully fixed, but at least it should be clearer now if it fails. 3.1.0. If not, feel free to re-open :)