From 574b23070ac1e452a27410356e973a6fafd89000 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Fri, 21 Oct 2016 18:40:04 +0200 Subject: [PATCH] kick and ban will respoect role hierarchy now --- .../Modules/Administration/Administration.cs | 21 +++++++++++++++++++ .../Modules/Utility/Commands/InfoCommands.cs | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/NadekoBot/Modules/Administration/Administration.cs b/src/NadekoBot/Modules/Administration/Administration.cs index 8f123251..a4802a68 100644 --- a/src/NadekoBot/Modules/Administration/Administration.cs +++ b/src/NadekoBot/Modules/Administration/Administration.cs @@ -301,6 +301,16 @@ namespace NadekoBot.Modules.Administration { msg = "No reason provided."; } + if (umsg.Author.Id != user.Guild.OwnerId && user.Roles.Select(r=>r.Position).Max() >= ((IGuildUser)umsg.Author).Roles.Select(r => r.Position).Max()) + { + await channel.SendMessageAsync("You can't use this command on users with a role higher or equal to yours in the role hierarchy."); + return; + } + if (umsg.Author.Id != user.Guild.OwnerId && user.Roles.Max().Position >= ((IGuildUser)umsg.Author).Roles.Max().Position) + { + await channel.SendMessageAsync("You can't use this command on users with a role higher or equal to yours in the role hierarchy."); + return; + } try { await (await user.CreateDMChannelAsync()).SendMessageAsync($"**You have been BANNED from `{channel.Guild.Name}` server.**\n" + @@ -330,6 +340,11 @@ namespace NadekoBot.Modules.Administration { msg = "No reason provided."; } + if (umsg.Author.Id != user.Guild.OwnerId && user.Roles.Max().Position >= ((IGuildUser)umsg.Author).Roles.Max().Position) + { + await channel.SendMessageAsync("You can't use this command on users with a role higher or equal to yours in the role hierarchy."); + return; + } try { await user.SendMessageAsync($"**You have been SOFT-BANNED from `{channel.Guild.Name}` server.**\n" + @@ -363,6 +378,12 @@ namespace NadekoBot.Modules.Administration await channel.SendMessageAsync("User not found.").ConfigureAwait(false); return; } + + if (umsg.Author.Id != user.Guild.OwnerId && user.Roles.Select(r => r.Position).Max() >= ((IGuildUser)umsg.Author).Roles.Select(r => r.Position).Max()) + { + await channel.SendMessageAsync("You can't use this command on users with a role higher or equal to yours in the role hierarchy."); + return; + } if (!string.IsNullOrWhiteSpace(msg)) { try diff --git a/src/NadekoBot/Modules/Utility/Commands/InfoCommands.cs b/src/NadekoBot/Modules/Utility/Commands/InfoCommands.cs index fad77cc4..5f65fa64 100644 --- a/src/NadekoBot/Modules/Utility/Commands/InfoCommands.cs +++ b/src/NadekoBot/Modules/Utility/Commands/InfoCommands.cs @@ -79,7 +79,7 @@ namespace NadekoBot.Modules.Utility `Joined Server:` **{user.JoinedAt?.ToString("dd.MM.yyyy HH:mm")}** `Joined Discord:` **{user.CreatedAt.ToString("dd.MM.yyyy HH:mm")}** `Roles:` **({user.Roles.Count()}) - {string.Join(", ", user.Roles.Select(r => r.Name)).SanitizeMentions()}** -`AvatarUrl:` **{user.AvatarUrl}**"; +`AvatarUrl:` **{await NadekoBot.Google.ShortenUrl(user.AvatarUrl).ConfigureAwait(false)}**"; await msg.Reply(toReturn).ConfigureAwait(false); } }