aboutsummaryrefslogtreecommitdiff
path: root/src/commands/info/links.ts
blob: b3d0292e06c3570f24a9e5f64f7ee56f769b20d6 (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
import { BotCommand, invite, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert/strict';
import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from 'discord.js';
import packageDotJSON from '../../../package.json' assert { type: 'json' };

assert(packageDotJSON);

export default class LinksCommand extends BotCommand {
	public constructor() {
		super('links', {
			aliases: ['links', 'invite', 'inv', 'support', 'github', 'source', 'oss'],
			category: 'info',
			description: 'Sends bot links',
			usage: ['links'],
			examples: ['links'],
			clientPermissions: [],
			userPermissions: [],
			slash: true
		});
	}

	public override async exec(message: CommandMessage | SlashMessage) {
		const buttonRow = new ActionRowBuilder<ButtonBuilder>();
		if (!this.client.config.isDevelopment || message.author.isOwner()) {
			buttonRow.addComponents(new ButtonBuilder({ style: ButtonStyle.Link, label: 'Invite Me', url: invite(this.client) }));
		}
		const supportInvite = this.client.config.supportGuild.invite;

		if (supportInvite) {
			buttonRow.addComponents(new ButtonBuilder({ style: ButtonStyle.Link, label: 'Support Server', url: supportInvite }));
		}

		buttonRow.addComponents(new ButtonBuilder({ style: ButtonStyle.Link, label: 'GitHub', url: packageDotJSON.repository }));

		buttonRow.addComponents(
			new ButtonBuilder({ style: ButtonStyle.Link, label: 'Privacy Policy', url: 'https://privacy.tanzanite.dev' })
		);
		return await message.util.reply({ content: 'Here are some useful links:', components: [buttonRow] });
	}
}