1 |
import { BanOptions, CommandInteraction, EmojiIdentifierResolvable, GuildMember, Interaction, Message, TextChannel, User } from 'discord.js'; |
2 |
import BaseCommand from '../../utils/structures/BaseCommand'; |
3 |
import DiscordClient from '../../client/Client'; |
4 |
import CommandOptions from '../../types/CommandOptions'; |
5 |
import InteractionOptions from '../../types/InteractionOptions'; |
6 |
import MessageEmbed from '../../client/MessageEmbed'; |
7 |
import getMember from '../../utils/getMember'; |
8 |
|
9 |
export default class VerifyCommand extends BaseCommand { |
10 |
supportsInteractions: boolean = true; |
11 |
|
12 |
constructor() { |
13 |
super('verify', 'moderation', []); |
14 |
} |
15 |
|
16 |
async run(client: DiscordClient, msg: Message | CommandInteraction, options: CommandOptions | InteractionOptions) { |
17 |
if (!options.isInteraction && typeof options.args[0] === 'undefined') { |
18 |
await msg.reply({ |
19 |
embeds: [ |
20 |
new MessageEmbed() |
21 |
.setColor('#f14a60') |
22 |
.setDescription(`This command requires at least one argument.`) |
23 |
] |
24 |
}); |
25 |
|
26 |
return; |
27 |
} |
28 |
|
29 |
let member: GuildMember | null | undefined; |
30 |
|
31 |
if (options.isInteraction) { |
32 |
member = <GuildMember> await options.options.getMember('user'); |
33 |
|
34 |
if (!member) { |
35 |
await msg.reply({ |
36 |
content: 'Invalid member given.' |
37 |
}); |
38 |
|
39 |
return; |
40 |
} |
41 |
} |
42 |
else { |
43 |
try { |
44 |
member = await getMember(msg as Message, options); |
45 |
|
46 |
if (!member) |
47 |
throw new Error(); |
48 |
} |
49 |
catch (e) { |
50 |
console.log(e); |
51 |
|
52 |
await msg.reply({ |
53 |
content: 'Invalid member given.' |
54 |
}); |
55 |
|
56 |
return; |
57 |
} |
58 |
} |
59 |
|
60 |
if (member.roles.cache.has(client.config.props[member.guild.id].mod_role)) { |
61 |
await msg.reply(`Cannot enforce verification to a moderator.`); |
62 |
return; |
63 |
} |
64 |
|
65 |
// if (member.roles.cache.has(client.config.props[member.guild.id].verification.role)) { |
66 |
// await msg.reply(`Verification is already enforced to this user.`); |
67 |
// return; |
68 |
// } |
69 |
|
70 |
await client.verification.start(member); |
71 |
|
72 |
await msg.reply({ |
73 |
embeds: [ |
74 |
new MessageEmbed({ |
75 |
author: { |
76 |
name: member.user.tag, |
77 |
iconURL: member.displayAvatarURL() |
78 |
}, |
79 |
description: `Verfication has been enforced to this user. They won't be able to access channels or talk unless they verify themselves.` |
80 |
}) |
81 |
] |
82 |
}); |
83 |
} |
84 |
} |