Skip to content

Commit

Permalink
Disallow TQS-mutes if the user is already muted
Browse files Browse the repository at this point in the history
  • Loading branch information
FloatingMilkshake committed Feb 22, 2024
1 parent 74df3e0 commit e32a103
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Commands/InteractionCommands/MuteInteractions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@ public async Task TqsMuteSlashCommand(
return;
}

// Check if the user is already muted; disallow TQS-mute if so

DiscordRole mutedRole = ctx.Guild.GetRole(Program.cfgjson.MutedRole);
DiscordRole tqsMutedRole = ctx.Guild.GetRole(Program.cfgjson.TqsMutedRole);

if (await Program.db.HashExistsAsync("mutes", targetUser.Id) || ctx.Member.Roles.Contains(mutedRole) || ctx.Member.Roles.Contains(tqsMutedRole))
{
await ctx.EditResponseAsync(new DiscordWebhookBuilder().WithContent($"{Program.cfgjson.Emoji.Error} {ctx.User.Mention}, that user is already muted."));
return;
}

// Get member
DiscordMember targetMember = default;
try
{
Expand All @@ -119,6 +131,7 @@ public async Task TqsMuteSlashCommand(
// blah
}

// Check if user to be muted is staff or TQS, and disallow if so
if (targetMember != default && GetPermLevel(ctx.Member) == ServerPermLevel.TechnicalQueriesSlayer && (GetPermLevel(targetMember) >= ServerPermLevel.TechnicalQueriesSlayer || targetMember.IsBot))
{
await ctx.EditResponseAsync(new DiscordWebhookBuilder().WithContent($"{Program.cfgjson.Emoji.Error} {ctx.User.Mention}, you cannot mute other TQS or staff members."));
Expand Down
13 changes: 13 additions & 0 deletions Commands/Mutes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ public async Task TqsMuteCmd(
return;
}

// Check if the user is already muted; disallow TQS-mute if so

DiscordRole mutedRole = ctx.Guild.GetRole(Program.cfgjson.MutedRole);
DiscordRole tqsMutedRole = ctx.Guild.GetRole(Program.cfgjson.TqsMutedRole);

if ((await Program.db.HashExistsAsync("mutes", targetUser.Id)) || (ctx.Member != default && (ctx.Member.Roles.Contains(mutedRole) || ctx.Member.Roles.Contains(tqsMutedRole))))
{
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} {ctx.User.Mention}, that user is already muted.");
return;
}

// Get member
DiscordMember targetMember = default;
try
{
Expand All @@ -123,6 +135,7 @@ public async Task TqsMuteCmd(
// blah
}

// Check if user to be muted is staff or TQS, and disallow if so
if (targetMember != default && GetPermLevel(ctx.Member) == ServerPermLevel.TechnicalQueriesSlayer && (GetPermLevel(targetMember) >= ServerPermLevel.TechnicalQueriesSlayer || targetMember.IsBot))
{
await ctx.Channel.SendMessageAsync($"{Program.cfgjson.Emoji.Error} {ctx.User.Mention}, you cannot mute other TQS or staff members.");
Expand Down

0 comments on commit e32a103

Please sign in to comment.