From f4c8489beba4d2cb341b6863d3e4977ff3e4f578 Mon Sep 17 00:00:00 2001
From: March 7th <71698422+aiko-chan-ai@users.noreply.github.com>
Date: Fri, 25 Mar 2022 23:31:17 +0700
Subject: [PATCH] Working
---
DOCUMENT.md | 24 +++++++++++++++++++
.../ApplicationCommandPermissionsManager.js | 2 +-
src/structures/ApplicationCommand.js | 4 ++--
typings/index.d.ts | 2 +-
4 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/DOCUMENT.md b/DOCUMENT.md
index 4278340..b5dd146 100644
--- a/DOCUMENT.md
+++ b/DOCUMENT.md
@@ -244,6 +244,30 @@ await MessageSelectMenu.select(Message, value);
// value: ['value1', 'value2' , ...]
```
+
+Slash Command (v1)
+
+```js
+const botID = '12345678987654321'
+const user = await client.users.fetch(botID);
+const application = await user.applications.fetch();
+const command = application.cache.first();
+await command.sendSlashCommand(messsage, ['option1', 'option2']);
+// Eg: Slash /add role:123456789 user:987654321
+// value: ['123456789', '987654321']
+```
+
+
+Message Context Command (v1)
+
+```js
+const botID = '12345678987654321'
+const user = await client.users.fetch(botID);
+const application = await user.applications.fetch();
+const command = application.cache.first();
+await command.sendContextMenu(messsage);
+```
+
## More features
diff --git a/src/managers/ApplicationCommandPermissionsManager.js b/src/managers/ApplicationCommandPermissionsManager.js
index 05081d6..b9cbb20 100644
--- a/src/managers/ApplicationCommandPermissionsManager.js
+++ b/src/managers/ApplicationCommandPermissionsManager.js
@@ -49,7 +49,7 @@ class ApplicationCommandPermissionsManager extends BaseManager {
* @private
*/
permissionsPath(guildId, commandId) {
- return this.client.api.applications(this.user.id).guilds(guildId).commands(commandId).permissions;
+ return this.client.api.applications(typeof this.user == 'string' ? this.user : this.user.id).guilds(guildId).commands(commandId).permissions;
}
/**
diff --git a/src/structures/ApplicationCommand.js b/src/structures/ApplicationCommand.js
index 2d1381d..0204283 100644
--- a/src/structures/ApplicationCommand.js
+++ b/src/structures/ApplicationCommand.js
@@ -4,7 +4,7 @@ const Base = require('./Base');
const ApplicationCommandPermissionsManager = require('../managers/ApplicationCommandPermissionsManager');
const { ApplicationCommandOptionTypes, ApplicationCommandTypes, ChannelTypes } = require('../util/Constants');
const SnowflakeUtil = require('../util/SnowflakeUtil');
-const { Message } = require('..');
+const { Message } = require('discord.js');
/**
* Represents an application command.
@@ -43,7 +43,7 @@ class ApplicationCommand extends Base {
* The manager for permissions of this command on its guild or arbitrary guilds when the command is global
* @type {ApplicationCommandPermissionsManager}
*/
- this.permissions = new ApplicationCommandPermissionsManager(this, user);
+ this.permissions = new ApplicationCommandPermissionsManager(this, this.applicationId);
/**
* The type of this application command
diff --git a/typings/index.d.ts b/typings/index.d.ts
index 59c3db2..e107244 100644
--- a/typings/index.d.ts
+++ b/typings/index.d.ts
@@ -2401,7 +2401,7 @@ export class Typing extends Base {
export class User extends PartialTextBasedChannel(Base) {
protected constructor(client: Client, data: RawUserData);
private _equals(user: APIUser): boolean;
-
+ public applications: ApplicationCommandManager;
public accentColor: number | null | undefined;
public avatar: string | null;
public banner: string | null | undefined;