discord-jda / JDA

Java wrapper for the popular chat & VOIP service: Discord https://discord.com
Apache License 2.0
4.28k stars 738 forks source link

GuildManager not able to remove roles from members #319

Closed cuzitsjonny closed 7 years ago

cuzitsjonny commented 7 years ago

I'm using the GuildManager by calling net.dv8tion.jda.core.entities.Guild#getController() in a command executor class of my Discord bot. It is possible to add roles to my users by calling net.dv8tion.jda.core.managers.GuildController#addRolesToMember(Member, Collection) but removing roles using net.dv8tion.jda.core.managers.GuildController#modifyMemberRoles(Member, Collection) or net.dv8tion.jda.core.managers.GuildController#removeRolesFromMember(Member, Collection) doesn't seem to be working. It's not throwing any exceptions, it's just not applying the update. My bot has ADMINISTRATOR permissions, so that shouldn't be a problem.

Mentioned command executor for reference: https://github.com/cuzitsjonny/DiscordBot/blob/master/src/com/cuzitsjonny/discordbot/FactionCommandExecutor.java

Almighty-Alpaca commented 7 years ago

It's a RestAction, you have to .queue() or complete() it

On Wed, Apr 19, 2017, 11:24 Jonny notifications@github.com wrote:

I'm using the GuildManager by calling net.dv8tion.jda.core.entities.Guild#getController() in a command executor class of my Discord bot. It is possible to add roles to my users by calling net.dv8tion.jda.core.managers.GuildController#addRolesToMember(Member, Collection) but removing roles using net.dv8tion.jda.core.managers.GuildController#modifyMemberRoles(Member, Collection) or net.dv8tion.jda.core.managers.GuildController#removeRolesFromMember(Member, Collection) doesn't seem to be working. It's not throwing any exceptions, it's just not applying the update. My bot has ADMINISTRATOR permissions, so that shouldn't be a problem.

Mentioned command executor for reference:

https://github.com/cuzitsjonny/DiscordBot/blob/master/src/com/cuzitsjonny/discordbot/FactionCommandExecutor.java

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/DV8FromTheWorld/JDA/issues/319, or mute the thread https://github.com/notifications/unsubscribe-auth/APDltApA2Z-7VZ8u8jUyjWdfM0EG234cks5rxdK6gaJpZM4NBayU .

cuzitsjonny commented 7 years ago

cries

This is just embarrassing, I can't believe I forgot the complete() at the end... Thank you, I'm sorry for wasting your time for this! D:

cuzitsjonny commented 7 years ago

Actually now the roles are stacking. So it's still not removing them in the first operation.

4132132

Updated command executor for reference: https://github.com/cuzitsjonny/DiscordBot/blob/master/src/com/cuzitsjonny/discordbot/FactionCommandExecutor.java

cuzitsjonny commented 7 years ago

Alright, I changed my application logic to use modify instead of a combination of add and remove. Now it's working!

Thanks for the quick reply to my problem though.