mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-05-01 11:39:55 +03:00
Always default cancellation tokens (#319)
This PR makes sure that a cancellation token is never *required* to use an `async` method. This does not affect user experience in any way, only code quality. --------- Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
a953053f1d
commit
a0e7b3a611
10 changed files with 26 additions and 26 deletions
|
@ -288,7 +288,7 @@ public sealed class InfoCommandGroup : CommandGroup
|
|||
return await ShowGuildInfoAsync(bot, guild, CancellationToken);
|
||||
}
|
||||
|
||||
private Task<Result> ShowGuildInfoAsync(IUser bot, IGuild guild, CancellationToken ct)
|
||||
private Task<Result> ShowGuildInfoAsync(IUser bot, IGuild guild, CancellationToken ct = default)
|
||||
{
|
||||
var description = new StringBuilder().AppendLine($"## {guild.Name}");
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ public sealed class MuteCommandGroup : CommandGroup
|
|||
|
||||
private async Task<Result> SelectMuteMethodAsync(
|
||||
IUser executor, IUser target, string reason, TimeSpan duration, Snowflake guildId, GuildData data,
|
||||
IUser bot, DateTimeOffset until, CancellationToken ct)
|
||||
IUser bot, DateTimeOffset until, CancellationToken ct = default)
|
||||
{
|
||||
var muteRole = GuildSettings.MuteRole.Get(data.Settings);
|
||||
|
||||
|
@ -186,7 +186,7 @@ public sealed class MuteCommandGroup : CommandGroup
|
|||
|
||||
private async Task<Result> RoleMuteUserAsync(
|
||||
IUser executor, IUser target, string reason, Snowflake guildId, GuildData data,
|
||||
DateTimeOffset until, Snowflake muteRole, CancellationToken ct)
|
||||
DateTimeOffset until, Snowflake muteRole, CancellationToken ct = default)
|
||||
{
|
||||
var assignRoles = new List<Snowflake> { muteRole };
|
||||
var memberData = data.GetOrCreateMemberData(target.ID);
|
||||
|
@ -208,7 +208,7 @@ public sealed class MuteCommandGroup : CommandGroup
|
|||
|
||||
private async Task<Result> TimeoutUserAsync(
|
||||
IUser executor, IUser target, string reason, TimeSpan duration, Snowflake guildId,
|
||||
IUser bot, DateTimeOffset until, CancellationToken ct)
|
||||
IUser bot, DateTimeOffset until, CancellationToken ct = default)
|
||||
{
|
||||
if (duration.TotalDays >= 28)
|
||||
{
|
||||
|
|
|
@ -78,7 +78,7 @@ public sealed class RemindCommandGroup : CommandGroup
|
|||
return await ListRemindersAsync(data.GetOrCreateMemberData(executorId), guildId, executor, bot, CancellationToken);
|
||||
}
|
||||
|
||||
private Task<Result> ListRemindersAsync(MemberData data, Snowflake guildId, IUser executor, IUser bot, CancellationToken ct)
|
||||
private Task<Result> ListRemindersAsync(MemberData data, Snowflake guildId, IUser executor, IUser bot, CancellationToken ct = default)
|
||||
{
|
||||
if (data.Reminders.Count == 0)
|
||||
{
|
||||
|
@ -353,7 +353,7 @@ public sealed class RemindCommandGroup : CommandGroup
|
|||
}
|
||||
|
||||
private Task<Result> DeleteReminderAsync(MemberData data, int index, IUser bot,
|
||||
CancellationToken ct)
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
if (index >= data.Reminders.Count)
|
||||
{
|
||||
|
|
|
@ -90,7 +90,7 @@ public sealed class ToolsCommandGroup : CommandGroup
|
|||
}
|
||||
|
||||
private Task<Result> SendRandomNumberAsync(long first, long? secondNullable,
|
||||
IUser executor, CancellationToken ct)
|
||||
IUser executor, CancellationToken ct = default)
|
||||
{
|
||||
const long secondDefault = 0;
|
||||
var second = secondNullable ?? secondDefault;
|
||||
|
@ -187,7 +187,7 @@ public sealed class ToolsCommandGroup : CommandGroup
|
|||
return await SendTimestampAsync(offset, executor, CancellationToken);
|
||||
}
|
||||
|
||||
private Task<Result> SendTimestampAsync(TimeSpan? offset, IUser executor, CancellationToken ct)
|
||||
private Task<Result> SendTimestampAsync(TimeSpan? offset, IUser executor, CancellationToken ct = default)
|
||||
{
|
||||
var timestamp = DateTimeOffset.UtcNow.Add(offset ?? TimeSpan.Zero).ToUnixTimeSeconds();
|
||||
|
||||
|
@ -249,7 +249,7 @@ public sealed class ToolsCommandGroup : CommandGroup
|
|||
return await AnswerEightBallAsync(bot, CancellationToken);
|
||||
}
|
||||
|
||||
private Task<Result> AnswerEightBallAsync(IUser bot, CancellationToken ct)
|
||||
private Task<Result> AnswerEightBallAsync(IUser bot, CancellationToken ct = default)
|
||||
{
|
||||
var typeNumber = Random.Shared.Next(0, 4);
|
||||
var embedColor = typeNumber switch
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue