mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
- 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:
@@ -1,4 +1,4 @@
|
||||
#nullable disable
|
||||
#nullable disable
|
||||
using NadekoBot.Modules.Xp.Services;
|
||||
|
||||
namespace NadekoBot.Modules.Xp;
|
||||
@@ -23,7 +23,7 @@ public partial class Xp
|
||||
Format.Bold(club.Name),
|
||||
Format.Bold(newOwner.ToString())));
|
||||
else
|
||||
await ReplyErrorLocalizedAsync(strs.club_transfer_failed).ConfigureAwait(false);
|
||||
await ReplyErrorLocalizedAsync(strs.club_transfer_failed);
|
||||
}
|
||||
|
||||
[NadekoCommand, Aliases]
|
||||
@@ -36,7 +36,7 @@ public partial class Xp
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.club_admin_error).ConfigureAwait(false);
|
||||
await ReplyErrorLocalizedAsync(strs.club_admin_error);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -51,17 +51,17 @@ public partial class Xp
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(clubName) || clubName.Length > 20)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.club_name_too_long).ConfigureAwait(false);
|
||||
await ReplyErrorLocalizedAsync(strs.club_name_too_long);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_service.CreateClub(ctx.User, clubName, out var club))
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.club_create_error).ConfigureAwait(false);
|
||||
await ReplyErrorLocalizedAsync(strs.club_create_error);
|
||||
return;
|
||||
}
|
||||
|
||||
await ReplyConfirmLocalizedAsync(strs.club_created(Format.Bold(club.ToString()))).ConfigureAwait(false);
|
||||
await ReplyConfirmLocalizedAsync(strs.club_created(Format.Bold(club.ToString())));
|
||||
}
|
||||
|
||||
[NadekoCommand, Aliases]
|
||||
@@ -70,11 +70,11 @@ public partial class Xp
|
||||
if ((!Uri.IsWellFormedUriString(url, UriKind.Absolute) && url != null)
|
||||
|| !await _service.SetClubIcon(ctx.User.Id, url is null ? null : new Uri(url)))
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.club_icon_error).ConfigureAwait(false);
|
||||
await ReplyErrorLocalizedAsync(strs.club_icon_error);
|
||||
return;
|
||||
}
|
||||
|
||||
await ReplyConfirmLocalizedAsync(strs.club_icon_set).ConfigureAwait(false);
|
||||
await ReplyConfirmLocalizedAsync(strs.club_icon_set);
|
||||
}
|
||||
|
||||
[NadekoCommand, Aliases]
|
||||
@@ -89,7 +89,7 @@ public partial class Xp
|
||||
return;
|
||||
}
|
||||
|
||||
await ClubInformation(club.ToString()).ConfigureAwait(false);
|
||||
await ClubInformation(club.ToString());
|
||||
}
|
||||
|
||||
[NadekoCommand, Aliases]
|
||||
@@ -98,13 +98,13 @@ public partial class Xp
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(clubName))
|
||||
{
|
||||
await ClubInformation(ctx.User).ConfigureAwait(false);
|
||||
await ClubInformation(ctx.User);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_service.GetClubByName(clubName, out var club))
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.club_not_exists).ConfigureAwait(false);
|
||||
await ReplyErrorLocalizedAsync(strs.club_not_exists);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ public partial class Xp
|
||||
return embed.WithThumbnailUrl(club.ImageUrl);
|
||||
|
||||
return embed;
|
||||
}, club.Users.Count, 10).ConfigureAwait(false);
|
||||
}, club.Users.Count, 10);
|
||||
}
|
||||
|
||||
[NadekoCommand, Aliases]
|
||||
@@ -221,7 +221,7 @@ public partial class Xp
|
||||
|
||||
if (!_service.GetClubByName(clubName, out var club))
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.club_not_exists).ConfigureAwait(false);
|
||||
await ReplyErrorLocalizedAsync(strs.club_not_exists);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ public partial class Xp
|
||||
}
|
||||
else
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.club_apply_error).ConfigureAwait(false);
|
||||
await ReplyErrorLocalizedAsync(strs.club_apply_error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,16 +249,16 @@ public partial class Xp
|
||||
await ReplyConfirmLocalizedAsync(strs.club_accepted(Format.Bold(discordUser.ToString())));
|
||||
}
|
||||
else
|
||||
await ReplyErrorLocalizedAsync(strs.club_accept_error).ConfigureAwait(false);
|
||||
await ReplyErrorLocalizedAsync(strs.club_accept_error);
|
||||
}
|
||||
|
||||
[NadekoCommand, Aliases]
|
||||
public async Task Clubleave()
|
||||
{
|
||||
if (_service.LeaveClub(ctx.User))
|
||||
await ReplyConfirmLocalizedAsync(strs.club_left).ConfigureAwait(false);
|
||||
await ReplyConfirmLocalizedAsync(strs.club_left);
|
||||
else
|
||||
await ReplyErrorLocalizedAsync(strs.club_not_in_club).ConfigureAwait(false);
|
||||
await ReplyErrorLocalizedAsync(strs.club_not_in_club);
|
||||
}
|
||||
|
||||
[NadekoCommand, Aliases]
|
||||
@@ -318,7 +318,7 @@ public partial class Xp
|
||||
}
|
||||
else
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.club_level_req_change_error).ConfigureAwait(false);
|
||||
await ReplyErrorLocalizedAsync(strs.club_level_req_change_error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,7 +331,7 @@ public partial class Xp
|
||||
}
|
||||
else
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.club_desc_update_failed).ConfigureAwait(false);
|
||||
await ReplyErrorLocalizedAsync(strs.club_desc_update_failed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -344,7 +344,7 @@ public partial class Xp
|
||||
}
|
||||
else
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.club_disband_error).ConfigureAwait(false);
|
||||
await ReplyErrorLocalizedAsync(strs.club_disband_error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#nullable disable
|
||||
#nullable disable
|
||||
using NadekoBot.Modules.Xp.Services;
|
||||
|
||||
namespace NadekoBot.Modules.Xp;
|
||||
@@ -23,7 +23,7 @@ public partial class Xp
|
||||
.WithTitle(GetText(strs.reset))
|
||||
.WithDescription(GetText(strs.reset_user_confirm));
|
||||
|
||||
if (!await PromptUserConfirmAsync(embed).ConfigureAwait(false))
|
||||
if (!await PromptUserConfirmAsync(embed))
|
||||
return;
|
||||
|
||||
_service.XpReset(ctx.Guild.Id, userId);
|
||||
@@ -40,12 +40,12 @@ public partial class Xp
|
||||
.WithTitle(GetText(strs.reset))
|
||||
.WithDescription(GetText(strs.reset_server_confirm));
|
||||
|
||||
if (!await PromptUserConfirmAsync(embed).ConfigureAwait(false))
|
||||
if (!await PromptUserConfirmAsync(embed))
|
||||
return;
|
||||
|
||||
_service.XpReset(ctx.Guild.Id);
|
||||
|
||||
await ReplyConfirmLocalizedAsync(strs.reset_server).ConfigureAwait(false);
|
||||
await ReplyConfirmLocalizedAsync(strs.reset_server);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -100,7 +100,7 @@ public class ClubService : INService
|
||||
if (url != null)
|
||||
{
|
||||
using var http = _httpFactory.CreateClient();
|
||||
using var temp = await http.GetAsync(url, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false);
|
||||
using var temp = await http.GetAsync(url, HttpCompletionOption.ResponseHeadersRead);
|
||||
if (!temp.IsImage() || temp.GetImageSize() > 11)
|
||||
return false;
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#nullable disable
|
||||
#nullable disable
|
||||
using NadekoBot.Common.Configs;
|
||||
|
||||
namespace NadekoBot.Modules.Xp.Services;
|
||||
@@ -29,7 +29,7 @@ public sealed class XpConfigService : ConfigServiceBase<XpConfig>
|
||||
|
||||
private void Migrate()
|
||||
{
|
||||
if (_data.Version < 2)
|
||||
if (data.Version < 2)
|
||||
{
|
||||
ModifyConfig(c =>
|
||||
{
|
||||
|
@@ -242,7 +242,7 @@ public class XpService : INService
|
||||
uow.SaveChanges();
|
||||
}
|
||||
|
||||
await Task.WhenAll(toNotify.Select(async x =>
|
||||
await toNotify.Select(async x =>
|
||||
{
|
||||
if (x.NotifOf == NotifOf.Server)
|
||||
{
|
||||
@@ -281,7 +281,7 @@ public class XpService : INService
|
||||
Format.Bold(x.Level.ToString())),
|
||||
x.Guild.Id));
|
||||
}
|
||||
}));
|
||||
}).WhenAll();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@@ -21,12 +21,11 @@ public partial class Xp : NadekoModule<XpService>
|
||||
public async Task Experience([Leftover] IUser user = null)
|
||||
{
|
||||
user ??= ctx.User;
|
||||
await ctx.Channel.TriggerTypingAsync().ConfigureAwait(false);
|
||||
var (img, fmt) = await _service.GenerateXpImageAsync((IGuildUser)user).ConfigureAwait(false);
|
||||
await ctx.Channel.TriggerTypingAsync();
|
||||
var (img, fmt) = await _service.GenerateXpImageAsync((IGuildUser)user);
|
||||
await using (img)
|
||||
{
|
||||
await ctx.Channel.SendFileAsync(img, $"{ctx.Guild.Id}_{user.Id}_xp.{fmt.FileExtensions.FirstOrDefault()}")
|
||||
.ConfigureAwait(false);
|
||||
await ctx.Channel.SendFileAsync(img, $"{ctx.Guild.Id}_{user.Id}_xp.{fmt.FileExtensions.FirstOrDefault()}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,11 +198,11 @@ public partial class Xp : NadekoModule<XpService>
|
||||
public async Task XpNotify(NotifyPlace place, XpNotificationLocation type)
|
||||
{
|
||||
if (place == NotifyPlace.Guild)
|
||||
await _service.ChangeNotificationType(ctx.User.Id, ctx.Guild.Id, type).ConfigureAwait(false);
|
||||
await _service.ChangeNotificationType(ctx.User.Id, ctx.Guild.Id, type);
|
||||
else
|
||||
await _service.ChangeNotificationType(ctx.User, type).ConfigureAwait(false);
|
||||
await _service.ChangeNotificationType(ctx.User, type);
|
||||
|
||||
await ctx.OkAsync().ConfigureAwait(false);
|
||||
await ctx.OkAsync();
|
||||
}
|
||||
|
||||
public enum Server { Server };
|
||||
@@ -277,10 +276,9 @@ public partial class Xp : NadekoModule<XpService>
|
||||
.Select(x => $"`role` {x.Mention}")
|
||||
.ToList();
|
||||
|
||||
var chans = (await Task.WhenAll(_service.GetExcludedChannels(ctx.Guild.Id)
|
||||
.Select(x => ctx.Guild.GetChannelAsync(x)))
|
||||
.ConfigureAwait(false))
|
||||
.Where(x => x != null)
|
||||
var chans = (await _service.GetExcludedChannels(ctx.Guild.Id)
|
||||
.Select(x => ctx.Guild.GetChannelAsync(x))
|
||||
.WhenAll()).Where(x => x != null)
|
||||
.Select(x => $"`channel` <#{x.Id}>")
|
||||
.ToList();
|
||||
|
||||
@@ -328,8 +326,8 @@ public partial class Xp : NadekoModule<XpService>
|
||||
var allUsers = new List<UserXpStats>();
|
||||
if (opts.Clean)
|
||||
{
|
||||
await ctx.Channel.TriggerTypingAsync().ConfigureAwait(false);
|
||||
await _tracker.EnsureUsersDownloadedAsync(ctx.Guild).ConfigureAwait(false);
|
||||
await ctx.Channel.TriggerTypingAsync();
|
||||
await _tracker.EnsureUsersDownloadedAsync(ctx.Guild);
|
||||
|
||||
allUsers = _service.GetTopUserXps(ctx.Guild.Id, 1000)
|
||||
.Where(user => socketGuild.GetUser(user.UserId) is not null)
|
||||
@@ -403,7 +401,7 @@ public partial class Xp : NadekoModule<XpService>
|
||||
}
|
||||
}
|
||||
|
||||
await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);
|
||||
await ctx.Channel.EmbedAsync(embed);
|
||||
}
|
||||
|
||||
[NadekoCommand, Aliases]
|
||||
@@ -417,7 +415,7 @@ public partial class Xp : NadekoModule<XpService>
|
||||
_service.AddXp(userId, ctx.Guild.Id, amount);
|
||||
var usr = ((SocketGuild)ctx.Guild).GetUser(userId)?.ToString()
|
||||
?? userId.ToString();
|
||||
await ReplyConfirmLocalizedAsync(strs.modified(Format.Bold(usr), Format.Bold(amount.ToString()))).ConfigureAwait(false);
|
||||
await ReplyConfirmLocalizedAsync(strs.modified(Format.Bold(usr), Format.Bold(amount.ToString())));
|
||||
}
|
||||
|
||||
[NadekoCommand, Aliases]
|
||||
@@ -432,7 +430,7 @@ public partial class Xp : NadekoModule<XpService>
|
||||
public async Task XpTemplateReload()
|
||||
{
|
||||
_service.ReloadXpTemplate();
|
||||
await Task.Delay(1000).ConfigureAwait(false);
|
||||
await ReplyConfirmLocalizedAsync(strs.template_reloaded).ConfigureAwait(false);
|
||||
await Task.Delay(1000);
|
||||
await ReplyConfirmLocalizedAsync(strs.template_reloaded);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user