aboutsummaryrefslogtreecommitdiff
path: root/src/commands/info/pronouns.ts
blob: b45f9b3c2b1326c190f7a2c7f16c9b29e1a5ca1e (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
import { AllowedMentions, BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
import { ApplicationCommandOptionType, EmbedBuilder, PermissionFlagsBits } from 'discord.js';

export default class PronounsCommand extends BushCommand {
	public constructor() {
		super('pronouns', {
			aliases: ['pronouns', 'pronoun'],
			category: 'info',
			description: 'Finds the pronouns of a user using https://pronoundb.org.',
			usage: ['pronouns <user>'],
			examples: ['pronouns IRONM00N'],
			args: [
				{
					id: 'user',
					description: 'The user to get pronouns for.',
					type: 'globalUser',
					prompt: 'Who would you like to view the pronouns of?',
					retry: '{error} Choose a valid user to view the pronouns of.',
					optional: true,
					slashType: ApplicationCommandOptionType.User
				}
			],
			clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true),
			userPermissions: [],
			slash: true
		});
	}

	public override async exec(message: BushMessage | BushSlashMessage, args: { user?: ArgType<'globalUser'> }) {
		const user = args.user ?? message.author;
		const author = user.id === message.author.id;

		if (message.util.isSlashMessage(message)) await message.interaction.deferReply();

		const pronouns = await util.getPronounsOf(user);
		if (!pronouns) {
			return await message.util.reply({
				content: `${
					author ? 'You do' : `${util.discord.escapeMarkdown(user.tag)} does`
				} not appear to have any pronouns set. Please${author ? '' : ' tell them to'} go to https://pronoundb.org/ and set ${
					author ? 'your' : 'their'
				} pronouns.`,
				allowedMentions: AllowedMentions.none()
			});
		} else {
			return await message.util.reply({
				embeds: [
					new EmbedBuilder({
						title: `${author ? 'Your' : `${util.discord.escapeMarkdown(user.tag)}'s`} pronouns:`,
						description: pronouns,
						footer: {
							text: 'Data provided by https://pronoundb.org/'
						}
					})
				]
			});
		}
	}
}