fix: Range of issues presented by analyzer (#2404)

This commit is contained in:
Armano den Boef
2022-08-01 18:53:22 +02:00
committed by GitHub
parent cfd2662963
commit 902326d1f3
9 changed files with 56 additions and 58 deletions

View File

@@ -532,13 +532,10 @@ namespace Discord.WebSocket
Features = model.Features;
var roles = new ConcurrentDictionary<ulong, SocketRole>(ConcurrentHashSet.DefaultConcurrencyLevel, (int)(model.Roles.Length * 1.05));
if (model.Roles != null)
for (int i = 0; i < model.Roles.Length; i++)
{
for (int i = 0; i < model.Roles.Length; i++)
{
var role = SocketRole.Create(this, state, model.Roles[i]);
roles.TryAdd(role.Id, role);
}
var role = SocketRole.Create(this, state, model.Roles[i]);
roles.TryAdd(role.Id, role);
}
_roles = roles;

View File

@@ -39,7 +39,7 @@ namespace Discord.WebSocket
{
foreach (var channel in resolved.Channels.Value)
{
SocketChannel socketChannel = guild != null
var socketChannel = guild != null
? guild.GetChannel(channel.Value.Id)
: discord.GetChannel(channel.Value.Id);
@@ -69,7 +69,7 @@ namespace Discord.WebSocket
}
}
if (resolved.Roles.IsSpecified)
if (resolved.Roles.IsSpecified && guild != null)
{
foreach (var role in resolved.Roles.Value)
{