Discord.Net icon indicating copy to clipboard operation
Discord.Net copied to clipboard

[Bug]: GetBansAsync() cannot get more than 1000 Users

Open 1NieR opened this issue 2 years ago • 3 comments

Check The Docs

  • [X] I double checked the docs and couldn't find any useful information.

Verify Issue Source

  • [x] I verified the issue was caused by Discord.Net.

Check your intents

  • [X] I double checked that I have the required intents.

Description

Guild.GetBansAsync() cannot get more than 1000 Users.

Version

Discord.Net 3.5.0

Working Version

Discord.Net 3.4.1

Logs

No response

Sample

            public async Task Unban([Leftover] string user)
            {
                var bans = await ctx.Guild.GetBansAsync(limit: 25000).FlattenAsync().ConfigureAwait(false);

                var bun = bans.FirstOrDefault(x => x.User.ToString()?.ToLowerInvariant() == user.ToLowerInvariant());

                if (bun is null)
                {
                    return;
                }
                
                await UnbanInternal(bun.User).ConfigureAwait(false);
            }

Packages

No response

1NieR avatar Apr 06 '22 07:04 1NieR

You can only get 1,000 per request at a time, you'll have to navigate the collection rather than flattening a single collection for it.

https://discord.com/developers/docs/resources/guild#get-guild-bans image

exsersewo avatar Apr 06 '22 13:04 exsersewo

@exsersewo Shouldn't it work the same way as the GetMessagesAsync()? image image

1NieR avatar Apr 06 '22 14:04 1NieR

It does, the intended behavior is to make calls until the self-defined limit is reached. Currently trying to figure out what is causing this to close out at 1000.

csmir avatar Apr 07 '22 13:04 csmir