Skip to content

Commit

Permalink
+ban limit
Browse files Browse the repository at this point in the history
  • Loading branch information
RheaAyase committed Oct 14, 2024
1 parent 07dd084 commit 40ce5a0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Core
25 changes: 25 additions & 0 deletions Modules/Moderation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class Moderation: IModule
private const string MuteNotFoundString = "And who would you like me to ~~kill~~ _silence_?";
private const string InvalidArgumentsString = "Invalid arguments.\n";
private const string BanReasonTooLongString = "Mute, Kick & Ban reason has 512 characters limit.\n";
private const string BanExceedsLimit = "Trying to kick or ban too many.\n_(This is a limit configurable on the web config under the Moderation section)_\n";
private const string RoleNotFoundString = "The Muted role is not configured - head to <https://valkyrja.app/config>";

private ValkyrjaClient Client;
Expand Down Expand Up @@ -624,6 +625,13 @@ bool IsAuthorSpecific(IMessage m)
return;
}

if( e.Server.Config.BanLimit > 0 && mentionedUsers.Count > e.Server.Config.BanLimit && e.Command.Id.ToLower() != "kickmany" )
{
await e.SendReplySafe(BanExceedsLimit);
dbContext.Dispose();
return;
}

string response = "";
List<string> usernames = new List<string>();
StringBuilder infractions = new StringBuilder();
Expand Down Expand Up @@ -676,6 +684,11 @@ bool IsAuthorSpecific(IMessage m)
};
commands.Add(newCommand);

newCommand = newCommand.CreateCopy("kickMany");
newCommand.Description = "Kick many, exceeding the limits.";
newCommand.RequiredPermissions = PermissionType.ServerOwner;
commands.Add(newCommand);

// !ban
newCommand = new Command("ban");
newCommand.Type = CommandType.Standard;
Expand Down Expand Up @@ -755,6 +768,13 @@ bool IsAuthorSpecific(IMessage m)
return;
}

if( e.Server.Config.BanLimit > 0 && mentionedUsers.Count > e.Server.Config.BanLimit && e.Command.Id.ToLower() != "banmany" )
{
await e.SendReplySafe(BanExceedsLimit);
dbContext.Dispose();
return;
}

try
{
response = await Ban(e.Server, mentionedUsers, duration.Value, warning.ToString(), e.Message.Author as SocketGuildUser,
Expand Down Expand Up @@ -783,6 +803,11 @@ bool IsAuthorSpecific(IMessage m)
newCommand.Description = "Ban someone just like the usual, but do not log their user ID or #discrim.";
commands.Add(newCommand);

newCommand = newCommand.CreateCopy("banMany");
newCommand.Description = "Ban many, exceeding the limits.";
newCommand.RequiredPermissions = PermissionType.ServerOwner;
commands.Add(newCommand);

// !quickBan
newCommand = new Command("quickBan");
newCommand.Type = CommandType.Standard;
Expand Down

0 comments on commit 40ce5a0

Please sign in to comment.