Add Async suffix to command-related Tasks (#804)
commit b7fb44a94fb1e75f696f281d6b201eba3f48e864 Author: Hsu Still <341464@gmail.com> Date: Sat Sep 2 14:34:18 2017 +0800 Fix more async naming violation commit e6912e2d020c69325826dbfa62c07cd1ef2cc45f Author: Hsu Still <341464@gmail.com> Date: Sat Sep 2 14:23:04 2017 +0800 Fix incorrect null xmldocs string commit da8d23222d207853375c3512232d1d7fd3629cad Author: Hsu Still <341464@gmail.com> Date: Sat Sep 2 14:17:12 2017 +0800 Fix CheckPreconditionsAsync commit 992407407a42fec9087c9ed18e0bf5de30dff82c Author: Hsu Still <341464@gmail.com> Date: Sat Sep 2 14:07:12 2017 +0800 Add Async suffix to abstract Task methods
This commit is contained in:
@@ -78,7 +78,7 @@ namespace Discord.Commands
|
||||
{
|
||||
foreach (PreconditionAttribute precondition in preconditionGroup)
|
||||
{
|
||||
var result = await precondition.CheckPermissions(context, this, services).ConfigureAwait(false);
|
||||
var result = await precondition.CheckPermissionsAsync(context, this, services).ConfigureAwait(false);
|
||||
if (!result.IsSuccess)
|
||||
return result;
|
||||
}
|
||||
@@ -87,7 +87,7 @@ namespace Discord.Commands
|
||||
{
|
||||
var results = new List<PreconditionResult>();
|
||||
foreach (PreconditionAttribute precondition in preconditionGroup)
|
||||
results.Add(await precondition.CheckPermissions(context, this, services).ConfigureAwait(false));
|
||||
results.Add(await precondition.CheckPermissionsAsync(context, this, services).ConfigureAwait(false));
|
||||
|
||||
if (!results.Any(p => p.IsSuccess))
|
||||
return PreconditionGroupResult.FromError($"{type} precondition group {preconditionGroup.Key} failed.", results);
|
||||
@@ -117,7 +117,7 @@ namespace Discord.Commands
|
||||
return ParseResult.FromError(preconditionResult);
|
||||
|
||||
string input = searchResult.Text.Substring(startIndex);
|
||||
return await CommandParser.ParseArgs(this, context, services, input, 0).ConfigureAwait(false);
|
||||
return await CommandParser.ParseArgsAsync(this, context, services, input, 0).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public Task<IResult> ExecuteAsync(ICommandContext context, ParseResult parseResult, IServiceProvider services)
|
||||
@@ -163,11 +163,11 @@ namespace Discord.Commands
|
||||
switch (RunMode)
|
||||
{
|
||||
case RunMode.Sync: //Always sync
|
||||
return await ExecuteAsyncInternal(context, args, services).ConfigureAwait(false);
|
||||
return await ExecuteAsyncInternalAsync(context, args, services).ConfigureAwait(false);
|
||||
case RunMode.Async: //Always async
|
||||
var t2 = Task.Run(async () =>
|
||||
{
|
||||
await ExecuteAsyncInternal(context, args, services).ConfigureAwait(false);
|
||||
await ExecuteAsyncInternalAsync(context, args, services).ConfigureAwait(false);
|
||||
});
|
||||
break;
|
||||
}
|
||||
@@ -179,7 +179,7 @@ namespace Discord.Commands
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<IResult> ExecuteAsyncInternal(ICommandContext context, object[] args, IServiceProvider services)
|
||||
private async Task<IResult> ExecuteAsyncInternalAsync(ICommandContext context, object[] args, IServiceProvider services)
|
||||
{
|
||||
await Module.Service._cmdLogger.DebugAsync($"Executing {GetLogText(context)}").ConfigureAwait(false);
|
||||
try
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Discord.Commands
|
||||
|
||||
foreach (var precondition in Preconditions)
|
||||
{
|
||||
var result = await precondition.CheckPermissions(context, this, arg, services).ConfigureAwait(false);
|
||||
var result = await precondition.CheckPermissionsAsync(context, this, arg, services).ConfigureAwait(false);
|
||||
if (!result.IsSuccess)
|
||||
return result;
|
||||
}
|
||||
@@ -56,10 +56,10 @@ namespace Discord.Commands
|
||||
return PreconditionResult.FromSuccess();
|
||||
}
|
||||
|
||||
public async Task<TypeReaderResult> Parse(ICommandContext context, string input, IServiceProvider services = null)
|
||||
public async Task<TypeReaderResult> ParseAsync(ICommandContext context, string input, IServiceProvider services = null)
|
||||
{
|
||||
services = services ?? EmptyServiceProvider.Instance;
|
||||
return await _reader.Read(context, input, services).ConfigureAwait(false);
|
||||
return await _reader.ReadAsync(context, input, services).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public override string ToString() => Name;
|
||||
|
||||
Reference in New Issue
Block a user