Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempting to add the everyone role to a user causes 404 #780

Closed
Still34 opened this issue Aug 1, 2017 · 2 comments · Fixed by #781
Closed

Attempting to add the everyone role to a user causes 404 #780

Still34 opened this issue Aug 1, 2017 · 2 comments · Fixed by #781

Comments

@Still34
Copy link
Member

Still34 commented Aug 1, 2017

Title.
Reproducible using

        [Command("role-test")]
        public async Task RoleAddTest()
        {
            if (Context.User is SocketGuildUser user)
                await user.AddRolesAsync(new []{ Context.Guild.Roles.FirstOrDefault(x => x.IsEveryone), Context.Guild.Roles.FirstOrDefault(x=>!x.IsEveryone)});
        }

Stack trace

      Command     Discord.Commands.CommandException: Error occurred executing "role-test" for Still#2876 in DevServer/nsfw-general. ---> Discord.Net.HttpException: The server responded with error 404: NotFound
         at Discord.Net.Queue.RequestBucket.<SendAsync>d__18.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
         at Discord.Net.Queue.RequestQueue.<SendAsync>d__14.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
         at Discord.API.DiscordRestApiClient.<SendInternalAsync>d__62.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
         at Discord.API.DiscordRestApiClient.<SendAsync>d__51.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
         at Discord.API.DiscordRestApiClient.<AddRoleAsync>d__73.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
         at Discord.Rest.UserHelper.<AddRolesAsync>d__4.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
         at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
         at GeneralBot.Commands.Owners.BotModule.<RoleAddTest>d__11.MoveNext() in C:\Users\34146\Source\Repos\GeneralBot\GeneralBot\Commands\Owners\BotModule.cs:line 42
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
         at Discord.Commands.ModuleClassBuilder.<>c__DisplayClass6_1.<<BuildCommand>g__ExecuteCallback1>d.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
         at Discord.Commands.CommandInfo.<ExecuteAsyncInternal>d__41.MoveNext()
         --- End of inner exception stack trace ---

This will also cause issues when adding roles whose collection contains the Everyone role (i.e. IGuildUser#AddRolesAsync()), the method will throw and exit immediately.
imo AddRoleAsync method should ignore the everyone role of the guild.

@foxbot
Copy link
Member

foxbot commented Aug 1, 2017

It doesn't seem like it would be good design to just start throwing out invalid request parameters - if anything, we could add a precondition here to preemptively stop role modifications with the everyone role attached (as we do with the 14-day age limit on bulk delete)

@Still34
Copy link
Member Author

Still34 commented Aug 1, 2017

I could see people accidentally adding EveryoneRole when filtering through the roles collection with LINQ - I know I did several times. I think adding a check on AddRoleAsync would be great.

foxbot added a commit that referenced this issue Aug 1, 2017
Auralytical pushed a commit that referenced this issue Aug 17, 2017
* Throw when attempting to add or remove a member's EveryoneRole

This resolves #780

* Removed braces
FiniteReality pushed a commit to FiniteReality/Discord.Net that referenced this issue May 5, 2018
…rd-net#781)

* Throw when attempting to add or remove a member's EveryoneRole

This resolves discord-net#780

* Removed braces
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 a pull request may close this issue.

2 participants