/[sudobot]/trunk/src/commands/moderation/VerifyCommand.ts
ViewVC logotype

Contents of /trunk/src/commands/moderation/VerifyCommand.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 344 - (show annotations)
Mon Jul 29 17:29:40 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: application/typescript
File size: 2737 byte(s)
chore: eslint autofix
1 import { CommandInteraction, GuildMember, Message } 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 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26