Skip to content

Commit b1312c7

Browse files
committed
add insider interactions and tqsmute to microsoft commands
1 parent 6573f1f commit b1312c7

File tree

3 files changed

+166
-165
lines changed

3 files changed

+166
-165
lines changed

Commands/MuteCmds.cs

Lines changed: 0 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -77,170 +77,6 @@ public async Task MuteSlashCommand(
7777
await ctx.EditResponseAsync(new DiscordWebhookBuilder().WithContent("Command completed successfully."));
7878
}
7979

80-
[Command("tqsmute")]
81-
[Description("Temporarily mute a user in tech support channels.")]
82-
[AllowedProcessors(typeof(SlashCommandProcessor), typeof(TextCommandProcessor))]
83-
[RequireHomeserverPerm(ServerPermLevel.TechnicalQueriesSlayer)]
84-
public async Task TqsMuteSlashCommand(
85-
CommandContext ctx,
86-
[Parameter("user"), Description("The user to mute.")] DiscordUser targetUser,
87-
[Parameter("reason"), Description("The reason for the mute.")] string reason)
88-
{
89-
if (ctx is SlashCommandContext)
90-
await ctx.As<SlashCommandContext>().DeferResponseAsync(ephemeral: true);
91-
else
92-
await ctx.As<TextCommandContext>().Message.DeleteAsync();
93-
94-
// only work if TQS mute role is configured
95-
if (Program.cfgjson.TqsMutedRole == 0)
96-
{
97-
if (ctx is SlashCommandContext)
98-
await ctx.EditResponseAsync(new DiscordWebhookBuilder().WithContent($"{Program.cfgjson.Emoji.Error} TQS mutes are not configured, so this command does nothing. Please contact the bot maintainer if this is unexpected."));
99-
else
100-
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} TQS mutes are not configured, so this command does nothing. Please contact the bot maintainer if this is unexpected.");
101-
return;
102-
}
103-
104-
// Only allow usage in #tech-support, #tech-support-forum, and their threads + #bot-commands
105-
if (ctx.Channel.Id != Program.cfgjson.TechSupportChannel &&
106-
ctx.Channel.Id != Program.cfgjson.SupportForumId &&
107-
ctx.Channel.Parent.Id != Program.cfgjson.TechSupportChannel &&
108-
ctx.Channel.Parent.Id != Program.cfgjson.SupportForumId &&
109-
ctx.Channel.Id != Program.cfgjson.BotCommandsChannel)
110-
{
111-
if (ctx is SlashCommandContext)
112-
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!"));
113-
else
114-
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!");
115-
return;
116-
}
117-
118-
// Check if the user is already muted; disallow TQS-mute if so
119-
120-
DiscordRole mutedRole = await ctx.Guild.GetRoleAsync(Program.cfgjson.MutedRole);
121-
DiscordRole tqsMutedRole = await ctx.Guild.GetRoleAsync(Program.cfgjson.TqsMutedRole);
122-
123-
// Get member
124-
DiscordMember targetMember = default;
125-
try
126-
{
127-
targetMember = await ctx.Guild.GetMemberAsync(targetUser.Id);
128-
}
129-
catch (DSharpPlus.Exceptions.NotFoundException)
130-
{
131-
// blah
132-
}
133-
134-
if (await Program.redis.HashExistsAsync("mutes", targetUser.Id) || (targetMember is not null && (targetMember.Roles.Contains(mutedRole) || targetMember.Roles.Contains(tqsMutedRole))))
135-
{
136-
if (ctx is SlashCommandContext)
137-
await ctx.EditResponseAsync(new DiscordWebhookBuilder().WithContent($"{Program.cfgjson.Emoji.Error} {ctx.User.Mention}, that user is already muted."));
138-
else
139-
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} {ctx.User.Mention}, that user is already muted.");
140-
return;
141-
}
142-
143-
// Check if user to be muted is staff or TQS, and disallow if so
144-
if (targetMember != default && (await GetPermLevelAsync(ctx.Member)) == ServerPermLevel.TechnicalQueriesSlayer && ((await GetPermLevelAsync(targetMember)) >= ServerPermLevel.TechnicalQueriesSlayer || targetMember.IsBot))
145-
{
146-
if (ctx is SlashCommandContext)
147-
await ctx.EditResponseAsync(new DiscordWebhookBuilder().WithContent($"{Program.cfgjson.Emoji.Error} {ctx.User.Mention}, you cannot mute other TQS or staff members."));
148-
else
149-
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} {ctx.User.Mention}, you cannot mute other TQS or staff members.");
150-
return;
151-
}
152-
153-
// mute duration is static for TQS mutes
154-
TimeSpan muteDuration = TimeSpan.FromHours(Program.cfgjson.TqsMuteDurationHours);
155-
156-
await MuteHelpers.MuteUserAsync(targetUser, reason, ctx.User.Id, ctx.Guild, ctx.Channel, muteDuration, true, true);
157-
if (ctx is SlashCommandContext)
158-
await ctx.EditResponseAsync(new DiscordWebhookBuilder().WithContent("Done. Please open a modmail thread for this user if you haven't already!"));
159-
}
160-
161-
[Command("tqsunmute")]
162-
[TextAlias("tqs-unmute", "untqsmute")]
163-
[Description("Removes a TQS Mute from a previously TQS-muted user. See also: tqsmute")]
164-
[AllowedProcessors(typeof(TextCommandProcessor), typeof(SlashCommandProcessor))]
165-
[HomeServer, RequireHomeserverPerm(ServerPermLevel.TechnicalQueriesSlayer)]
166-
public async Task TqsUnmuteCmd(CommandContext ctx, [Parameter("user"), Description("The user you're trying to unmute.")] DiscordUser targetUser, [Description("The reason for the unmute.")] string reason)
167-
{
168-
if (ctx is SlashCommandContext)
169-
await ctx.As<SlashCommandContext>().DeferResponseAsync();
170-
171-
// only work if TQS mute role is configured
172-
if (Program.cfgjson.TqsMutedRole == 0)
173-
{
174-
if (ctx is SlashCommandContext)
175-
await ctx.EditResponseAsync(new DiscordWebhookBuilder().WithContent($"{Program.cfgjson.Emoji.Error} TQS mutes are not configured, so this command does nothing. Please contact the bot maintainer if this is unexpected."));
176-
else
177-
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} TQS mutes are not configured, so this command does nothing. Please contact the bot maintainer if this is unexpected.");
178-
return;
179-
}
180-
181-
// Only allow usage in #tech-support, #tech-support-forum, and their threads + #bot-commands
182-
if (ctx.Channel.Id != Program.cfgjson.TechSupportChannel &&
183-
ctx.Channel.Id != Program.cfgjson.SupportForumId &&
184-
ctx.Channel.Parent.Id != Program.cfgjson.TechSupportChannel &&
185-
ctx.Channel.Parent.Id != Program.cfgjson.SupportForumId &&
186-
ctx.Channel.Id != Program.cfgjson.BotCommandsChannel)
187-
{
188-
if (ctx is SlashCommandContext)
189-
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!"));
190-
else
191-
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}>!");
192-
return;
193-
}
194-
195-
// Get muted roles
196-
DiscordRole mutedRole = await ctx.Guild.GetRoleAsync(Program.cfgjson.MutedRole);
197-
DiscordRole tqsMutedRole = await ctx.Guild.GetRoleAsync(Program.cfgjson.TqsMutedRole);
198-
199-
// Get member
200-
DiscordMember targetMember = default;
201-
try
202-
{
203-
targetMember = await ctx.Guild.GetMemberAsync(targetUser.Id);
204-
}
205-
catch (DSharpPlus.Exceptions.NotFoundException)
206-
{
207-
// couldn't fetch member, fail
208-
if (ctx is SlashCommandContext)
209-
await ctx.EditResponseAsync($"{Program.cfgjson.Emoji.Error} That user doesn't appear to be in the server!");
210-
else
211-
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} That user doesn't appear to be in the server!");
212-
return;
213-
}
214-
215-
if (await Program.redis.HashExistsAsync("mutes", targetUser.Id) && targetMember is not null && targetMember.Roles.Contains(tqsMutedRole))
216-
{
217-
// If the member has a regular mute, leave the TQS mute alone (it's only a role now & it has no effect if they also have Muted); it will be removed when they are unmuted
218-
if (targetMember.Roles.Contains(mutedRole))
219-
{
220-
if (ctx is SlashCommandContext)
221-
await ctx.EditResponseAsync($"{Program.cfgjson.Emoji.Error} {targetUser.Mention} has been muted by a Moderator! Their TQS Mute will be removed when the Moderator-issued mute expires.");
222-
else
223-
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} {targetUser.Mention} has been muted by a Moderator! Their TQS Mute will be removed when the Moderator-issued mute expires.");
224-
return;
225-
}
226-
227-
// user is TQS-muted; unmute
228-
await MuteHelpers.UnmuteUserAsync(targetUser, reason, true, ctx.User, true);
229-
if (ctx is SlashCommandContext)
230-
await ctx.EditResponseAsync($"{Program.cfgjson.Emoji.Success} Successfully unmuted {targetUser.Mention}!");
231-
else
232-
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Success} Successfully unmuted {targetUser.Mention}!");
233-
}
234-
else
235-
{
236-
// member is not TQS-muted, fail
237-
if (ctx is SlashCommandContext)
238-
await ctx.EditResponseAsync($"{Program.cfgjson.Emoji.Error} That user doesn't appear to be TQS-muted!");
239-
else
240-
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} That user doesn't appear to be TQS-muted!");
241-
}
242-
}
243-
24480
[Command("muteinfo")]
24581
[Description("Show information about the mute for a user.")]
24682
[AllowedProcessors(typeof(SlashCommandProcessor))]

0 commit comments

Comments
 (0)