diff --git a/CHANGELOG.md b/CHANGELOG.md index 34d2276..d6f8db1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.1.0/) except date format. a-c-f-r-o +## [5.1.19] + ## [5.1.18] - 04.11.2024 ### Added diff --git a/src/EllieBot.GrpcApiBase/protos/xp.proto b/src/EllieBot.GrpcApiBase/protos/xp.proto index 84c4daa..72bcba9 100644 --- a/src/EllieBot.GrpcApiBase/protos/xp.proto +++ b/src/EllieBot.GrpcApiBase/protos/xp.proto @@ -15,6 +15,17 @@ service GrpcXp { rpc AddReward(AddRewardRequest) returns (AddRewardReply); rpc DeleteReward(DeleteRewardRequest) returns (DeleteRewardReply); + + rpc SetServerExclusion(SetServerExclusionRequest) returns (SetServerExclusionReply); +} + +message SetServerExclusionRequest { + uint64 guildId = 1; + bool serverExcluded = 2; +} + +message SetServerExclusionReply { + bool success = 1; } message GetXpLbRequest { @@ -32,7 +43,8 @@ message XpLbUserReply { string username = 2; int64 xp = 3; int64 level = 4; - string avatar = 5; + int64 levelPercent = 5; + string avatar = 6; } message ResetUserXpRequest { diff --git a/src/EllieBot/Db/Models/support/PatronQuota.cs b/src/EllieBot/Db/Models/support/PatronQuota.cs index d493807..4f529fa 100644 --- a/src/EllieBot/Db/Models/support/PatronQuota.cs +++ b/src/EllieBot/Db/Models/support/PatronQuota.cs @@ -3,6 +3,7 @@ namespace EllieBot.Db.Models; public class PatronUser { + public int Id { get; set; } public string UniquePlatformUserId { get; set; } public ulong UserId { get; set; } public int AmountCents { get; set; } diff --git a/src/EllieBot/Modules/Gambling/PlantPick/PlantPickService.cs b/src/EllieBot/Modules/Gambling/PlantPick/PlantPickService.cs index cd08bf1..c875bc0 100644 --- a/src/EllieBot/Modules/Gambling/PlantPick/PlantPickService.cs +++ b/src/EllieBot/Modules/Gambling/PlantPick/PlantPickService.cs @@ -169,7 +169,7 @@ public class PlantPickService : IEService, IExecNoCommand Start = 0, End = pass.GetGraphemeCount(), Font = font, - StrikeoutPen = new SolidPen(Color.White, 5), + StrikeoutPen = new SolidPen(Color.White, 3), TextDecorations = TextDecorations.Strikeout }; diff --git a/src/EllieBot/Modules/Searches/Translate/FlagTranslateService_SupportedFlags.cs b/src/EllieBot/Modules/Searches/Translate/FlagTranslateService_SupportedFlags.cs index 07a6fe7..c82b9ae 100644 --- a/src/EllieBot/Modules/Searches/Translate/FlagTranslateService_SupportedFlags.cs +++ b/src/EllieBot/Modules/Searches/Translate/FlagTranslateService_SupportedFlags.cs @@ -69,5 +69,8 @@ public partial class FlagTranslateService YE ar AL sq AE ar + AU en + NZ en + KZ kz """; } \ No newline at end of file diff --git a/src/EllieBot/Services/GrpcApi/XpSvc.cs b/src/EllieBot/Services/GrpcApi/XpSvc.cs index 8374382..7886b43 100644 --- a/src/EllieBot/Services/GrpcApi/XpSvc.cs +++ b/src/EllieBot/Services/GrpcApi/XpSvc.cs @@ -69,10 +69,10 @@ public class XpSvc : GrpcXp.GrpcXpBase, IGrpcSvc, IEService rews = rews.Concat(roleRews.Select(x => new RewItemReply() { Level = x.Level, - Type = "Role", + Type = x.Remove ? "RemoveRole" : "AddRole", Value = guild.GetRole(x.RoleId)?.ToString() ?? x.RoleId.ToString() })) - .OrderBy(x => x.Level); + .OrderBy(x => x.Level); reply.Rewards.AddRange(rews); @@ -207,15 +207,15 @@ public class XpSvc : GrpcXp.GrpcXpBase, IGrpcSvc, IEService public override async Task GetXpLb(GetXpLbRequest request, ServerCallContext context) { - if (request.Page < 0) - throw new RpcException(new Status(StatusCode.InvalidArgument, "Page must be greater than or equal to 0")); + if (request.Page < 1) + throw new RpcException(new Status(StatusCode.InvalidArgument, "Page must be greater than or equal to 1")); var guild = _client.GetGuild(request.GuildId); if (guild is null) throw new RpcException(new Status(StatusCode.NotFound, "Guild not found")); - var data = await _xp.GetGuildUserXps(request.GuildId, request.Page); + var data = await _xp.GetGuildUserXps(request.GuildId, request.Page - 1); var total = await _xp.GetTotalGuildUsers(request.GuildId); var reply = new GetXpLbReply @@ -223,45 +223,60 @@ public class XpSvc : GrpcXp.GrpcXpBase, IGrpcSvc, IEService Total = total }; - reply.Users.AddRange(await data - .Select(async x => - { - var user = guild.GetUser(x.UserId); + var users = await data + .Select(async x => + { + var user = guild.GetUser(x.UserId); - if (user is null) - { - var du = await _duSvc.GetUserAsync(x.UserId); - if (du is null) - return new XpLbUserReply - { - UserId = x.UserId, - Avatar = string.Empty, - Username = string.Empty, - Xp = x.Xp, - Level = new LevelStats(x.Xp).Level - }; + if (user is null) + { + var du = await _duSvc.GetUserAsync(x.UserId); + if (du is null) + return new XpLbUserReply + { + UserId = x.UserId, + Avatar = string.Empty, + Username = string.Empty, + Xp = x.Xp, + Level = new LevelStats(x.Xp).Level + }; - return new XpLbUserReply() - { - UserId = x.UserId, - Avatar = du.RealAvatarUrl()?.ToString() ?? string.Empty, - Username = du.ToString() ?? string.Empty, - Xp = x.Xp, - Level = new LevelStats(x.Xp).Level - }; - } + return new XpLbUserReply() + { + UserId = x.UserId, + Avatar = du.RealAvatarUrl()?.ToString() ?? string.Empty, + Username = du.ToString() ?? string.Empty, + Xp = x.Xp, + Level = new LevelStats(x.Xp).Level + }; + } - return new XpLbUserReply - { - UserId = x.UserId, - Avatar = user?.GetAvatarUrl() ?? string.Empty, - Username = user?.ToString() ?? string.Empty, - Xp = x.Xp, - Level = new LevelStats(x.Xp).Level - }; - }) - .WhenAll()); + return new XpLbUserReply + { + UserId = x.UserId, + Avatar = user?.GetAvatarUrl() ?? string.Empty, + Username = user?.ToString() ?? string.Empty, + Xp = x.Xp, + Level = new LevelStats(x.Xp).Level + }; + }) + .WhenAll(); + + reply.Users.AddRange(users); return reply; } + + public override async Task SetServerExclusion( + SetServerExclusionRequest request, + ServerCallContext context) + { + await Task.Yield(); + + var newValue = _xp.ToggleExcludeServer(request.GuildId); + return new() + { + Success = newValue + }; + } } \ No newline at end of file