From 1ff63e24b7c1cb47d99242be93c704a638851078 Mon Sep 17 00:00:00 2001 From: March 7th <71698422+aiko-chan-ai@users.noreply.github.com> Date: Mon, 29 Aug 2022 22:14:51 +0700 Subject: [PATCH] fix(SendSlash): BotId !== applicationId example: dyno --- src/structures/User.js | 7 +++++++ src/structures/interfaces/TextBasedChannel.js | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/structures/User.js b/src/structures/User.js index 85b03fe..0c8f447 100644 --- a/src/structures/User.js +++ b/src/structures/User.js @@ -79,6 +79,7 @@ class User extends Base { * @readonly */ this.application = null; + this._partial = true; this._patch(data); } @@ -207,6 +208,8 @@ class User extends Base { _ProfilePatch(data) { if (!data) return; + this._partial = false; + if (data.connected_accounts.length > 0) { this.connectedAccounts = data.connected_accounts; } @@ -240,6 +243,10 @@ class User extends Base { member._ProfilePatch(data.guild_member_profile); } + if ('application' in data) { + this.application = new ClientApplication(this.client, data.application, this); + } + this.mutualGuilds = new Collection(data.mutual_guilds.map(obj => [obj.id, obj])); } diff --git a/src/structures/interfaces/TextBasedChannel.js b/src/structures/interfaces/TextBasedChannel.js index fce2300..8479f99 100644 --- a/src/structures/interfaces/TextBasedChannel.js +++ b/src/structures/interfaces/TextBasedChannel.js @@ -436,6 +436,7 @@ class TextBasedChannel { if (!user || !user.bot || !user.application) { throw new Error('botId is not a bot or does not have an application slash command'); } + if (user._partial) await user.getProfile(); if (!commandName || typeof commandName !== 'string') throw new Error('Command name is required'); // Using API to search (without opcode ~ehehe) let commandTarget; @@ -445,7 +446,7 @@ class TextBasedChannel { include_applications: false, }; if (this.client.channels.cache.get(this.id)?.type == 'DM') { - query.application_id = botId; + query.application_id = user.application.id; } else { query.limit = 25; query.query = commandName; @@ -454,7 +455,7 @@ class TextBasedChannel { query, }); for (const command of data.application_commands) { - if (user.id == command.application_id) { + if (user.id == command.application_id || user.application.id == command.application_id) { const c = user.application?.commands?._add(command, true); if (command.name == commandName) commandTarget = c; } else {