System.NullReferenceException: Object reference not set to an instance of an object.
at Discord.WebSocket.SocketGuildChannel.GetPermissionOverwrite(IRole role)
at Discord.Permissions.ResolveChannel(IGuild guild, IGuildUser user, IGuildChannel channel, UInt64 guildPermissions)
at Discord.WebSocket.SocketTextChannel.<get_Users>b__13_0(SocketGuildUser x)
at System.Linq.Enumerable.WhereEnumerableIterator`1.ToArray()
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
at System.Collections.Immutable.ImmutableArray.ToImmutableArray[TSource](IEnumerable`1 items)
at Discord.WebSocket.SocketTextChannel.get_Users()
at Discord.WebSocket.SocketGuildChannel.Discord.IChannel.GetUsersAsync(CacheMode mode, RequestOptions options)
at Discord.Commands.UserTypeReader`1.<Read>d__0.MoveNext()
It happens to random users, never to me. One person said that it was temporarily fixed when they removed all roles form themselves and readded them back, but I wouldn't count on it. Looking at the code, it could be either that the EveryoneRole is somehow null at line 128, or that the GetRole on line 138 in Permissions.cs returns null.
Also, it has been happening for a very long time.

I'm guessing this issue is sourcing from a cache inconsistency with invisible users. If a user is cached with, for example, roles: [1, 2, 3], and the guild deletes role 2, it's possible that the invisible user might never be updated in our cache to reflect roles: [1, 3]. In this case, the library will try to pull permissions with guild.GetRole(2), returning null, producing a nullref on Permissions.cs:138.
Not sure how Discord and the library handle deleting roles, but this might be a good place to start looking.
Any updates on this?
Would like to get an update if possible. Happening on the one server I actually need it to work on.
anyone? anything? 2 more people with this problem today...
Edit: also, servers with this problem cannot have the bot (NadekoBot) prune messages with the number of messages as an argument.
Edit 2: had a server try removing all roles. they removed all roles that didnt come with bots, problem still there.
Any update on this? This issue has been plaguing my server. The bug seems to only affect my 10000 member guild, as my 2 person guild is unaffected.
Is there any update on this @foxbot ? My server just started having this issue after I deleted a role with many people in it, pretty much renders most of my bot useless.
That seems like the missing piece to reproducing this - we don't currently
update every user to remove deleted roles from their RoleIds, which in turn
would probably lead to the permissions error Kwoth was finding.
Hadn't considered this as a viable cause to the issue, I never really
considered it common that guilds would be deleting roles frequently enough
for this to be noticable.
On Jan 14, 2018 2:37 PM, "Dragon342" notifications@github.com wrote:
Is there any update on this @foxbot https://github.com/foxbot ? My
server just started having this issue after I deleted a role with many
people in it, pretty much renders most of my bot useless.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/RogueException/Discord.Net/issues/824#issuecomment-357535945,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMff8gcKlJQFA-Vkl80SQe3sWN8zu8SFks5tKld6gaJpZM4PjE-0
.
I'm going to reopen this until another party can verify that the changes made in 05cd1ff are effective at resolving this issue.
Most helpful comment
Any updates on this?