- Updated editorconfig rules to hopefully look a bit nicer.

- Removed configureawait(false) from everywhere as it doesnt' do anything in a console app and just makes the code look ugly
- Started using .WhenAll extension instead of Task.WhenAll to make it look nicer when chaining methods
This commit is contained in:
Kwoth
2021-12-28 21:14:26 +01:00
parent d093f7eed7
commit 723447c7d4
171 changed files with 1523 additions and 1594 deletions

View File

@@ -1,4 +1,4 @@
#nullable disable
#nullable disable
using Microsoft.EntityFrameworkCore;
using NadekoBot.Services.Database.Models;
using NadekoBot.Common.TypeReaders;
@@ -81,9 +81,9 @@ public partial class Permissions
var localSet = CommandCooldowns.GetOrAdd(channel.Guild.Id, new ConcurrentHashSet<CommandCooldown>());
if (!localSet.Any())
await ReplyConfirmLocalizedAsync(strs.cmdcd_none).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.cmdcd_none);
else
await channel.SendTableAsync("", localSet.Select(c => c.CommandName + ": " + c.Seconds + GetText(strs.sec)), s => $"{s,-30}", 2).ConfigureAwait(false);
await channel.SendTableAsync("", localSet.Select(c => c.CommandName + ": " + c.Seconds + GetText(strs.sec)), s => $"{s,-30}", 2);
}
}
}

View File

@@ -1,4 +1,4 @@
#nullable disable
#nullable disable
using Microsoft.EntityFrameworkCore;
using NadekoBot.Modules.Permissions.Services;
using NadekoBot.Services.Database.Models;
@@ -22,7 +22,7 @@ public partial class Permissions
public async Task FwClear()
{
_service.ClearFilteredWords(ctx.Guild.Id);
await ReplyConfirmLocalizedAsync(strs.fw_cleared).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.fw_cleared);
}
[NadekoCommand, Aliases]
@@ -42,12 +42,12 @@ public partial class Permissions
if (enabled)
{
_service.InviteFilteringServers.Add(channel.Guild.Id);
await ReplyConfirmLocalizedAsync(strs.invite_filter_server_on).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.invite_filter_server_on);
}
else
{
_service.InviteFilteringServers.TryRemove(channel.Guild.Id);
await ReplyConfirmLocalizedAsync(strs.invite_filter_server_off).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.invite_filter_server_off);
}
}
@@ -81,12 +81,12 @@ public partial class Permissions
if (removed is null)
{
_service.InviteFilteringChannels.Add(channel.Id);
await ReplyConfirmLocalizedAsync(strs.invite_filter_channel_on).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.invite_filter_channel_on);
}
else
{
_service.InviteFilteringChannels.TryRemove(channel.Id);
await ReplyConfirmLocalizedAsync(strs.invite_filter_channel_off).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.invite_filter_channel_off);
}
}
@@ -107,12 +107,12 @@ public partial class Permissions
if (enabled)
{
_service.LinkFilteringServers.Add(channel.Guild.Id);
await ReplyConfirmLocalizedAsync(strs.link_filter_server_on).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.link_filter_server_on);
}
else
{
_service.LinkFilteringServers.TryRemove(channel.Guild.Id);
await ReplyConfirmLocalizedAsync(strs.link_filter_server_off).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.link_filter_server_off);
}
}
@@ -146,12 +146,12 @@ public partial class Permissions
if (removed is null)
{
_service.LinkFilteringChannels.Add(channel.Id);
await ReplyConfirmLocalizedAsync(strs.link_filter_channel_on).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.link_filter_channel_on);
}
else
{
_service.LinkFilteringChannels.TryRemove(channel.Id);
await ReplyConfirmLocalizedAsync(strs.link_filter_channel_off).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.link_filter_channel_off);
}
}
@@ -172,12 +172,12 @@ public partial class Permissions
if (enabled)
{
_service.WordFilteringServers.Add(channel.Guild.Id);
await ReplyConfirmLocalizedAsync(strs.word_filter_server_on).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.word_filter_server_on);
}
else
{
_service.WordFilteringServers.TryRemove(channel.Guild.Id);
await ReplyConfirmLocalizedAsync(strs.word_filter_server_off).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.word_filter_server_off);
}
}
@@ -211,12 +211,12 @@ public partial class Permissions
if (removed is null)
{
_service.WordFilteringChannels.Add(channel.Id);
await ReplyConfirmLocalizedAsync(strs.word_filter_channel_on).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.word_filter_channel_on);
}
else
{
_service.WordFilteringChannels.TryRemove(channel.Id);
await ReplyConfirmLocalizedAsync(strs.word_filter_channel_off).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.word_filter_channel_off);
}
}
@@ -253,12 +253,12 @@ public partial class Permissions
if (removed is null)
{
filteredWords.Add(word);
await ReplyConfirmLocalizedAsync(strs.filter_word_add(Format.Code(word))).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.filter_word_add(Format.Code(word)));
}
else
{
filteredWords.TryRemove(word);
await ReplyConfirmLocalizedAsync(strs.filter_word_remove(Format.Code(word))).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.filter_word_remove(Format.Code(word)));
}
}
@@ -281,7 +281,7 @@ public partial class Permissions
.WithTitle(GetText(strs.filter_word_list))
.WithDescription(string.Join("\n", fws.Skip(curPage * 10).Take(10)))
.WithOkColor()
, fws.Length, 10).ConfigureAwait(false);
, fws.Length, 10);
}
}
}

