/[sudobot]/branches/2.x/src/commands/settings/WelcomeMsgCommand.ts
ViewVC logotype

Annotation of /branches/2.x/src/commands/settings/WelcomeMsgCommand.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 577 - (hide annotations)
Mon Jul 29 18:52:37 2024 UTC (8 months ago) by rakinar2
File MIME type: application/typescript
File size: 3802 byte(s)
chore: add old version archive branches (2.x to 9.x-dev)
1 rakinar2 577 import { CommandInteraction, GuildMember, Interaction, 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 { emoji } from '../../utils/Emoji';
8    
9     export default class WelcomeMsgCommand extends BaseCommand {
10     constructor() {
11     super('welcomemsg', 'settings', ['welcomer']);
12     }
13    
14     async run(client: DiscordClient, message: Message, options: CommandOptions) {
15     if (options.args[0] === undefined) {
16     await message.reply(`${emoji('error')} This command requires at least one argument or option.`);
17     return;
18     }
19    
20     if (options.options.includes('--enable')) {
21     client.config.props[message.guild!.id].welcomer.enabled = true;
22     await message.reply(`${emoji('check')} Welcomer has been enabled.`);
23     }
24     else if (options.options.includes('--disable')) {
25     client.config.props[message.guild!.id].welcomer.enabled = false;
26     await message.reply(`${emoji('check')} Welcomer has been disabled.`);
27     }
28     else if (options.options.includes('--toggle')) {
29     client.config.props[message.guild!.id].welcomer.enabled = !client.config.props[message.guild!.id].welcomer.enabled;
30     await message.reply(`${emoji('check')} Welcomer has been ${client.config.props[message.guild!.id].welcomer.enabled ? 'enabled' : 'disabled'}.`);
31     }
32     else if (options.options.includes('--msg') || options.options.includes('--message') || options.options.includes('--custom')) {
33     let msg = options.args.filter(a => a !== '--msg' && a !== '--message' && a !== '--custom').join(' ');
34    
35     if (msg.trim() === '') {
36     client.config.props[message.guild!.id].welcomer.message = null;
37     await message.reply(`${emoji('check')} Welcome message was successfully removed.`);
38     }
39     else {
40     client.config.props[message.guild!.id].welcomer.message = msg;
41     await message.reply(`${emoji('check')} Welcome message was successfully set.`);
42     }
43     }
44     else if (options.options.includes('--rm-msg') || options.options.includes('--remove-message')) {
45     client.config.props[message.guild!.id].welcomer.message = null;
46     await message.reply(`${emoji('check')} Welcome message was successfully removed.`);
47     }
48     else if (options.options.includes('--randomize') || options.options.includes('--rand')) {
49     client.config.props[message.guild!.id].welcomer.randomize = !client.config.props[message.guild!.id].welcomer.randomize;
50     await message.reply(`${emoji('check')} Welcomer random messages are ${client.config.props[message.guild!.id].welcomer.randomize ? 'enabled' : 'disabled'}.${client.config.props[message.guild!.id].welcomer.message && client.config.props[message.guild!.id].welcomer.randomize ? '\nNote: A custom welcome message is already set. Both random and custom messages will be shown.' : ''}`);
51     }
52     else if (options.options.includes('--preview')) {
53     const options = client.welcomer.generateEmbed(message.member!);
54    
55     if (!options) {
56     await message.reply(`${emoji('error')} No welcome message set and randomization is disabled. Please configure one of those first!`);
57     return;
58     }
59    
60     await message.channel.send(options);
61     }
62     else {
63     await message.reply(`${emoji('error')} Invalid argument(s) or option(s) supplied.`);
64     return;
65     }
66     }
67     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26