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,27 +124,31 @@ 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.");
return;
}
// Hierarchy check
if ((msg.Author as SocketGuildUser).Hierarchy <= targetobj.Hierarchy)
{
// 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;
}
} }
// Bot check
if (targetobj.IsBot)
{
await SendUsageMessageAsync(msg.Channel, ":x: I will not do that. Please kick bots manually.");
return;
}
// Send out message // Send out message
var notifyTask = SendNotificationMessage(targetobj, reason); var notifyTask = SendNotificationMessage(targetobj, reason);
// 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