Roles of the member is not updated
See original GitHub issueSince some functions of 3.x do not work at some point,
I am migrating my project to version 4.
But I still have problems.
When I use GrantRoleAsync
or RevokeRoleAsync
of DiscordMember
, It is not reflected to Roles
.
I use .Net Core 2.1 and D#+ 4.0.0-nightly-00745.
Here is the code.
(First step):
var guild = discord.GetGuildAsync(DiscordConstants.GuildId).Result;
var member = guild.GetMemberAsync(id).Result;
var fooRole = guild.GetRole(DiscordConstants.FooRoleId);
var barRole = guild.GetRole(DiscordConstants.BarRoleId);
// In this example, it is assumed that the user has the Foo role.
if (member.Roles.Count() > 0 && member.Roles.Any(role => role.Name == "Foo"))
{
// Grant Bar, Revoke Foo.
member.GrantRoleAsync(barRole, reason).Wait();
member.RevokeRoleAsync(fooRole, reason).Wait();
}
(In other method that called in few seconds later):
var guild = discord.GetGuildAsync(DiscordConstants.GuildId).Result;
var member = guild.GetMemberAsync(id).Result;
var fooRole = guild.GetRole(DiscordConstants.FooRoleId);
var barRole = guild.GetRole(DiscordConstants.BarRoleId);
// This condition is not satisfied.
// `Roles` still has "Foo" and doesn't have "Bar".
if (member.Roles.Count() > 0 && member.Roles.Any(role => role.Name == "Bar"))
{
// Grant Foo, Revoke Bar. (Never executed.)
member.GrantRoleAsync(fooRole, reason).Wait();
member.RevokeRoleAsync(barRole, reason).Wait();
}
Need help.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
"Unable to Update Role" When trying to change role name ...
When I went to update one of my group members' roles, it simply prompted me saying “Unable to update the user's role.”. I...
Read more >Roles not updating
I can update the roles I created on WordPress's own roles and with this plugin. But, This plugin does not update the permissions...
Read more >role does not meet the selected updated criteria".
Hi,. I am now able to update the mass roles with role owner. However, strange thing is that while updating role owner, I...
Read more >Discord.py not seeing updates to User/Member roles
Restarting the bot allows one update again before it breaks, so it makes me think that something isn't updating when the user's roles...
Read more >Discord roles not updating
I'm trying to implement a way for my players Discord roles to be updated when they purchase a VIP and their Oxide group...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Solved by turning on the bot’s intent setting which is
SERVER MEMBERS INTENT
in the developer portal. Thank you all.I would fix what I mentioned above first. If you’re still having issues with that it is likely due to intents.