View File

@@ -1,4 +1,4 @@
#nullable disable
#nullable disable
using NadekoBot.Common.TypeReaders;
using NadekoBot.Modules.Permissions.Services;
@@ -26,7 +26,7 @@ public partial class Permissions
var blockedCommands = _service.BlockedCommands;
if (!blockedModule.Any() && !blockedCommands.Any())
{
await ReplyErrorLocalizedAsync(strs.lgp_none).ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.lgp_none);
return;
}
@@ -42,7 +42,7 @@ public partial class Permissions
, string.Join("\n", _service.BlockedCommands)
, false);
await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);
await ctx.Channel.EmbedAsync(embed);
}
[NadekoCommand, Aliases]
@@ -55,11 +55,11 @@ public partial class Permissions
if (added)
{
await ReplyConfirmLocalizedAsync(strs.gmod_add(Format.Bold(module.Name))).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.gmod_add(Format.Bold(module.Name)));
return;
}
await ReplyConfirmLocalizedAsync(strs.gmod_remove(Format.Bold(module.Name))).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.gmod_remove(Format.Bold(module.Name)));
}
[NadekoCommand, Aliases]
@@ -71,11 +71,11 @@ public partial class Permissions
if (added)
{
await ReplyConfirmLocalizedAsync(strs.gcmd_add(Format.Bold(cmd.Name))).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.gcmd_add(Format.Bold(cmd.Name)));
return;
}
await ReplyConfirmLocalizedAsync(strs.gcmd_remove(Format.Bold(cmd.Name))).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.gcmd_remove(Format.Bold(cmd.Name)));
}
}
}

View File

