From 3bcf9366362167ee0ab51802df2ca2a3d2b4183a Mon Sep 17 00:00:00 2001 From: March 7th <71698422+aiko-chan-ai@users.noreply.github.com> Date: Wed, 3 Aug 2022 18:50:23 +0700 Subject: [PATCH] fix(sendSlash): [] commands (DM channel) Fixed #235 --- src/structures/interfaces/TextBasedChannel.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/structures/interfaces/TextBasedChannel.js b/src/structures/interfaces/TextBasedChannel.js index 0d3c44d..554421b 100644 --- a/src/structures/interfaces/TextBasedChannel.js +++ b/src/structures/interfaces/TextBasedChannel.js @@ -420,14 +420,18 @@ class TextBasedChannel { // Using API to search (without opcode ~ehehe) let commandTarget; // https://discord.com/api/v9/channels/id/application-commands/search?type=1&query=aiko&limit=7&include_applications=false&application_id=id + const query = { + type: 1, // Slash commands + include_applications: false, + }; + if (this.client.channels.cache.get(this.id)?.type == 'DM') { + query.application_id = botId; + } else { + query.limit = 25; + query.query = commandName; + } const data = await this.client.api.channels[this.id]['application-commands'].search.get({ - query: { - type: 1, // CHAT_INPUT, - include_applications: false, - query: commandName, - limit: 25, // Max - // application_id: botId, - }, + query, }); for (const command of data.application_commands) { if (user.id == command.application_id) {