Fix a few more compiler warnings

Signed-off-by: Ske <voltasalt@gmail.com>
This commit is contained in:
Ske 2021-05-07 10:56:15 +02:00
parent dd2c669cd2
commit dbde8c07ad
6 changed files with 18 additions and 12 deletions

View File

@ -151,10 +151,11 @@ namespace Myriad.Cache
public bool TryGetRole(ulong roleId, out Role role) =>
_roles.TryGetValue(roleId, out role!);
public async IAsyncEnumerable<Guild> GetAllGuilds()
public IAsyncEnumerable<Guild> GetAllGuilds()
{
foreach (var guild in _guilds.Values)
yield return guild.Guild;
return _guilds.Values
.Select(g => g.Guild)
.ToAsyncEnumerable();
}
public IEnumerable<Channel> GetGuildChannels(ulong guildId)

View File

@ -19,6 +19,7 @@
<PackageReference Include="Polly" Version="7.2.1" />
<PackageReference Include="Polly.Contrib.WaitAndRetry" Version="1.1.1" />
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="System.Linq.Async" Version="5.0.0" />
</ItemGroup>
</Project>

View File

@ -155,19 +155,19 @@ namespace PluralKit.Bot
return $"Group not found. Note that a group ID is 5 characters long.";
}
public static async Task<Channel> MatchChannel(this Context ctx)
public static Task<Channel> MatchChannel(this Context ctx)
{
if (!MentionUtils.TryParseChannel(ctx.PeekArgument(), out var id))
return null;
return Task.FromResult<Channel>(null);
if (!ctx.Cache.TryGetChannel(id, out var channel))
return null;
return Task.FromResult<Channel>(null);
if (!(channel.Type == Channel.ChannelType.GuildText || channel.Type == Channel.ChannelType.GuildText))
return null;
if (!(channel.Type == Channel.ChannelType.GuildText || channel.Type == Channel.ChannelType.GuildNews))
return Task.FromResult<Channel>(null);
ctx.PopArgument();
return channel;
return Task.FromResult(channel);
}
public static Guild MatchGuild(this Context ctx)

View File

@ -10,7 +10,7 @@ namespace PluralKit.Core
{
public Task PrepareAsync(CancellationToken ct = default);
public Task<int> ExecuteNonQueryAsync(CancellationToken ct = default);
public Task<object> ExecuteScalarAsync(CancellationToken ct = default);
public Task<object?> ExecuteScalarAsync(CancellationToken ct = default);
public Task<DbDataReader> ExecuteReaderAsync(CancellationToken ct = default);
public Task<DbDataReader> ExecuteReaderAsync(CommandBehavior behavior, CancellationToken ct = default);
}

View File

@ -2,6 +2,7 @@
using System;
using System.Data;
using System.Data.Common;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
@ -32,13 +33,14 @@ namespace PluralKit.Core
}
public override Task<int> ExecuteNonQueryAsync(CancellationToken ct) => LogQuery(Inner.ExecuteNonQueryAsync(ct));
public override Task<object> ExecuteScalarAsync(CancellationToken ct) => LogQuery(Inner.ExecuteScalarAsync(ct));
public override Task<object?> ExecuteScalarAsync(CancellationToken ct) => LogQuery(Inner.ExecuteScalarAsync(ct));
protected override async Task<DbDataReader> ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken ct) => await LogQuery(Inner.ExecuteReaderAsync(behavior, ct));
public override Task PrepareAsync(CancellationToken ct = default) => Inner.PrepareAsync(ct);
public override void Cancel() => Inner.Cancel();
protected override DbParameter CreateDbParameter() => Inner.CreateParameter();
[AllowNull]
public override string CommandText
{
get => Inner.CommandText;

View File

@ -2,6 +2,7 @@
using System;
using System.Data;
using System.Data.Common;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
@ -73,13 +74,14 @@ namespace PluralKit.Core
IDbTransaction IPKConnection.BeginTransaction() => throw SyncError(nameof(BeginTransaction));
IDbTransaction IPKConnection.BeginTransaction(IsolationLevel level) => throw SyncError(nameof(BeginTransaction));
[AllowNull]
public override string ConnectionString
{
get => Inner.ConnectionString;
set => Inner.ConnectionString = value;
}
public override string? Database => Inner.Database;
public override string Database => Inner.Database!;
public override ConnectionState State => Inner.State;
public override string DataSource => Inner.DataSource;
public override string ServerVersion => Inner.ServerVersion;