This commit is contained in:
March 7th 2022-03-25 23:31:17 +07:00
parent fd4a6fa509
commit f4c8489beb
4 changed files with 28 additions and 4 deletions

View File

@ -244,6 +244,30 @@ await MessageSelectMenu.select(Message, value);
// value: ['value1', 'value2' , ...]
```
</details>
<details>
<summary>Slash Command (v1)</summary>
```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']
```
</details>
<details>
<summary>Message Context Command (v1)</summary>
```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);
```
</details>
## More features

View File

@ -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;
}
/**

View File

@ -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

2
typings/index.d.ts vendored
View File

@ -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;