chore: format with csharpier
This commit is contained in:
parent
2f516dcb73
commit
4f54077c68
59 changed files with 2000 additions and 942 deletions
|
|
@ -17,18 +17,21 @@ public class ChannelCache
|
|||
_channels[channel.ID] = channel;
|
||||
if (guildId == null)
|
||||
{
|
||||
if (!channel.GuildID.TryGet(out var snowflake)) return;
|
||||
if (!channel.GuildID.TryGet(out var snowflake))
|
||||
return;
|
||||
guildId = snowflake;
|
||||
}
|
||||
|
||||
// Add to set of guild channels
|
||||
_guildChannels.AddOrUpdate(guildId.Value,
|
||||
_guildChannels.AddOrUpdate(
|
||||
guildId.Value,
|
||||
_ => [channel.ID],
|
||||
(_, l) =>
|
||||
{
|
||||
l.Add(channel.ID);
|
||||
return l;
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public bool TryGet(Snowflake id, [NotNullWhen(true)] out IChannel? channel) =>
|
||||
|
|
@ -37,13 +40,18 @@ public class ChannelCache
|
|||
public void Remove(Snowflake? guildId, Snowflake id, out IChannel? channel)
|
||||
{
|
||||
_channels.Remove(id, out channel);
|
||||
if (guildId == null) return;
|
||||
if (guildId == null)
|
||||
return;
|
||||
// Remove from set of guild channels
|
||||
_guildChannels.AddOrUpdate(guildId.Value, _ => [], (_, s) =>
|
||||
{
|
||||
s.Remove(id);
|
||||
return s;
|
||||
});
|
||||
_guildChannels.AddOrUpdate(
|
||||
guildId.Value,
|
||||
_ => [],
|
||||
(_, s) =>
|
||||
{
|
||||
s.Remove(id);
|
||||
return s;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -54,6 +62,8 @@ public class ChannelCache
|
|||
public IEnumerable<IChannel> GuildChannels(Snowflake guildId) =>
|
||||
!_guildChannels.TryGetValue(guildId, out var channelIds)
|
||||
? []
|
||||
: channelIds.Select(id => _channels.GetValueOrDefault(id))
|
||||
.Where(c => c != null).Select(c => c!);
|
||||
}
|
||||
: channelIds
|
||||
.Select(id => _channels.GetValueOrDefault(id))
|
||||
.Where(c => c != null)
|
||||
.Select(c => c!);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue