From 3c33c55dda21f7f2e589459ddd1407ba232f5388 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Tue, 13 Jul 2021 23:58:16 +0200 Subject: [PATCH] .warnp should accept roles only below your max role. Also added a custom error message --- .../Modules/Administration/UserPunishCommands.cs | 8 ++++++++ src/NadekoBot/data/strings/responses/responses.en-US.json | 1 + 2 files changed, 9 insertions(+) diff --git a/src/NadekoBot/Modules/Administration/UserPunishCommands.cs b/src/NadekoBot/Modules/Administration/UserPunishCommands.cs index e9c21f432..0eda24390 100644 --- a/src/NadekoBot/Modules/Administration/UserPunishCommands.cs +++ b/src/NadekoBot/Modules/Administration/UserPunishCommands.cs @@ -323,6 +323,14 @@ namespace NadekoBot.Modules.Administration public async Task WarnPunish(int number, AddRole _, IRole role, StoopidTime time = null) { var punish = PunishmentAction.AddRole; + + if (ctx.Guild.OwnerId != ctx.User.Id && + role.Position >= ((IGuildUser)ctx.User).GetRoles().Max(x => x.Position)) + { + await ReplyErrorLocalizedAsync("role_too_high"); + return; + } + var success = _service.WarnPunish(ctx.Guild.Id, number, punish, time, role); if (!success) diff --git a/src/NadekoBot/data/strings/responses/responses.en-US.json b/src/NadekoBot/data/strings/responses/responses.en-US.json index 02c49276c..4b26621d3 100644 --- a/src/NadekoBot/data/strings/responses/responses.en-US.json +++ b/src/NadekoBot/data/strings/responses/responses.en-US.json @@ -80,6 +80,7 @@ "greet_off": "Greet announcements disabled.", "greet_on": "Greet announcements enabled on this channel.", "hierarchy": "You can't use this command on users with a role higher or equal than yours (or mine) in the role hierarchy.", + "role_too_high": "You can't use this command with roles which are above your highest role, unless you're server administrator.", "images_loading": "Images will be reloaded within a few seconds.", "insuf_perms_i": "I have insufficient permissions.", "insuf_perms_u": "You have insufficient permissions.",