@@ -1,4 +1,4 @@
#nullable disable
#nullable disable
using NadekoBot.Services.Database.Models;
using NadekoBot.Common.TypeReaders;
using NadekoBot.Common.TypeReaders.Models;
@@ -29,11 +29,11 @@ public partial class Permissions : NadekoModule<PermissionService>
}
if (action.Value)
{
await ReplyConfirmLocalizedAsync(strs.verbose_true).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.verbose_true);
}
else
{
await ReplyConfirmLocalizedAsync(strs.verbose_false).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.verbose_false);
}
}
@@ -52,11 +52,11 @@ public partial class Permissions : NadekoModule<PermissionService>
if (!ulong.TryParse(cache.PermRole, out var roleId) ||
(role = ((SocketGuild)ctx.Guild).GetRole(roleId)) is null)
{
await ReplyConfirmLocalizedAsync(strs.permrole_not_set).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.permrole_not_set);
}
else
{
await ReplyConfirmLocalizedAsync(strs.permrole(Format.Bold(role.ToString()))).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.permrole(Format.Bold(role.ToString())));
}
return;
}
@@ -69,7 +69,7 @@ public partial class Permissions : NadekoModule<PermissionService>
_service.UpdateCache(config);
}
await ReplyConfirmLocalizedAsync(strs.permrole_changed(Format.Bold(role.Name))).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.permrole_changed(Format.Bold(role.Name)));
}
public enum Reset { Reset };
@@ -88,7 +88,7 @@ public partial class Permissions : NadekoModule<PermissionService>
_service.UpdateCache(config);
}
await ReplyConfirmLocalizedAsync(strs.permrole_reset).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.permrole_reset);
}
[NadekoCommand, Aliases]
@@ -123,7 +123,7 @@ public partial class Permissions : NadekoModule<PermissionService>
return str;
}));
await ctx.Channel.SendMessageAsync(toSend).ConfigureAwait(false);
await ctx.Channel.SendMessageAsync(toSend);
}
[NadekoCommand, Aliases]
@@ -153,7 +153,7 @@ public partial class Permissions : NadekoModule<PermissionService>
}
catch (IndexOutOfRangeException)
{
await ReplyErrorLocalizedAsync(strs.perm_out_of_range).ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.perm_out_of_range);
}
}
@@ -206,7 +206,7 @@ public partial class Permissions : NadekoModule<PermissionService>
{
}
}
await ReplyConfirmLocalizedAsync(strs.perm_out_of_range).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.perm_out_of_range);
}
[NadekoCommand, Aliases]
@@ -221,7 +221,7 @@ public partial class Permissions : NadekoModule<PermissionService>
SecondaryTargetName = command.Name.ToLowerInvariant(),
State = action.Value,
IsCustomCommand = command.IsCustom,
}).ConfigureAwait(false);
});
if (action.Value)
{
@@ -248,7 +248,7 @@ public partial class Permissions : NadekoModule<PermissionService>
SecondaryTarget = SecondaryPermissionType.Module,
SecondaryTargetName = module.Name.ToLowerInvariant(),
State = action.Value,
}).ConfigureAwait(false);
});
if (action.Value)
{
@@ -276,7 +276,7 @@ public partial class Permissions : NadekoModule<PermissionService>
SecondaryTargetName = command.Name.ToLowerInvariant(),
State = action.Value,
IsCustomCommand = command.IsCustom,
}).ConfigureAwait(false);
});
if (action.Value)
{
@@ -305,7 +305,7 @@ public partial class Permissions : NadekoModule<PermissionService>
SecondaryTarget = SecondaryPermissionType.Module,
SecondaryTargetName = module.Name.ToLowerInvariant(),
State = action.Value,
}).ConfigureAwait(false);
});
if (action.Value)
{
@@ -338,7 +338,7 @@ public partial class Permissions : NadekoModule<PermissionService>
SecondaryTargetName = command.Name.ToLowerInvariant(),
State = action.Value,
IsCustomCommand = command.IsCustom,
}).ConfigureAwait(false);
});
if (action.Value)
{
@@ -370,7 +370,7 @@ public partial class Permissions : NadekoModule<PermissionService>
SecondaryTarget = SecondaryPermissionType.Module,
SecondaryTargetName = module.Name.ToLowerInvariant(),
State = action.Value,
}).ConfigureAwait(false);
});
if (action.Value)
@@ -401,7 +401,7 @@ public partial class Permissions : NadekoModule<PermissionService>
SecondaryTargetName = command.Name.ToLowerInvariant(),
State = action.Value,
IsCustomCommand = command.IsCustom,
}).ConfigureAwait(false);
});
if (action.Value)
{
@@ -430,7 +430,7 @@ public partial class Permissions : NadekoModule<PermissionService>
SecondaryTarget = SecondaryPermissionType.Module,
SecondaryTargetName = module.Name.ToLowerInvariant(),
State = action.Value,
}).ConfigureAwait(false);
});
if (action.Value)
{
@@ -459,7 +459,7 @@ public partial class Permissions : NadekoModule<PermissionService>
SecondaryTarget = SecondaryPermissionType.AllModules,
SecondaryTargetName = "*",
State = action.Value,
}).ConfigureAwait(false);
});
if (action.Value)
{
@@ -487,7 +487,7 @@ public partial class Permissions : NadekoModule<PermissionService>
SecondaryTarget = SecondaryPermissionType.AllModules,
SecondaryTargetName = "*",
State = action.Value,
}).ConfigureAwait(false);
});
if (action.Value)
{
@@ -512,7 +512,7 @@ public partial class Permissions : NadekoModule<PermissionService>
SecondaryTarget = SecondaryPermissionType.AllModules,
SecondaryTargetName = "*",
State = action.Value,
}).ConfigureAwait(false);
});
if (action.Value)
{
@@ -550,15 +550,15 @@ public partial class Permissions : NadekoModule<PermissionService>
await _service.AddPermissions(ctx.Guild.Id,
newPerm,
allowUser).ConfigureAwait(false);
allowUser);
if (action.Value)
{
await ReplyConfirmLocalizedAsync(strs.asm_enable).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.asm_enable);
}
else
{
await ReplyConfirmLocalizedAsync(strs.asm_disable).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.asm_disable);
}
}
}

