Slash Command and Context Menu
- Doc. comming soon
This commit is contained in:
@@ -10,7 +10,7 @@ const { ApplicationCommandPermissionTypes, APIErrors } = require('../util/Consta
|
||||
* @extends {BaseManager}
|
||||
*/
|
||||
class ApplicationCommandPermissionsManager extends BaseManager {
|
||||
constructor(manager) {
|
||||
constructor(manager, user) {
|
||||
super(manager.client);
|
||||
|
||||
/**
|
||||
@@ -37,6 +37,8 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
||||
* @type {?Snowflake}
|
||||
*/
|
||||
this.commandId = manager.id ?? null;
|
||||
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,7 +49,7 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
||||
* @private
|
||||
*/
|
||||
permissionsPath(guildId, commandId) {
|
||||
return this.client.api.applications(this.client.application.id).guilds(guildId).commands(commandId).permissions;
|
||||
return this.client.api.applications(this.user.id).guilds(guildId).commands(commandId).permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,6 +161,7 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
||||
* .catch(console.error);
|
||||
*/
|
||||
async set({ guild, command, permissions, fullPermissions } = {}) {
|
||||
if(!this.manager.client.user.bot) throw new Error("INVALID_USER_METHOD");
|
||||
const { guildId, commandId } = this._validateOptions(guild, command);
|
||||
|
||||
if (commandId) {
|
||||
@@ -220,6 +223,7 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
||||
* .catch(console.error);
|
||||
*/
|
||||
async add({ guild, command, permissions }) {
|
||||
if(!this.manager.client.user.bot) throw new Error("INVALID_USER_METHOD");
|
||||
const { guildId, commandId } = this._validateOptions(guild, command);
|
||||
if (!commandId) throw new TypeError('INVALID_TYPE', 'command', 'ApplicationCommandResolvable');
|
||||
if (!Array.isArray(permissions)) {
|
||||
@@ -271,6 +275,7 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
||||
* .catch(console.error);
|
||||
*/
|
||||
async remove({ guild, command, users, roles }) {
|
||||
if(!this.manager.client.user.bot) throw new Error("INVALID_USER_METHOD");
|
||||
const { guildId, commandId } = this._validateOptions(guild, command);
|
||||
if (!commandId) throw new TypeError('INVALID_TYPE', 'command', 'ApplicationCommandResolvable');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user