Skip to content

Commit

Permalink
Refuse to ban bots
Browse files Browse the repository at this point in the history
  • Loading branch information
Erisa committed Apr 20, 2024
1 parent 4c4fd99 commit 8700a1a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 7 additions & 0 deletions Commands/Bans.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ public async Task BanCmd(CommandContext ctx,
[Description("The user you wish to ban. Accepts many formats")] DiscordUser targetMember,
[RemainingText, Description("The time and reason for the ban. e.g. '14d trolling' NOTE: Add 'appeal' to the start of the reason to include an appeal link")] string timeAndReason = "No reason specified.")
{

if (targetMember.IsBot)
{
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} To prevent accidents, I won't ban bots. If you really need to do this, do it manually in Discord.");
return;
}

bool appealable = false;
bool timeParsed = false;

Expand Down
11 changes: 9 additions & 2 deletions Commands/InteractionCommands/BanInteractions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,21 @@ public async Task BanSlashCommand(InteractionContext ctx,
if (keepMessages)
messageDeleteDays = 0;

if (user.IsBot)
{
webhookOut.Content = $"{Program.cfgjson.Emoji.Error} To prevent accidents, I won't ban bots. If you really need to do this, do it manually in Discord.";
await ctx.EditResponseAsync(webhookOut);
return;
}

DiscordMember targetMember;

try
{
targetMember = await ctx.Guild.GetMemberAsync(user.Id);
if (GetPermLevel(ctx.Member) == ServerPermLevel.TrialModerator && (GetPermLevel(targetMember) >= ServerPermLevel.TrialModerator || targetMember.IsBot))
if (GetPermLevel(ctx.Member) == ServerPermLevel.TrialModerator && (GetPermLevel(targetMember) >= ServerPermLevel.TrialModerator))
{
webhookOut.Content = $"{Program.cfgjson.Emoji.Error} As a Trial Moderator you cannot perform moderation actions on other staff members or bots.";
webhookOut.Content = $"{Program.cfgjson.Emoji.Error} As a Trial Moderator you cannot perform moderation actions on other staff members.";
await ctx.EditResponseAsync(webhookOut);
return;
}
Expand Down

0 comments on commit 8700a1a

Please sign in to comment.