aboutsummaryrefslogtreecommitdiff
path: root/src/context-menu-commands/user/modlog.ts
blob: bdb311f79bd5376536f924732ee2bd6c706f60f4 (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
import { ModlogCommand } from '#commands';
import { SlashMessage } from '#lib';
import { CommandUtil, ContextMenuCommand } from 'discord-akairo';
import { ApplicationCommandType, type ContextMenuCommandInteraction } from 'discord.js';

export default class ModlogContextMenuCommand extends ContextMenuCommand {
	public constructor() {
		super('modlog', {
			name: "Users's Modlogs",
			type: ApplicationCommandType.User,
			category: 'user'
		});
	}

	public override async exec(interaction: ContextMenuCommandInteraction) {
		if (!interaction.inCachedGuild())
			return interaction.reply({
				content: `${util.emojis.error} You can't use this command outside of a server.`,
				ephemeral: true
			});
		if (!interaction.member?.permissions.has('ManageMessages'))
			return interaction.reply({
				content: `${util.emojis.error} You can't use this command because you have the **Manage Messages** permission.`,
				ephemeral: true
			});

		await interaction.deferReply({ ephemeral: true });
		const pseudoMessage = new SlashMessage(client, interaction as any);
		pseudoMessage.util = new CommandUtil(client.commandHandler, pseudoMessage);

		void new ModlogCommand().exec(pseudoMessage, { search: interaction.targetId, hidden: false });
	}
}