Skip to content

Commit 50b1a0f

Browse files
Rewrite lockdown (#249)
* Rewrite lockdown * Remove boolean return values from lockdown helpers
1 parent 43176ea commit 50b1a0f

File tree

2 files changed

+151
-170
lines changed

2 files changed

+151
-170
lines changed

Commands/InteractionCommands/LockdownInteractions.cs

+14-6
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,15 @@ await thread.ModifyAsync(a =>
5757
return;
5858
}
5959

60-
bool success = await LockdownHelpers.LockChannelAsync(user: ctx.User, channel: currentChannel, duration: lockDuration, reason: reason, lockThreads: lockThreads);
61-
if (success)
60+
try
61+
{
62+
await LockdownHelpers.LockChannelAsync(user: ctx.User, channel: currentChannel, duration: lockDuration, reason: reason, lockThreads: lockThreads);
6263
await ctx.FollowUpAsync(new DiscordFollowupMessageBuilder().WithContent("Channel locked successfully.").AsEphemeral(true));
63-
else
64+
}
65+
catch (ArgumentException)
66+
{
6467
await ctx.FollowUpAsync(new DiscordFollowupMessageBuilder().WithContent("Failed to lock this channel!").AsEphemeral(true));
68+
}
6569
}
6670

6771
[SlashCommand("all", "Lock all lockable channels in the server. See also: unlock all")]
@@ -123,11 +127,15 @@ public class UnlockCmds
123127
await ctx.FollowUpAsync(new DiscordFollowupMessageBuilder().WithContent($"{Program.cfgjson.Emoji.Error} A mass lockdown or unlock is already ongoing. Refusing your request. sorry.").AsEphemeral(true));
124128
return;
125129
}
126-
bool success = await LockdownHelpers.UnlockChannel(currentChannel, ctx.Member);
127-
if (success)
130+
try
131+
{
132+
await LockdownHelpers.UnlockChannel(currentChannel, ctx.Member);
128133
await ctx.FollowUpAsync(new DiscordFollowupMessageBuilder().WithContent("Channel unlocked successfully.").AsEphemeral(true));
129-
else
134+
}
135+
catch (ArgumentException)
136+
{
130137
await ctx.FollowUpAsync(new DiscordFollowupMessageBuilder().WithContent("Failed to unlock this channel!").AsEphemeral(true));
138+
}
131139
}
132140

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

0 commit comments

Comments
 (0)