diff --git a/src/NadekoBot/Modules/Xp/Xp.cs b/src/NadekoBot/Modules/Xp/Xp.cs index 570b776fe..57c0f19c6 100644 --- a/src/NadekoBot/Modules/Xp/Xp.cs +++ b/src/NadekoBot/Modules/Xp/Xp.cs @@ -252,6 +252,23 @@ public partial class Xp : NadekoModule [Cmd] [RequireContext(ContextType.Guild)] [UserPerm(GuildPerm.Administrator)] + [Priority(2)] + public async Task XpAdd(long amount, [Remainder] SocketRole role) + { + if (amount == 0) + return; + + if (role.IsManaged) + return; + + var count = await _service.AddXpToUsersAsync(ctx.Guild.Id, amount, role.Members.Select(x => x.Id).ToArray()); + await ReplyConfirmLocalizedAsync(strs.xpadd_users(Format.Bold(amount.ToString()), Format.Bold(count.ToString()))); + } + + [Cmd] + [RequireContext(ContextType.Guild)] + [UserPerm(GuildPerm.Administrator)] + [Priority(3)] public async Task XpAdd(int amount, ulong userId) { if (amount == 0) @@ -265,6 +282,7 @@ public partial class Xp : NadekoModule [Cmd] [RequireContext(ContextType.Guild)] [UserPerm(GuildPerm.Administrator)] + [Priority(4)] public Task XpAdd(int amount, [Leftover] IGuildUser user) => XpAdd(amount, user.Id); diff --git a/src/NadekoBot/Modules/Xp/XpService.cs b/src/NadekoBot/Modules/Xp/XpService.cs index 7b9216d92..becc68810 100644 --- a/src/NadekoBot/Modules/Xp/XpService.cs +++ b/src/NadekoBot/Modules/Xp/XpService.cs @@ -726,6 +726,17 @@ public class XpService : INService, IReadyExecutor, IExecNoCommand // }); // } + public async Task AddXpToUsersAsync(ulong guildId, long amount, params ulong[] userIds) + { + await using var ctx = _db.GetDbContext(); + return await ctx.GetTable() + .Where(x => x.GuildId == guildId && userIds.Contains(x.UserId)) + .UpdateAsync(old => new() + { + Xp = old.Xp + amount + }); + } + public void AddXp(ulong userId, ulong guildId, int amount) { using var uow = _db.GetDbContext(); diff --git a/src/NadekoBot/Services/Impl/StatsService.cs b/src/NadekoBot/Services/Impl/StatsService.cs index ec2b15796..f42a25fed 100644 --- a/src/NadekoBot/Services/Impl/StatsService.cs +++ b/src/NadekoBot/Services/Impl/StatsService.cs @@ -7,7 +7,7 @@ namespace NadekoBot.Services; public sealed class StatsService : IStatsService, IReadyExecutor, INService { - public const string BOT_VERSION = "4.2.15"; + public const string BOT_VERSION = "4.3.0"; public string Author => "Kwoth#2452"; diff --git a/src/NadekoBot/data/strings/commands/commands.en-US.yml b/src/NadekoBot/data/strings/commands/commands.en-US.yml index d7f5308d9..60fc26147 100644 --- a/src/NadekoBot/data/strings/commands/commands.en-US.yml +++ b/src/NadekoBot/data/strings/commands/commands.en-US.yml @@ -1853,9 +1853,10 @@ xpgloballeaderboard: args: - "" xpadd: - desc: "Adds xp to a user on the server. This does not affect their global ranking. You can use negative values." + desc: "Adds server XP to a single user or all users role on this server. This does not affect their global ranking. You can use negative values." args: - "100 @Someone" + - "500 SomeRoleName" clubcreate: desc: "Creates a club. You must be at least level 5 and not be in the club already." args: diff --git a/src/NadekoBot/data/strings/responses/responses.en-US.json b/src/NadekoBot/data/strings/responses/responses.en-US.json index c0beba279..f7d8af042 100644 --- a/src/NadekoBot/data/strings/responses/responses.en-US.json +++ b/src/NadekoBot/data/strings/responses/responses.en-US.json @@ -1012,5 +1012,6 @@ "quotas": "<<< Quotas >>>", "patron_not_enabled": "Patron system is disabled.", "results_in": "{0} results in {1}s", - "patron_msg_sent": "Done sending messages to patrons at and above tier {1}. {1} successfully sent and {2} failed." + "patron_msg_sent": "Done sending messages to patrons at and above tier {1}. {1} successfully sent and {2} failed.", + "xpadd_users": "Added {0} server XP to {1} users." }