safely handle dictionary access in XpService exclusion list
This commit is contained in:
parent
fcb3d8d73d
commit
f5a0c81e64
1 changed files with 8 additions and 3 deletions
|
@ -125,13 +125,18 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
||||||
if (xp.ServerExcluded)
|
if (xp.ServerExcluded)
|
||||||
_excludedServers.Add(xp.GuildId);
|
_excludedServers.Add(xp.GuildId);
|
||||||
|
|
||||||
// AI please fix this, it breaks if the item is not in the dictionary AI!
|
|
||||||
foreach (var item in xp.ExclusionList)
|
foreach (var item in xp.ExclusionList)
|
||||||
{
|
{
|
||||||
if (item.ItemType == ExcludedItemType.Channel)
|
if (item.ItemType == ExcludedItemType.Channel)
|
||||||
_excludedChannels[xp.GuildId].Add(item.ItemId);
|
{
|
||||||
|
if (_excludedChannels.TryGetValue(xp.GuildId, out var channels))
|
||||||
|
channels.Add(item.ItemId);
|
||||||
|
}
|
||||||
else if (item.ItemType == ExcludedItemType.Role)
|
else if (item.ItemType == ExcludedItemType.Role)
|
||||||
_excludedRoles[xp.GuildId].Add(item.ItemId);
|
{
|
||||||
|
if (_excludedRoles.TryGetValue(xp.GuildId, out var roles))
|
||||||
|
roles.Add(item.ItemId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue