.warn can now only be used on users lower than you in the role hierarchy

This commit is contained in:
Master Kwoth 2017-10-17 15:14:15 +02:00
parent f53c77ec9d
commit 2d81bc45fd

View File

@ -29,6 +29,11 @@ namespace NadekoBot.Modules.Administration
[RequireUserPermission(GuildPermission.BanMembers)] [RequireUserPermission(GuildPermission.BanMembers)]
public async Task Warn(IGuildUser user, [Remainder] string reason = null) public async Task Warn(IGuildUser user, [Remainder] string reason = null)
{ {
if (Context.User.Id != user.Guild.OwnerId && (user.GetRoles().Select(r => r.Position).Max() >= ((IGuildUser)Context.User).GetRoles().Select(r => r.Position).Max()))
{
await ReplyErrorLocalized("hierarchy").ConfigureAwait(false);
return;
}
try try
{ {
await (await user.GetOrCreateDMChannelAsync()).EmbedAsync(new EmbedBuilder().WithErrorColor() await (await user.GetOrCreateDMChannelAsync()).EmbedAsync(new EmbedBuilder().WithErrorColor()