diff --git a/Myriad/Cache/MemoryDiscordCache.cs b/Myriad/Cache/MemoryDiscordCache.cs index 9dc4ca1c..3174870b 100644 --- a/Myriad/Cache/MemoryDiscordCache.cs +++ b/Myriad/Cache/MemoryDiscordCache.cs @@ -151,10 +151,11 @@ namespace Myriad.Cache public bool TryGetRole(ulong roleId, out Role role) => _roles.TryGetValue(roleId, out role!); - public async IAsyncEnumerable GetAllGuilds() + public IAsyncEnumerable GetAllGuilds() { - foreach (var guild in _guilds.Values) - yield return guild.Guild; + return _guilds.Values + .Select(g => g.Guild) + .ToAsyncEnumerable(); } public IEnumerable GetGuildChannels(ulong guildId) diff --git a/Myriad/Myriad.csproj b/Myriad/Myriad.csproj index f8c73f84..aa02602f 100644 --- a/Myriad/Myriad.csproj +++ b/Myriad/Myriad.csproj @@ -19,6 +19,7 @@ + diff --git a/PluralKit.Bot/CommandSystem/ContextEntityArgumentsExt.cs b/PluralKit.Bot/CommandSystem/ContextEntityArgumentsExt.cs index a5995f89..9a88b4d5 100644 --- a/PluralKit.Bot/CommandSystem/ContextEntityArgumentsExt.cs +++ b/PluralKit.Bot/CommandSystem/ContextEntityArgumentsExt.cs @@ -155,19 +155,19 @@ namespace PluralKit.Bot return $"Group not found. Note that a group ID is 5 characters long."; } - public static async Task MatchChannel(this Context ctx) + public static Task MatchChannel(this Context ctx) { if (!MentionUtils.TryParseChannel(ctx.PeekArgument(), out var id)) - return null; + return Task.FromResult(null); if (!ctx.Cache.TryGetChannel(id, out var channel)) - return null; + return Task.FromResult(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(null); ctx.PopArgument(); - return channel; + return Task.FromResult(channel); } public static Guild MatchGuild(this Context ctx) diff --git a/PluralKit.Core/Database/Wrappers/IPKCommand.cs b/PluralKit.Core/Database/Wrappers/IPKCommand.cs index 3f814d6c..affdf72d 100644 --- a/PluralKit.Core/Database/Wrappers/IPKCommand.cs +++ b/PluralKit.Core/Database/Wrappers/IPKCommand.cs @@ -10,7 +10,7 @@ namespace PluralKit.Core { public Task PrepareAsync(CancellationToken ct = default); public Task ExecuteNonQueryAsync(CancellationToken ct = default); - public Task ExecuteScalarAsync(CancellationToken ct = default); + public Task ExecuteScalarAsync(CancellationToken ct = default); public Task ExecuteReaderAsync(CancellationToken ct = default); public Task ExecuteReaderAsync(CommandBehavior behavior, CancellationToken ct = default); } diff --git a/PluralKit.Core/Database/Wrappers/PKCommand.cs b/PluralKit.Core/Database/Wrappers/PKCommand.cs index 02d75079..c6a5282a 100644 --- a/PluralKit.Core/Database/Wrappers/PKCommand.cs +++ b/PluralKit.Core/Database/Wrappers/PKCommand.cs @@ -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 ExecuteNonQueryAsync(CancellationToken ct) => LogQuery(Inner.ExecuteNonQueryAsync(ct)); - public override Task ExecuteScalarAsync(CancellationToken ct) => LogQuery(Inner.ExecuteScalarAsync(ct)); + public override Task ExecuteScalarAsync(CancellationToken ct) => LogQuery(Inner.ExecuteScalarAsync(ct)); protected override async Task 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; diff --git a/PluralKit.Core/Database/Wrappers/PKConnection.cs b/PluralKit.Core/Database/Wrappers/PKConnection.cs index acf171be..fe04948c 100644 --- a/PluralKit.Core/Database/Wrappers/PKConnection.cs +++ b/PluralKit.Core/Database/Wrappers/PKConnection.cs @@ -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;