Skip to content

Commit 9942c86

Browse files
committed
Add back the grant command
New implementation uses DiscordMemberFlags.BypassesVerification
1 parent 14e3ffe commit 9942c86

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

Commands/RoleCmds.cs

+27-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,34 @@ public class RoleCmds
66
[Description("Grant a user Tier 1, bypassing any verification requirements.")]
77
[AllowedProcessors(typeof(SlashCommandProcessor), typeof(TextCommandProcessor))]
88
[RequireHomeserverPerm(ServerPermLevel.TrialModerator), RequirePermissions(DiscordPermission.ModerateMembers)]
9-
public async Task Grant(CommandContext ctx, [Parameter("user"), Description("The user to grant Tier 1 to.")] DiscordUser _)
9+
public async Task Grant(CommandContext ctx, [Parameter("user"), Description("The user to grant Tier 1 to.")] DiscordUser user)
1010
{
11-
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} This command is deprecated and no longer works. Please right click (or tap and hold on mobile) the user and click \"Verify Member\" if available.");
11+
DiscordMember member = default;
12+
try
13+
{
14+
member = await ctx.Guild.GetMemberAsync(user.Id);
15+
}
16+
catch (Exception)
17+
{
18+
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} That user does not appear to be in the server!");
19+
return;
20+
}
21+
22+
if (!DiscordHelpers.AllowedToMod(await ctx.Guild.GetMemberAsync(ctx.Client.CurrentUser.Id), member))
23+
{
24+
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} I don't have permission to grant {member.Mention}! Check the role order.");
25+
return;
26+
}
27+
28+
if (member.MemberFlags.Value.HasFlag(DiscordMemberFlags.BypassesVerification))
29+
{
30+
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} {member.Mention} has already been allowed access to the server!");
31+
return;
32+
}
33+
34+
await member.ModifyAsync(x => x.MemberFlags = (DiscordMemberFlags)member.MemberFlags | DiscordMemberFlags.BypassesVerification);
35+
36+
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Success} {member.Mention} can now access the server!");
1237
}
1338

1439
[HomeServer]

0 commit comments

Comments
 (0)