Skip to content

Commit

Permalink
Rewrite lockdown (#249)
Browse files Browse the repository at this point in the history
* Rewrite lockdown

* Remove boolean return values from lockdown helpers
  • Loading branch information
FloatingMilkshake authored Dec 16, 2024
1 parent 43176ea commit 50b1a0f
Show file tree
Hide file tree
Showing 2 changed files with 151 additions and 170 deletions.
20 changes: 14 additions & 6 deletions Commands/InteractionCommands/LockdownInteractions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,15 @@ await thread.ModifyAsync(a =>
return;
}

bool success = await LockdownHelpers.LockChannelAsync(user: ctx.User, channel: currentChannel, duration: lockDuration, reason: reason, lockThreads: lockThreads);
if (success)
try
{
await LockdownHelpers.LockChannelAsync(user: ctx.User, channel: currentChannel, duration: lockDuration, reason: reason, lockThreads: lockThreads);
await ctx.FollowUpAsync(new DiscordFollowupMessageBuilder().WithContent("Channel locked successfully.").AsEphemeral(true));
else
}
catch (ArgumentException)
{
await ctx.FollowUpAsync(new DiscordFollowupMessageBuilder().WithContent("Failed to lock this channel!").AsEphemeral(true));
}
}

[SlashCommand("all", "Lock all lockable channels in the server. See also: unlock all")]
Expand Down Expand Up @@ -123,11 +127,15 @@ public class UnlockCmds
await ctx.FollowUpAsync(new DiscordFollowupMessageBuilder().WithContent($"{Program.cfgjson.Emoji.Error} A mass lockdown or unlock is already ongoing. Refusing your request. sorry.").AsEphemeral(true));
return;
}
bool success = await LockdownHelpers.UnlockChannel(currentChannel, ctx.Member);
if (success)
try
{
await LockdownHelpers.UnlockChannel(currentChannel, ctx.Member);
await ctx.FollowUpAsync(new DiscordFollowupMessageBuilder().WithContent("Channel unlocked successfully.").AsEphemeral(true));
else
}
catch (ArgumentException)
{
await ctx.FollowUpAsync(new DiscordFollowupMessageBuilder().WithContent("Failed to unlock this channel!").AsEphemeral(true));
}
}

[SlashCommand("all", "Unlock all lockable channels in the server. See also: lockdown all")]
Expand Down
Loading

0 comments on commit 50b1a0f

Please sign in to comment.