aboutsummaryrefslogtreecommitdiff
path: root/src/context-menu-commands/user/userInfo.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/context-menu-commands/user/userInfo.ts')
-rw-r--r--src/context-menu-commands/user/userInfo.ts28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/context-menu-commands/user/userInfo.ts b/src/context-menu-commands/user/userInfo.ts
index 6d7f3b6..283e4a0 100644
--- a/src/context-menu-commands/user/userInfo.ts
+++ b/src/context-menu-commands/user/userInfo.ts
@@ -1,27 +1,35 @@
import { UserInfoCommand } from '#commands';
-import { format } from '#lib';
-import { ContextMenuCommand } from 'discord-akairo';
-import { ApplicationCommandType, type ContextMenuCommandInteraction, type Guild } from 'discord.js';
+import { emojis } from '#lib';
+import { ContextMenuCommand } from '@notenoughupdates/discord-akairo';
+import assert from 'assert';
+import { ApplicationCommandType, GuildMember, UserContextMenuCommandInteraction } from 'discord.js';
export default class UserInfoContextMenuCommand extends ContextMenuCommand {
public constructor() {
super('userInfo', {
name: 'User Info',
type: ApplicationCommandType.User,
- category: 'user'
+ category: 'user',
+ dmPermission: false
});
}
- public override async exec(interaction: ContextMenuCommandInteraction) {
+ public override async exec(interaction: UserContextMenuCommandInteraction) {
+ if (!interaction.inCachedGuild())
+ return interaction.reply({
+ content: `${emojis.error} You can't use this command outside of a server.`,
+ ephemeral: true
+ });
+
await interaction.deferReply({ ephemeral: true });
- const user = await this.client.users.fetch(interaction.targetId).catch(() => null);
- if (!user) return interaction.reply(`⁉ I couldn't find that user`);
+ const user = interaction.targetUser;
+
+ const guild = interaction.guild ?? undefined;
- const guild = interaction.guild as Guild;
+ const member = interaction.targetMember ?? undefined;
- const member = await guild.members.fetch(interaction.targetId).catch(() => null);
- if (!member) return interaction.reply(`${format.input(user.tag)} doesn't appear to be a member of this server anymore.`);
+ assert(member instanceof GuildMember || member === undefined);
const userEmbed = await UserInfoCommand.makeUserInfoEmbed(user, member, guild);