Skip to content

Commit 164e767

Browse files
tqsunmute: Address PR feedback
Allow usage in #bot-commands (adds config.json value), move `else if` into `catch`
1 parent 0e91739 commit 164e767

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

Commands/MuteCmds.cs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -223,16 +223,17 @@ public async Task TqsMuteSlashCommand(
223223
return;
224224
}
225225

226-
// Only allow usage in #tech-support, #tech-support-forum, and their threads
226+
// Only allow usage in #tech-support, #tech-support-forum, and their threads + #bot-commands
227227
if (ctx.Channel.Id != Program.cfgjson.TechSupportChannel &&
228228
ctx.Channel.Id != Program.cfgjson.SupportForumId &&
229229
ctx.Channel.Parent.Id != Program.cfgjson.TechSupportChannel &&
230-
ctx.Channel.Parent.Id != Program.cfgjson.SupportForumId)
230+
ctx.Channel.Parent.Id != Program.cfgjson.SupportForumId &&
231+
ctx.Channel.Id != Program.cfgjson.BotCommandsChannel)
231232
{
232233
if (ctx is SlashCommandContext)
233234
await ctx.EditResponseAsync(new DiscordWebhookBuilder().WithContent($"{Program.cfgjson.Emoji.Error} This command can only be used in <#{Program.cfgjson.TechSupportChannel}>, <#{Program.cfgjson.SupportForumId}>, and threads in those channels!"));
234235
else
235-
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} This command can only be used in <#{Program.cfgjson.TechSupportChannel}>, <#{Program.cfgjson.SupportForumId}>, and threads in those channels!");
236+
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} This command can only be used in <#{Program.cfgjson.TechSupportChannel}>, <#{Program.cfgjson.SupportForumId}>, their threads, and <#{Program.cfgjson.BotCommandsChannel}>!");
236237
return;
237238
}
238239

@@ -248,7 +249,12 @@ public async Task TqsMuteSlashCommand(
248249
}
249250
catch (DSharpPlus.Exceptions.NotFoundException)
250251
{
251-
// handled below
252+
// couldn't fetch member, fail
253+
if (ctx is SlashCommandContext)
254+
await ctx.EditResponseAsync($"{Program.cfgjson.Emoji.Error} That user doesn't appear to be in the server!");
255+
else
256+
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} That user doesn't appear to be in the server!");
257+
return;
252258
}
253259

254260
if (await Program.db.HashExistsAsync("mutes", targetUser.Id) && targetMember is not null && targetMember.Roles.Contains(tqsMutedRole))
@@ -270,14 +276,6 @@ public async Task TqsMuteSlashCommand(
270276
else
271277
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Success} Successfully unmuted {targetUser.Mention}!");
272278
}
273-
else if (targetMember is null)
274-
{
275-
// couldn't fetch member, fail
276-
if (ctx is SlashCommandContext)
277-
await ctx.EditResponseAsync($"{Program.cfgjson.Emoji.Error} That user doesn't appear to be in the server!");
278-
else
279-
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} That user doesn't appear to be in the server!");
280-
}
281279
else
282280
{
283281
// member is not TQS-muted, fail

Structs.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,9 @@ public ulong InsidersChannel
336336

337337
[JsonProperty("githubWorkflowSucessString")]
338338
public string GithubWorkflowSucessString { get; private set; } = "";
339+
340+
[JsonProperty("botCommandsChannel")]
341+
public ulong BotCommandsChannel { get; private set; }
339342
}
340343

341344
public enum Level { Information, Warning, Error, Debug, Verbose }

config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,5 +348,6 @@
348348
450181490345508884
349349
],
350350
"pingBotOwnersOnBadErrors": true,
351-
"githubWorkflowSucessString": "[lists:main] 1 new commit"
351+
"githubWorkflowSucessString": "[lists:main] 1 new commit",
352+
"botCommandsChannel": 740272437719072808
352353
}

0 commit comments

Comments
 (0)