diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-10-03 22:57:40 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-10-03 22:57:40 -0400 |
commit | 612ed820a0600ec11ed642005377cd7f5a8a8b77 (patch) | |
tree | 6bca4e7268fd0063ff53cf64fa44df62a23dba50 /src/context-menu-commands | |
parent | ed98ff7e2679f362f2657e77a6cf8dd3ce9b3d43 (diff) | |
download | tanzanite-612ed820a0600ec11ed642005377cd7f5a8a8b77.tar.gz tanzanite-612ed820a0600ec11ed642005377cd7f5a8a8b77.tar.bz2 tanzanite-612ed820a0600ec11ed642005377cd7f5a8a8b77.zip |
wip
Diffstat (limited to 'src/context-menu-commands')
-rw-r--r-- | src/context-menu-commands/message/viewRaw.ts | 2 | ||||
-rw-r--r-- | src/context-menu-commands/user/modlog.ts | 9 | ||||
-rw-r--r-- | src/context-menu-commands/user/userInfo.ts | 28 |
3 files changed, 25 insertions, 14 deletions
diff --git a/src/context-menu-commands/message/viewRaw.ts b/src/context-menu-commands/message/viewRaw.ts index 0a8fcfc..08a421d 100644 --- a/src/context-menu-commands/message/viewRaw.ts +++ b/src/context-menu-commands/message/viewRaw.ts @@ -1,4 +1,4 @@ -import { ContextMenuCommand } from 'discord-akairo'; +import { ContextMenuCommand } from '@notenoughupdates/discord-akairo'; import { ApplicationCommandType, type ContextMenuCommandInteraction, type Message } from 'discord.js'; import { getRawData } from '../../commands/utilities/viewRaw.js'; diff --git a/src/context-menu-commands/user/modlog.ts b/src/context-menu-commands/user/modlog.ts index c78396e..b68a7e9 100644 --- a/src/context-menu-commands/user/modlog.ts +++ b/src/context-menu-commands/user/modlog.ts @@ -1,6 +1,6 @@ import { ModlogCommand } from '#commands'; import { emojis, SlashMessage } from '#lib'; -import { CommandUtil, ContextMenuCommand } from 'discord-akairo'; +import { CommandUtil, ContextMenuCommand } from '@notenoughupdates/discord-akairo'; import { ApplicationCommandType, type ContextMenuCommandInteraction } from 'discord.js'; export default class ModlogContextMenuCommand extends ContextMenuCommand { @@ -8,7 +8,8 @@ export default class ModlogContextMenuCommand extends ContextMenuCommand { super('modlog', { name: "Users's Modlogs", type: ApplicationCommandType.User, - category: 'user' + category: 'user', + dmPermission: false }); } @@ -28,6 +29,8 @@ export default class ModlogContextMenuCommand extends ContextMenuCommand { const pseudoMessage = new SlashMessage(this.client, interaction as any); pseudoMessage.util = new CommandUtil(this.client.commandHandler, pseudoMessage); - void new ModlogCommand().exec(pseudoMessage, { search: interaction.targetId, hidden: false }); + const command = this.client.commandHandler.modules.get('modlog') as ModlogCommand; + + void command.exec(pseudoMessage, { search: interaction.targetId, hidden: false }); } } 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); |