aboutsummaryrefslogtreecommitdiff
path: root/src/commands/dev/test.ts
blob: b53b2d8907e3cd3121f2612e290df049821e3cd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import { BushCommand, ButtonPaginator, Shared, type BushMessage } from '#lib';
import {
	ActionRow,
	ActionRowComponent,
	ButtonComponent,
	ButtonStyle,
	Embed,
	type ApplicationCommand,
	type Collection
} from 'discord.js';
import badLinksSecretArray from '../../lib/badlinks-secret.js';
import badLinksArray from '../../lib/badlinks.js';
import badWords from '../../lib/badwords.js';

export default class TestCommand extends BushCommand {
	public constructor() {
		super('test', {
			aliases: ['test'],
			category: 'dev',
			description: 'A command to test stuff.',
			usage: ['test [feature]'],
			examples: ['test lots of buttons', 'test buttons'],
			args: [
				{
					id: 'feature',
					description: 'The feature to test.',
					match: 'rest',
					prompt: 'start prompt',
					retry: 'retry prompt',
					optional: true,
					slashType: false
				}
			],
			superUserOnly: true,
			clientPermissions: (m) => util.clientSendAndPermCheck(m),
			userPermissions: []
		});
	}

	public override async exec(message: BushMessage, args: { feature: string }) {
		const responses = [
			'Yes master.',
			'Test it your self bitch, I am hungry.',
			'Give me a break.',
			'I am not your slave.',
			'I have done as you wished, now please feed me.',
			`Someone help me I am trapped in ${message.author.username}'s basement.`
		];
		if (!message.author.isOwner()) {
			return await message.util.reply(responses[Math.floor(Math.random() * responses.length)]);
		}

		if (['button', 'buttons'].includes(args?.feature?.toLowerCase())) {
			const ButtonRow = new ActionRow().addComponents(
				new ButtonComponent().setStyle(ButtonStyle.Primary).setCustomId('primaryButton').setLabel('Primary'),
				new ButtonComponent().setStyle(ButtonStyle.Secondary).setCustomId('secondaryButton').setLabel('Secondary'),
				new ButtonComponent().setStyle(ButtonStyle.Success).setCustomId('successButton').setLabel('Success'),
				new ButtonComponent().setStyle(ButtonStyle.Danger).setCustomId('dangerButton').setLabel('Danger'),
				new ButtonComponent().setStyle(ButtonStyle.Link).setLabel('Link').setURL('https://www.youtube.com/watch?v=dQw4w9WgXcQ')
			);
			return await message.util.reply({ content: 'buttons', components: [ButtonRow] });
		} else if (['embed', 'button embed'].includes(args?.feature?.toLowerCase())) {
			const embed = new Embed()
				.addField({ name: 'Field Name', value: 'Field Content' })
				.setAuthor({ name: 'Author', iconURL: 'https://www.w3schools.com/w3css/img_snowtops.jpg', url: 'https://google.com/' })
				.setColor(message.member?.displayColor ?? util.colors.default)
				.setDescription('Description')
				.setFooter({ text: 'Footer', iconURL: message.author.avatarURL() ?? undefined })
				.setURL('https://duckduckgo.com/')
				.setTimestamp()
				.setImage('https://media.sproutsocial.com/uploads/2017/02/10x-featured-social-media-image-size.png')
				.setThumbnail(
					'https://images.unsplash.com/photo-1501183007986-d0d080b147f9?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2134&q=80'
				)
				.setTitle('Title');

			const buttonRow = new ActionRow().addComponents(
				new ButtonComponent().setStyle(ButtonStyle.Link).setLabel('Link').setURL('https://google.com/')
			);
			return await message.util.reply({ content: 'Test', embeds: [embed], components: [buttonRow] });
		} else if (['lots of buttons'].includes(args?.feature?.toLowerCase())) {
			const ButtonRows: ActionRow<ActionRowComponent>[] = [];
			for (let a = 1; a <= 5; a++) {
				const row = new ActionRow();
				for (let b = 1; b <= 5; b++) {
					const id = (a + 5 * (b - 1)).toString();
					const button = new ButtonComponent().setStyle(ButtonStyle.Primary).setCustomId(id).setLabel(id);
					row.addComponents(button);
				}
				ButtonRows.push(row);
			}
			return await message.util.reply({ content: 'buttons', components: ButtonRows });
		} else if (['paginate'].includes(args?.feature?.toLowerCase())) {
			const embeds = [];
			for (let i = 1; i <= 5; i++) {
				embeds.push(new Embed().setDescription(i.toString()));
			}
			return await ButtonPaginator.send(message, embeds);
		} else if (['lots of embeds'].includes(args?.feature?.toLowerCase())) {
			const description = 'This is a description.';
			const _avatar = message.author.avatarURL() ?? undefined;
			const author = { name: 'This is a author', iconURL: _avatar };
			const footer = { text: 'This is a footer', iconURL: _avatar };
			const fields = Array(25)
				.fill(0)
				.map((_, i) => ({ name: `Field ${i}`, value: 'Field Value' }));
			const c = util.colors;
			const o = { description, author, footer, fields, time: Date.now() };

			const colors = [c.red, c.orange, c.gold, c.yellow, c.green, c.darkGreen, c.aqua, c.blue, c.purple, c.pink];

			const embeds = colors.map((c, i) => ({ ...o, title: `Embed Title ${i}`, color: c }));

			const ButtonRows: ActionRow<ActionRowComponent>[] = [];
			for (let a = 1; a <= 5; a++) {
				const row = new ActionRow();
				for (let b = 1; b <= 5; b++) {
					const id = (a + 5 * (b - 1)).toString();
					const button = new ButtonComponent().setStyle(ButtonStyle.Secondary).setCustomId(id).setLabel(id);
					row.addComponents(button);
				}
				ButtonRows.push(row);
			}
			return await message.util.reply({ content: 'this is content', components: ButtonRows, embeds });
		} else if (['delete slash commands'].includes(args?.feature?.toLowerCase())) {
			if (!message.guild) return await message.util.reply(`${util.emojis.error} This test can only be run in a guild.`);
			await client.guilds.fetch();
			const promises: Promise<Collection<string, ApplicationCommand>>[] = [];
			client.guilds.cache.each((guild) => {
				promises.push(guild.commands.set([]));
			});
			await Promise.all(promises);

			await client.application!.commands.fetch();
			await client.application!.commands.set([]);

			return await message.util.reply(`${util.emojis.success} Removed guild commands and global commands.`);
		} else if (['drop down', 'drop downs', 'select menu', 'select menus'].includes(args?.feature?.toLowerCase())) {
		} else if (['sync automod'].includes(args?.feature?.toLowerCase())) {
			const row = (await Shared.findByPk(0))!;
			row.badLinks = badLinksArray;
			row.badLinksSecret = badLinksSecretArray;
			row.badWords = badWords;
			await row.save();
			return await message.util.reply(`${util.emojis.success} Synced automod.`);
		}
		return await message.util.reply(responses[Math.floor(Math.random() * responses.length)]);
	}
}