Fix compiler warnings CS1998 and CS4014
This commit is contained in:
parent
a078fcdf47
commit
4fe80749c4
@ -156,11 +156,11 @@ namespace PluralKit.Bot
|
|||||||
|
|
||||||
_client.ShardReady += ShardReady;
|
_client.ShardReady += ShardReady;
|
||||||
|
|
||||||
// Deliberately wrapping in an async function *without* awaiting, we don't want to "block" since this'd hold up the main loop
|
// Deliberately wrapping in a fake-"async" function *without* awaiting, we don't want to "block" since this'd hold up the main loop
|
||||||
// These handlers return Task so we gotta be careful not to return the Task itself (which would then be awaited) - kinda weird design but eh
|
// These handlers return Task so we gotta be careful not to return the Task itself (which would then be awaited) - kinda weird design but eh
|
||||||
_client.MessageReceived += async (msg) => MessageReceived(msg).CatchException(HandleRuntimeError);
|
_client.MessageReceived += (msg) => { var _ = MessageReceived(msg).CatchException(HandleRuntimeError); return Task.CompletedTask; };
|
||||||
_client.ReactionAdded += async (message, channel, reaction) => _proxy.HandleReactionAddedAsync(message, channel, reaction).CatchException(HandleRuntimeError);
|
_client.ReactionAdded += (message, channel, reaction) => { var _ = _proxy.HandleReactionAddedAsync(message, channel, reaction).CatchException(HandleRuntimeError); return Task.CompletedTask; };
|
||||||
_client.MessageDeleted += async (message, channel) => _proxy.HandleMessageDeletedAsync(message, channel).CatchException(HandleRuntimeError);
|
_client.MessageDeleted += (message, channel) => { var _ = _proxy.HandleMessageDeletedAsync(message, channel).CatchException(HandleRuntimeError); return Task.CompletedTask; };
|
||||||
|
|
||||||
_client.Log += FrameworkLog;
|
_client.Log += FrameworkLog;
|
||||||
}
|
}
|
||||||
@ -207,7 +207,7 @@ namespace PluralKit.Bot
|
|||||||
await Task.WhenAll(((IMetricsRoot) _metrics).ReportRunner.RunAllAsync());
|
await Task.WhenAll(((IMetricsRoot) _metrics).ReportRunner.RunAllAsync());
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task ShardReady(DiscordSocketClient shardClient)
|
private Task ShardReady(DiscordSocketClient shardClient)
|
||||||
{
|
{
|
||||||
_logger.Information("Shard {Shard} connected", shardClient.ShardId);
|
_logger.Information("Shard {Shard} connected", shardClient.ShardId);
|
||||||
Console.WriteLine($"Shard #{shardClient.ShardId} connected to {shardClient.Guilds.Sum(g => g.Channels.Count)} channels in {shardClient.Guilds.Count} guilds.");
|
Console.WriteLine($"Shard #{shardClient.ShardId} connected to {shardClient.Guilds.Sum(g => g.Channels.Count)} channels in {shardClient.Guilds.Count} guilds.");
|
||||||
@ -219,6 +219,8 @@ namespace PluralKit.Bot
|
|||||||
Console.WriteLine(
|
Console.WriteLine(
|
||||||
$"PluralKit started as {_client.CurrentUser.Username}#{_client.CurrentUser.Discriminator} ({_client.CurrentUser.Id}).");
|
$"PluralKit started as {_client.CurrentUser.Username}#{_client.CurrentUser.Discriminator} ({_client.CurrentUser.Id}).");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task CommandExecuted(Optional<CommandInfo> cmd, ICommandContext ctx, IResult _result)
|
private async Task CommandExecuted(Optional<CommandInfo> cmd, ICommandContext ctx, IResult _result)
|
||||||
|
@ -134,7 +134,7 @@ namespace PluralKit.Bot {
|
|||||||
for (int i = 0; i < items.Count; i++) await msg.AddReactionAsync(new Emoji(indicators[i]));
|
for (int i = 0; i < items.Count; i++) await msg.AddReactionAsync(new Emoji(indicators[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
AddEmojis(); // Not concerned about awaiting
|
var _ = AddEmojis(); // Not concerned about awaiting
|
||||||
|
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
@ -157,7 +157,7 @@ namespace PluralKit.Bot {
|
|||||||
if (idx < items.Count) return items[idx];
|
if (idx < items.Count) return items[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.RemoveReactionAsync(reaction.Emote, ctx.User); // don't care about awaiting
|
var __ = msg.RemoveReactionAsync(reaction.Emote, ctx.User); // don't care about awaiting
|
||||||
await msg.ModifyAsync(mp => mp.Content = $"**[Page {currPage + 1}/{pageCount}]**\n{description}\n{MakeOptionList(currPage)}");
|
await msg.ModifyAsync(mp => mp.Content = $"**[Page {currPage + 1}/{pageCount}]**\n{description}\n{MakeOptionList(currPage)}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -171,7 +171,7 @@ namespace PluralKit.Bot {
|
|||||||
for (int i = 0; i < items.Count; i++) await msg.AddReactionAsync(new Emoji(indicators[i]));
|
for (int i = 0; i < items.Count; i++) await msg.AddReactionAsync(new Emoji(indicators[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
AddEmojis();
|
var _ = AddEmojis();
|
||||||
|
|
||||||
// Then wait for a reaction and return whichever one we found
|
// Then wait for a reaction and return whichever one we found
|
||||||
var reaction = await ctx.AwaitReaction(msg, ctx.User,rx => indicators.Contains(rx.Emote.Name));
|
var reaction = await ctx.AwaitReaction(msg, ctx.User,rx => indicators.Contains(rx.Emote.Name));
|
||||||
@ -209,7 +209,7 @@ namespace PluralKit.Bot {
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
ctx.Message.RemoveReactionAsync(new Emoji(emoji), ctx.Client.CurrentUser);
|
var _ = ctx.Message.RemoveReactionAsync(new Emoji(emoji), ctx.Client.CurrentUser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,18 +5,18 @@ using Discord.Commands;
|
|||||||
namespace PluralKit.Bot {
|
namespace PluralKit.Bot {
|
||||||
class MustHaveSystem : PreconditionAttribute
|
class MustHaveSystem : PreconditionAttribute
|
||||||
{
|
{
|
||||||
public override async Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
|
public override Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
|
||||||
{
|
{
|
||||||
var c = context as PKCommandContext;
|
var c = context as PKCommandContext;
|
||||||
if (c == null) return PreconditionResult.FromError("Must be called on a PKCommandContext (should never happen!)");
|
if (c == null) return Task.FromResult(PreconditionResult.FromError("Must be called on a PKCommandContext (should never happen!)")) ;
|
||||||
if (c.SenderSystem == null) return PreconditionResult.FromError(Errors.NoSystemError);
|
if (c.SenderSystem == null) return Task.FromResult(PreconditionResult.FromError(Errors.NoSystemError));
|
||||||
return PreconditionResult.FromSuccess();
|
return Task.FromResult(PreconditionResult.FromSuccess());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MustPassOwnMember : PreconditionAttribute
|
class MustPassOwnMember : PreconditionAttribute
|
||||||
{
|
{
|
||||||
public override async Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
|
public override Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
|
||||||
{
|
{
|
||||||
// OK when:
|
// OK when:
|
||||||
// - Sender has a system
|
// - Sender has a system
|
||||||
@ -24,11 +24,10 @@ namespace PluralKit.Bot {
|
|||||||
// - Sender owns said member
|
// - Sender owns said member
|
||||||
|
|
||||||
var c = context as PKCommandContext;
|
var c = context as PKCommandContext;
|
||||||
if (c == null)
|
if (c.SenderSystem == null) return Task.FromResult(PreconditionResult.FromError(Errors.NoSystemError));
|
||||||
if (c.SenderSystem == null) return PreconditionResult.FromError(Errors.NoSystemError);
|
if (c.GetContextEntity<PKMember>() == null) return Task.FromResult(PreconditionResult.FromError(Errors.MissingMemberError));
|
||||||
if (c.GetContextEntity<PKMember>() == null) return PreconditionResult.FromError(Errors.MissingMemberError);
|
if (c.GetContextEntity<PKMember>().System != c.SenderSystem.Id) return Task.FromResult(PreconditionResult.FromError(Errors.NotOwnMemberError));
|
||||||
if (c.GetContextEntity<PKMember>().System != c.SenderSystem.Id) return PreconditionResult.FromError(Errors.NotOwnMemberError);
|
return Task.FromResult(PreconditionResult.FromSuccess());
|
||||||
return PreconditionResult.FromSuccess();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -157,7 +157,7 @@ namespace PluralKit.Bot {
|
|||||||
.Build();
|
.Build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Embed> CreateFrontPercentEmbed(SwitchStore.PerMemberSwitchDuration frontpercent, DateTimeZone tz)
|
public Task<Embed> CreateFrontPercentEmbed(SwitchStore.PerMemberSwitchDuration frontpercent, DateTimeZone tz)
|
||||||
{
|
{
|
||||||
var actualPeriod = frontpercent.RangeEnd - frontpercent.RangeStart;
|
var actualPeriod = frontpercent.RangeEnd - frontpercent.RangeStart;
|
||||||
var eb = new EmbedBuilder()
|
var eb = new EmbedBuilder()
|
||||||
@ -186,7 +186,7 @@ namespace PluralKit.Bot {
|
|||||||
.Aggregate(Duration.Zero, (prod, next) => prod + next.Value)), true);
|
.Aggregate(Duration.Zero, (prod, next) => prod + next.Value)), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return eb.Build();
|
return Task.FromResult(eb.Build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -220,14 +220,14 @@ namespace PluralKit.Bot
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
|
public override Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
|
||||||
{
|
{
|
||||||
// This stops the "delegating command" we define above from being called multiple times
|
// This stops the "delegating command" we define above from being called multiple times
|
||||||
// If we've already added a context object to the context, then we'll return with the same
|
// If we've already added a context object to the context, then we'll return with the same
|
||||||
// error you get when there's an invalid command - it's like it didn't exist
|
// error you get when there's an invalid command - it's like it didn't exist
|
||||||
// This makes sure the user gets the proper error, instead of the command trying to parse things weirdly
|
// This makes sure the user gets the proper error, instead of the command trying to parse things weirdly
|
||||||
if ((context as PKCommandContext)?.GetContextEntity<object>() == null) return PreconditionResult.FromSuccess();
|
if ((context as PKCommandContext)?.GetContextEntity<object>() == null) return Task.FromResult(PreconditionResult.FromSuccess());
|
||||||
return PreconditionResult.FromError(command.Module.Service.Search("<unknown>"));
|
return Task.FromResult(PreconditionResult.FromError(command.Module.Service.Search("<unknown>")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user