Skip to content

Commit

Permalink
Add missing [RemainingText] to text cmd parameters, fix bugs in kick
Browse files Browse the repository at this point in the history
kick text cmd now deletes the invoking message and does not respond with "Done!"
  • Loading branch information
FloatingMilkshake committed Feb 2, 2025
1 parent 33741f7 commit f63c63c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Commands/BanCmds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public async Task BanSlashCommand(SlashCommandContext ctx,
[Description("Unbans a user who has been previously banned.")]
[AllowedProcessors(typeof(SlashCommandProcessor), typeof(TextCommandProcessor))]
[HomeServer, RequireHomeserverPerm(ServerPermLevel.Moderator), RequirePermissions(permissions: DiscordPermission.BanMembers)]
public async Task UnbanCmd(CommandContext ctx, [Description("The user to unban, usually a mention or ID")] DiscordUser targetUser, [Description("Used in audit log only currently")] string reason = "No reason specified.")
public async Task UnbanCmd(CommandContext ctx, [Description("The user to unban, usually a mention or ID")] DiscordUser targetUser, [RemainingText, Description("Used in audit log only currently")] string reason = "No reason specified.")
{
if ((await Program.db.HashExistsAsync("bans", targetUser.Id)))
{
Expand Down
8 changes: 6 additions & 2 deletions Commands/KickCmds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ public class KickCmds
[Description("Kicks a user, removing them from the server until they rejoin.")]
[AllowedProcessors(typeof(SlashCommandProcessor), typeof(TextCommandProcessor))]
[RequireHomeserverPerm(ServerPermLevel.Moderator), RequirePermissions(DiscordPermission.KickMembers)]
public async Task KickCmd(CommandContext ctx, [Parameter("user"), Description("The user you want to kick from the server.")] DiscordUser target, [Parameter("reason"), Description("The reason for kicking this user.")] string reason = "No reason specified.")
public async Task KickCmd(CommandContext ctx, [Parameter("user"), Description("The user you want to kick from the server.")] DiscordUser target, [Parameter("reason"), Description("The reason for kicking this user."), RemainingText] string reason = "No reason specified.")
{
if (target.IsBot)
{
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} To prevent accidents, I won't kick bots. If you really need to do this, do it manually in Discord.");
return;
}

if (ctx is TextCommandContext)
await ctx.As<TextCommandContext>().Message.DeleteAsync();

reason = reason.Replace("`", "\\`").Replace("*", "\\*");

Expand All @@ -34,7 +37,8 @@ public class KickCmds
{
await KickAndLogAsync(member, reason, ctx.Member);
await ctx.Channel.SendMessageAsync($"{Program.cfgjson.Emoji.Ejected} {target.Mention} has been kicked: **{reason}**");
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Success} Done!", ephemeral: true);
if (ctx is SlashCommandContext)
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Success} Done!", ephemeral: true);
return;
}
else
Expand Down

0 comments on commit f63c63c

Please sign in to comment.