|
2 | 2 | {
|
3 | 3 | public class LockdownHelpers
|
4 | 4 | {
|
5 |
| - public static async Task<bool> LockChannelAsync(DiscordUser user, DiscordChannel channel, TimeSpan? duration = null, string reason = "No reason specified.", bool lockThreads = false) |
| 5 | + public static async Task LockChannelAsync(DiscordUser user, DiscordChannel channel, TimeSpan? duration = null, string reason = "No reason specified.", bool lockThreads = false) |
6 | 6 | {
|
7 | 7 | if (!Program.cfgjson.LockdownEnabledChannels.Contains(channel.Id))
|
8 | 8 | {
|
9 |
| - return false; |
| 9 | + throw new ArgumentException($"Channel {channel.Id} is not in the lockdown whitelist."); |
10 | 10 | }
|
11 | 11 |
|
12 | 12 | // Get the permissions that are already on the channel, so that we can make sure they are kept when we adjust overwrites for lockdown
|
@@ -86,11 +86,15 @@ public static async Task<bool> LockChannelAsync(DiscordUser user, DiscordChannel
|
86 | 86 | }
|
87 | 87 |
|
88 | 88 | await channel.SendMessageAsync(msg);
|
89 |
| - return true; |
90 | 89 | }
|
91 | 90 |
|
92 |
| - public static async Task<bool> UnlockChannel(DiscordChannel discordChannel, DiscordMember discordMember, string reason = "No reason specified.", bool isMassUnlock = false) |
| 91 | + public static async Task UnlockChannel(DiscordChannel discordChannel, DiscordMember discordMember, string reason = "No reason specified.", bool isMassUnlock = false) |
93 | 92 | {
|
| 93 | + if (!Program.cfgjson.LockdownEnabledChannels.Contains(discordChannel.Id)) |
| 94 | + { |
| 95 | + throw new ArgumentException($"Channel {discordChannel.Id} is not in the lockdown whitelist."); |
| 96 | + } |
| 97 | + |
94 | 98 | // Get the permissions that are already on the channel, so that we can make sure they are kept when we adjust overwrites for the unlock
|
95 | 99 | var permissions = discordChannel.PermissionOverwrites.ToArray();
|
96 | 100 |
|
@@ -160,8 +164,6 @@ public static async Task<bool> UnlockChannel(DiscordChannel discordChannel, Disc
|
160 | 164 |
|
161 | 165 | await Program.db.HashDeleteAsync("unlocks", discordChannel.Id);
|
162 | 166 | await discordChannel.SendMessageAsync($"{Program.cfgjson.Emoji.Unlock} This channel has been unlocked!");
|
163 |
| - |
164 |
| - return true; |
165 | 167 | }
|
166 | 168 |
|
167 | 169 | }
|
|
0 commit comments