chore: lint

This commit is contained in:
spiral 2022-04-20 10:47:15 -04:00
parent aa896de3af
commit 1e86c2d6c4
No known key found for this signature in database
GPG Key ID: 244A11E4B0BCF40E
2 changed files with 24 additions and 22 deletions

View File

@ -10,7 +10,7 @@ using Myriad.Types;
namespace Myriad.Cache; namespace Myriad.Cache;
#pragma warning disable 4014 #pragma warning disable 4014
public class RedisDiscordCache : IDiscordCache public class RedisDiscordCache: IDiscordCache
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
public RedisDiscordCache(ILogger logger) public RedisDiscordCache(ILogger logger)
@ -37,7 +37,7 @@ public class RedisDiscordCache : IDiscordCache
g.Id = guild.Id; g.Id = guild.Id;
g.Name = guild.Name; g.Name = guild.Name;
g.OwnerId = guild.OwnerId; g.OwnerId = guild.OwnerId;
g.PremiumTier = (int) guild.PremiumTier; g.PremiumTier = (int)guild.PremiumTier;
var tr = db.CreateTransaction(); var tr = db.CreateTransaction();
@ -53,7 +53,7 @@ public class RedisDiscordCache : IDiscordCache
Id = role.Id, Id = role.Id,
Name = role.Name, Name = role.Name,
Position = role.Position, Position = role.Position,
Permissions = (ulong) role.Permissions, Permissions = (ulong)role.Permissions,
Mentionable = role.Mentionable, Mentionable = role.Mentionable,
})); }));
@ -122,7 +122,7 @@ public class RedisDiscordCache : IDiscordCache
Id = role.Id, Id = role.Id,
Mentionable = role.Mentionable, Mentionable = role.Mentionable,
Name = role.Name, Name = role.Name,
Permissions = (ulong) role.Permissions, Permissions = (ulong)role.Permissions,
Position = role.Position, Position = role.Position,
})); }));
@ -138,7 +138,7 @@ public class RedisDiscordCache : IDiscordCache
await db.HashSetAsync("channels", channelId.HashWrapper(new CachedChannel() await db.HashSetAsync("channels", channelId.HashWrapper(new CachedChannel()
{ {
Id = channelId, Id = channelId,
Type = (int) Channel.ChannelType.Dm, Type = (int)Channel.ChannelType.Dm,
})); }));
} }
@ -184,7 +184,7 @@ public class RedisDiscordCache : IDiscordCache
var roles = await Task.WhenAll(redisRoles.Select(r => TryGetRole((ulong)r.Name))); var roles = await Task.WhenAll(redisRoles.Select(r => TryGetRole((ulong)r.Name)));
#pragma warning disable 8619 #pragma warning disable 8619
return guild.FromProtobuf() with { Roles = roles } ; return guild.FromProtobuf() with { Roles = roles };
#pragma warning restore 8619 #pragma warning restore 8619
} }
@ -231,7 +231,7 @@ public class RedisDiscordCache : IDiscordCache
Id = role.Id, Id = role.Id,
Name = role.Name, Name = role.Name,
Position = role.Position, Position = role.Position,
Permissions = (PermissionSet) role.Permissions, Permissions = (PermissionSet)role.Permissions,
Mentionable = role.Mentionable, Mentionable = role.Mentionable,
}; };
} }
@ -241,7 +241,7 @@ public class RedisDiscordCache : IDiscordCache
// return _guilds.Values // return _guilds.Values
// .Select(g => g.Guild) // .Select(g => g.Guild)
// .ToAsyncEnumerable(); // .ToAsyncEnumerable();
return new Guild[] {}.ToAsyncEnumerable(); return new Guild[] { }.ToAsyncEnumerable();
} }
public async Task<IEnumerable<Channel>> GetGuildChannels(ulong guildId) public async Task<IEnumerable<Channel>> GetGuildChannels(ulong guildId)
@ -251,7 +251,7 @@ public class RedisDiscordCache : IDiscordCache
throw new ArgumentException("Guild not found", nameof(guildId)); throw new ArgumentException("Guild not found", nameof(guildId));
#pragma warning disable 8619 #pragma warning disable 8619
return await Task.WhenAll(redisChannels.Select(c => TryGetChannel((ulong) c.Name))); return await Task.WhenAll(redisChannels.Select(c => TryGetChannel((ulong)c.Name)));
#pragma warning restore 8619 #pragma warning restore 8619
} }
} }
@ -264,24 +264,25 @@ internal static class CacheProtoExt
Id = guild.Id, Id = guild.Id,
Name = guild.Name, Name = guild.Name,
OwnerId = guild.OwnerId, OwnerId = guild.OwnerId,
PremiumTier = (PremiumTier) guild.PremiumTier, PremiumTier = (PremiumTier)guild.PremiumTier,
}; };
public static CachedChannel ToProtobuf(this Channel channel) public static CachedChannel ToProtobuf(this Channel channel)
{ {
var c = new CachedChannel(); var c = new CachedChannel();
c.Id = channel.Id; c.Id = channel.Id;
c.Type = (int) channel.Type; c.Type = (int)channel.Type;
if (channel.Position != null) if (channel.Position != null)
c.Position = channel.Position.Value; c.Position = channel.Position.Value;
c.Name = channel.Name; c.Name = channel.Name;
if (channel.PermissionOverwrites != null) if (channel.PermissionOverwrites != null)
foreach (var overwrite in channel.PermissionOverwrites) foreach (var overwrite in channel.PermissionOverwrites)
c.PermissionOverwrites.Add(new Overwrite() { c.PermissionOverwrites.Add(new Overwrite()
{
Id = overwrite.Id, Id = overwrite.Id,
Type = (int) overwrite.Type, Type = (int)overwrite.Type,
Allow = (ulong) overwrite.Allow, Allow = (ulong)overwrite.Allow,
Deny = (ulong) overwrite.Deny, Deny = (ulong)overwrite.Deny,
}); });
if (channel.GuildId != null) if (channel.GuildId != null)
c.GuildId = channel.GuildId.Value; c.GuildId = channel.GuildId.Value;
@ -293,16 +294,16 @@ internal static class CacheProtoExt
=> new Channel() => new Channel()
{ {
Id = channel.Id, Id = channel.Id,
Type = (Channel.ChannelType) channel.Type, Type = (Channel.ChannelType)channel.Type,
Position = channel.Position, Position = channel.Position,
Name = channel.Name, Name = channel.Name,
PermissionOverwrites = channel.PermissionOverwrites PermissionOverwrites = channel.PermissionOverwrites
.Select(x => new Channel.Overwrite() .Select(x => new Channel.Overwrite()
{ {
Id = x.Id, Id = x.Id,
Type = (Channel.OverwriteType) x.Type, Type = (Channel.OverwriteType)x.Type,
Allow = (PermissionSet) x.Allow, Allow = (PermissionSet)x.Allow,
Deny = (PermissionSet) x.Deny, Deny = (PermissionSet)x.Deny,
}).ToArray(), }).ToArray(),
GuildId = channel.HasGuildId ? channel.GuildId : null, GuildId = channel.HasGuildId ? channel.GuildId : null,
ParentId = channel.HasParentId ? channel.ParentId : null, ParentId = channel.HasParentId ? channel.ParentId : null,

View File

@ -44,7 +44,8 @@ public class BotModule: Module
}).AsSelf().SingleInstance(); }).AsSelf().SingleInstance();
builder.RegisterType<Cluster>().AsSelf().SingleInstance(); builder.RegisterType<Cluster>().AsSelf().SingleInstance();
builder.RegisterType<RedisGatewayService>().AsSelf().SingleInstance(); builder.RegisterType<RedisGatewayService>().AsSelf().SingleInstance();
builder.Register<IDiscordCache>(c => { builder.Register<IDiscordCache>(c =>
{
var botConfig = c.Resolve<BotConfig>(); var botConfig = c.Resolve<BotConfig>();
if (botConfig.UseRedisCache) if (botConfig.UseRedisCache)