mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 17:58:26 -04:00
Kotz's editorconfig styles slightly modified. Target typed new usage. Brackets in expressions used for clarity.
This commit is contained in:
@@ -68,7 +68,7 @@ public partial class Xp
|
||||
[NadekoCommand, Aliases]
|
||||
public async Task ClubIcon([Leftover] string url = null)
|
||||
{
|
||||
if (!Uri.IsWellFormedUriString(url, UriKind.Absolute) && url != null
|
||||
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);
|
||||
@@ -117,7 +117,7 @@ public partial class Xp
|
||||
if (club.OwnerId == x.Id)
|
||||
return int.MaxValue;
|
||||
else if (x.IsClubAdmin)
|
||||
return int.MaxValue / 2 + l;
|
||||
return (int.MaxValue / 2) + l;
|
||||
else
|
||||
return l;
|
||||
});
|
||||
|
@@ -23,7 +23,7 @@ public class LevelStats
|
||||
var lvl = 1;
|
||||
while (true)
|
||||
{
|
||||
required = (int)(baseXp + baseXp / 4.0 * (lvl - 1));
|
||||
required = (int)(baseXp + (baseXp / 4.0 * (lvl - 1)));
|
||||
|
||||
if (required + totalXp > xp)
|
||||
break;
|
||||
|
@@ -6,12 +6,12 @@ namespace NadekoBot.Modules.Xp;
|
||||
public class XpTemplate
|
||||
{
|
||||
[JsonProperty("output_size")]
|
||||
public XpTemplatePos OutputSize { get; set; } = new XpTemplatePos
|
||||
public XpTemplatePos OutputSize { get; set; } = new()
|
||||
{
|
||||
X = 450,
|
||||
Y = 220,
|
||||
};
|
||||
public XpTemplateUser User { get; set; } = new XpTemplateUser
|
||||
public XpTemplateUser User { get; set; } = new()
|
||||
{
|
||||
Name = new()
|
||||
{
|
||||
@@ -171,7 +171,7 @@ public class XpTemplate
|
||||
}
|
||||
}
|
||||
};
|
||||
public XpTemplateClub Club { get; set; } = new XpTemplateClub
|
||||
public XpTemplateClub Club { get; set; } = new()
|
||||
{
|
||||
Icon = new()
|
||||
{
|
||||
|
@@ -14,7 +14,7 @@ public static class Extensions
|
||||
var lvl = 1;
|
||||
while (true)
|
||||
{
|
||||
required = (int)(baseXp + baseXp / 4.0 * (lvl - 1));
|
||||
required = (int)(baseXp + (baseXp / 4.0 * (lvl - 1)));
|
||||
|
||||
if (required + totalXp > stats.Xp)
|
||||
break;
|
||||
|
@@ -289,7 +289,7 @@ public class ClubService : INService
|
||||
if (usr is null)
|
||||
return false;
|
||||
|
||||
if (club.OwnerId == usr.Id || usr.IsClubAdmin && club.Owner.UserId != bannerId) // can't ban the owner kek, whew
|
||||
if (club.OwnerId == usr.Id || (usr.IsClubAdmin && club.Owner.UserId != bannerId)) // can't ban the owner kek, whew
|
||||
return false;
|
||||
|
||||
club.Bans.Add(new()
|
||||
@@ -340,7 +340,7 @@ public class ClubService : INService
|
||||
if (usr is null)
|
||||
return false;
|
||||
|
||||
if (club.OwnerId == usr.Id || usr.IsClubAdmin && club.Owner.UserId != kickerId)
|
||||
if (club.OwnerId == usr.Id || (usr.IsClubAdmin && club.Owner.UserId != kickerId))
|
||||
return false;
|
||||
|
||||
club.Users.Remove(usr);
|
||||
|
@@ -6,7 +6,7 @@ public sealed class XpConfigService : ConfigServiceBase<XpConfig>
|
||||
{
|
||||
public override string Name { get; } = "xp";
|
||||
private const string FilePath = "data/xp.yml";
|
||||
private static TypedKey<XpConfig> changeKey = new TypedKey<XpConfig>("config.xp.updated");
|
||||
private static readonly TypedKey<XpConfig> changeKey = new("config.xp.updated");
|
||||
|
||||
public XpConfigService(IConfigSeria serializer, IPubSub pubSub)
|
||||
: base(FilePath, serializer, pubSub, changeKey)
|
||||
|
@@ -46,8 +46,7 @@ public class XpService : INService
|
||||
|
||||
private readonly ConcurrentHashSet<ulong> _excludedServers;
|
||||
|
||||
private readonly ConcurrentQueue<UserCacheItem> _addMessageXp
|
||||
= new ConcurrentQueue<UserCacheItem>();
|
||||
private readonly ConcurrentQueue<UserCacheItem> _addMessageXp = new();
|
||||
private XpTemplate _template;
|
||||
private readonly DiscordSocketClient _client;
|
||||
|
||||
@@ -485,7 +484,7 @@ public class XpService : INService
|
||||
|
||||
private Task _client_OnUserVoiceStateUpdated(SocketUser socketUser, SocketVoiceState before, SocketVoiceState after)
|
||||
{
|
||||
if (!(socketUser is SocketGuildUser user) || user.IsBot)
|
||||
if (socketUser is not SocketGuildUser user || user.IsBot)
|
||||
return Task.CompletedTask;
|
||||
|
||||
var _ = Task.Run(() =>
|
||||
@@ -608,7 +607,7 @@ public class XpService : INService
|
||||
|
||||
private Task _cmd_OnMessageNoTrigger(IUserMessage arg)
|
||||
{
|
||||
if (!(arg.Author is SocketGuildUser user) || user.IsBot)
|
||||
if (arg.Author is not SocketGuildUser user || user.IsBot)
|
||||
return Task.CompletedTask;
|
||||
|
||||
var _ = Task.Run(() =>
|
||||
@@ -955,7 +954,7 @@ public class XpService : INService
|
||||
? "+ "
|
||||
: "";
|
||||
var awX = _template.User.Xp.Awarded.Pos.X -
|
||||
Math.Max(0, stats.FullGuildStats.AwardedXp.ToString().Length - 2) * 5;
|
||||
(Math.Max(0, stats.FullGuildStats.AwardedXp.ToString().Length - 2) * 5);
|
||||
var awY = _template.User.Xp.Awarded.Pos.Y;
|
||||
img.Mutate(x => x.DrawText($"({sign}{stats.FullGuildStats.AwardedXp})",
|
||||
_fonts.NotoSans.CreateFont(_template.User.Xp.Awarded.FontSize, FontStyle.Bold),
|
||||
|
@@ -339,7 +339,7 @@ public partial class Xp : NadekoModule<XpService>
|
||||
await _tracker.EnsureUsersDownloadedAsync(ctx.Guild).ConfigureAwait(false);
|
||||
|
||||
allUsers = _service.GetTopUserXps(ctx.Guild.Id, 1000)
|
||||
.Where(user => !(socketGuild.GetUser(user.UserId) is null))
|
||||
.Where(user => socketGuild.GetUser(user.UserId) is not null)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
@@ -377,7 +377,7 @@ public partial class Xp : NadekoModule<XpService>
|
||||
awardStr = $"({userXpData.AwardedXp})";
|
||||
|
||||
embed.AddField(
|
||||
$"#{i + 1 + curPage * 9} {user?.ToString() ?? users[i].UserId.ToString()}",
|
||||
$"#{i + 1 + (curPage * 9)} {user?.ToString() ?? users[i].UserId.ToString()}",
|
||||
$"{GetText(strs.level_x(levelStats.Level))} - {levelStats.TotalXp}xp {awardStr}");
|
||||
}
|
||||
return embed;
|
||||
@@ -405,7 +405,7 @@ public partial class Xp : NadekoModule<XpService>
|
||||
{
|
||||
var user = users[i];
|
||||
embed.AddField(
|
||||
$"#{i + 1 + page * 9} {user.ToString()}",
|
||||
$"#{i + 1 + (page * 9)} {user.ToString()}",
|
||||
$"{GetText(strs.level_x(new LevelStats(users[i].TotalXp).Level))} - {users[i].TotalXp}xp");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user