View File

@@ -1,4 +1,4 @@
#nullable disable
#nullable disable
using NadekoBot.Modules.Permissions.Services;
namespace NadekoBot.Modules.Permissions;
@@ -22,8 +22,8 @@ public partial class Permissions
[UserPerm(GuildPerm.Administrator)]
public async Task ResetPerms()
{
await _perms.Reset(ctx.Guild.Id).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.perms_reset).ConfigureAwait(false);
await _perms.Reset(ctx.Guild.Id);
await ReplyConfirmLocalizedAsync(strs.perms_reset);
}
[NadekoCommand, Aliases]
@@ -31,7 +31,7 @@ public partial class Permissions
public async Task ResetGlobalPerms()
{
await _gps.Reset();
await ReplyConfirmLocalizedAsync(strs.global_perms_reset).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.global_perms_reset);
}
}
}

View File

@@ -1,4 +1,4 @@
#nullable disable
#nullable disable
using NadekoBot.Common.ModuleBehaviors;
using NadekoBot.Services.Database.Models;
@@ -41,7 +41,7 @@ public class CmdCdService : ILateBlocker, INService
{
try
{
await Task.Delay(cdRule.Seconds * 1000).ConfigureAwait(false);
await Task.Delay(cdRule.Seconds * 1000);
activeCdsForGuild.RemoveWhere(ac => ac.Command == commandName && ac.UserId == user.Id);
}
catch

View File

@@ -1,4 +1,4 @@
#nullable disable
#nullable disable
using NadekoBot.Common.ModuleBehaviors;
using Microsoft.EntityFrameworkCore;
using NadekoBot.Services.Database.Models;
@@ -145,7 +145,7 @@ public sealed class FilterService : IEarlyBehavior
try
{
await usrMsg.DeleteAsync().ConfigureAwait(false);
await usrMsg.DeleteAsync();
}
catch (HttpException ex)
{
@@ -176,7 +176,7 @@ public sealed class FilterService : IEarlyBehavior
try
{
await usrMsg.DeleteAsync().ConfigureAwait(false);
await usrMsg.DeleteAsync();
return true;
}
catch (HttpException ex)
@@ -206,7 +206,7 @@ public sealed class FilterService : IEarlyBehavior
try
{
await usrMsg.DeleteAsync().ConfigureAwait(false);
await usrMsg.DeleteAsync();
return true;
}
catch (HttpException ex)

View File

@@ -1,4 +1,4 @@
#nullable disable
#nullable disable
using Microsoft.EntityFrameworkCore;
using NadekoBot.Common.ModuleBehaviors;
using NadekoBot.Modules.Permissions.Common;
@@ -144,7 +144,7 @@ public class PermissionService : ILateBlocker, INService
{
returnMsg = $"You need Admin permissions in order to use permission commands.";
if (pc.Verbose)
try { await channel.SendErrorAsync(_eb, returnMsg).ConfigureAwait(false); } catch { }
try { await channel.SendErrorAsync(_eb, returnMsg); } catch { }
return true;
}
@@ -152,7 +152,7 @@ public class PermissionService : ILateBlocker, INService
{
returnMsg = $"You need the {Format.Bold(role.Name)} role in order to use permission commands.";
if (pc.Verbose)
try { await channel.SendErrorAsync(_eb, returnMsg).ConfigureAwait(false); } catch { }
try { await channel.SendErrorAsync(_eb, returnMsg); } catch { }
return true;
}