Fix arbitrary ID banning not working under certain conditions

This commit is contained in:
Noi 2021-09-30 13:47:25 -07:00
parent f16628a44e
commit affaf88425

View file

@ -124,18 +124,22 @@ namespace Noikoio.RegexBot.Module.ModCommands.Commands
return; return;
} }
// Hierarchy check // Checks for existing (found) users:
if ((msg.Author as SocketGuildUser).Hierarchy <= targetobj.Hierarchy) if (targetobj != null)
{ {
// Block kick attempts if the invoking user is at or above the target in role hierarchy // Bot check
await SendUsageMessageAsync(msg.Channel, ":x: You are not allowed to kick this user."); if (targetobj.IsBot)
return; {
} await SendUsageMessageAsync(msg.Channel, ":x: I will not do that. Please kick bots manually.");
// Bot check return;
if (targetobj.IsBot) }
{ // Hierarchy check
await SendUsageMessageAsync(msg.Channel, ":x: I will not do that. Please kick bots manually."); if ((msg.Author as SocketGuildUser).Hierarchy <= targetobj.Hierarchy)
return; {
// Block kick attempts if the invoking user is at or above the target in role hierarchy
await SendUsageMessageAsync(msg.Channel, ":x: You are not allowed to kick this user.");
return;
}
} }
// Send out message // Send out message
@ -144,7 +148,7 @@ namespace Noikoio.RegexBot.Module.ModCommands.Commands
// Do the action // Do the action
try try
{ {
string reasonlog = $"Invoked by {msg.Author.ToString()}."; string reasonlog = $"Invoked by {msg.Author}.";
if (reason != null) reasonlog += $" Reason: {reason}"; if (reason != null) reasonlog += $" Reason: {reason}";
await notifyTask; await notifyTask;
#if !DEBUG #if !DEBUG