.rar, .sr, .renr and .rr will now work only on roles lower than your highest role
This commit is contained in:
parent
d0380b0cbf
commit
6817b1ba07
@ -11,7 +11,6 @@ using Discord.WebSocket;
|
|||||||
using NadekoBot.Services.Database.Models;
|
using NadekoBot.Services.Database.Models;
|
||||||
using static NadekoBot.Modules.Permissions.Permissions;
|
using static NadekoBot.Modules.Permissions.Permissions;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using NLog;
|
using NLog;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Administration
|
namespace NadekoBot.Modules.Administration
|
||||||
@ -99,6 +98,10 @@ namespace NadekoBot.Modules.Administration
|
|||||||
[RequireBotPermission(GuildPermission.ManageRoles)]
|
[RequireBotPermission(GuildPermission.ManageRoles)]
|
||||||
public async Task Setrole(IGuildUser usr, [Remainder] IRole role)
|
public async Task Setrole(IGuildUser usr, [Remainder] IRole role)
|
||||||
{
|
{
|
||||||
|
var guser = (IGuildUser)Context.User;
|
||||||
|
var maxRole = guser.GetRoles().Max(x => x.Position);
|
||||||
|
if (maxRole < role.Position || maxRole <= usr.GetRoles().Max(x => x.Position))
|
||||||
|
return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await usr.AddRolesAsync(role).ConfigureAwait(false);
|
await usr.AddRolesAsync(role).ConfigureAwait(false);
|
||||||
@ -118,6 +121,9 @@ namespace NadekoBot.Modules.Administration
|
|||||||
[RequireBotPermission(GuildPermission.ManageRoles)]
|
[RequireBotPermission(GuildPermission.ManageRoles)]
|
||||||
public async Task Removerole(IGuildUser usr, [Remainder] IRole role)
|
public async Task Removerole(IGuildUser usr, [Remainder] IRole role)
|
||||||
{
|
{
|
||||||
|
var guser = (IGuildUser)Context.User;
|
||||||
|
if (Context.User.Id != guser.Guild.OwnerId && guser.GetRoles().Max(x => x.Position) <= usr.GetRoles().Max(x => x.Position))
|
||||||
|
return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await usr.RemoveRolesAsync(role).ConfigureAwait(false);
|
await usr.RemoveRolesAsync(role).ConfigureAwait(false);
|
||||||
@ -135,6 +141,9 @@ namespace NadekoBot.Modules.Administration
|
|||||||
[RequireBotPermission(GuildPermission.ManageRoles)]
|
[RequireBotPermission(GuildPermission.ManageRoles)]
|
||||||
public async Task RenameRole(IRole roleToEdit, string newname)
|
public async Task RenameRole(IRole roleToEdit, string newname)
|
||||||
{
|
{
|
||||||
|
var guser = (IGuildUser)Context.User;
|
||||||
|
if (Context.User.Id != guser.Guild.OwnerId && guser.GetRoles().Max(x => x.Position) <= roleToEdit.Position)
|
||||||
|
return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (roleToEdit.Position > (await Context.Guild.GetCurrentUserAsync().ConfigureAwait(false)).GetRoles().Max(r => r.Position))
|
if (roleToEdit.Position > (await Context.Guild.GetCurrentUserAsync().ConfigureAwait(false)).GetRoles().Max(r => r.Position))
|
||||||
@ -157,9 +166,14 @@ namespace NadekoBot.Modules.Administration
|
|||||||
[RequireBotPermission(GuildPermission.ManageRoles)]
|
[RequireBotPermission(GuildPermission.ManageRoles)]
|
||||||
public async Task RemoveAllRoles([Remainder] IGuildUser user)
|
public async Task RemoveAllRoles([Remainder] IGuildUser user)
|
||||||
{
|
{
|
||||||
|
var guser = (IGuildUser)Context.User;
|
||||||
|
|
||||||
|
var userRoles = user.GetRoles();
|
||||||
|
if (guser.Id != Context.Guild.OwnerId && (user.Id == Context.Guild.OwnerId || guser.GetRoles().Max(x => x.Position) <= userRoles.Max(x => x.Position)))
|
||||||
|
return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await user.RemoveRolesAsync(user.GetRoles()).ConfigureAwait(false);
|
await user.RemoveRolesAsync(userRoles).ConfigureAwait(false);
|
||||||
await ReplyConfirmLocalized("rar", Format.Bold(user.ToString())).ConfigureAwait(false);
|
await ReplyConfirmLocalized("rar", Format.Bold(user.ToString())).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
27
src/NadekoBot/Resources/CommandStrings.Designer.cs
generated
27
src/NadekoBot/Resources/CommandStrings.Designer.cs
generated
@ -5378,6 +5378,33 @@ namespace NadekoBot.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to ping.
|
||||||
|
/// </summary>
|
||||||
|
public static string ping_cmd {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ping_cmd", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Ping the bot to see if there are latency issues..
|
||||||
|
/// </summary>
|
||||||
|
public static string ping_desc {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ping_desc", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to `{0}ping`.
|
||||||
|
/// </summary>
|
||||||
|
public static string ping_usage {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ping_usage", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to place.
|
/// Looks up a localized string similar to place.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user