Skip to content

Commit

Permalink
feat(interactions): Add support for appPermissions (#1394)
Browse files Browse the repository at this point in the history
  • Loading branch information
frobinsonj committed Jun 30, 2022
1 parent f886ebc commit c7689d0
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions index.d.ts
Expand Up @@ -2956,6 +2956,7 @@ declare namespace Eris {
}

export class CommandInteraction<T extends PossiblyUncachedTextable = TextableChannel> extends Interaction {
appPermissions?: Permission;
channel: T;
data: {
id: string;
Expand Down Expand Up @@ -2998,6 +2999,7 @@ declare namespace Eris {
}

export class ComponentInteraction<T extends PossiblyUncachedTextable = TextableChannel> extends Interaction {
appPermissions?: Permission;
channel: T;
data: ComponentInteractionButtonData | ComponentInteractionSelectMenuData;
guildID?: string;
Expand All @@ -3018,6 +3020,7 @@ declare namespace Eris {
getOriginalMessage(): Promise<Message>
}
export class AutocompleteInteraction<T extends PossiblyUncachedTextable = TextableChannel> extends Interaction {
appPermissions?: Permission;
channel: T;
data: {
id: string;
Expand All @@ -3034,6 +3037,7 @@ declare namespace Eris {
result(choices: ApplicationCommandOptionChoice[]): Promise<void>;
}
export class UnknownInteraction<T extends PossiblyUncachedTextable = TextableChannel> extends Interaction {
appPermissions?: Permission;
channel?: T;
data?: unknown;
guildID?: string;
Expand Down
6 changes: 5 additions & 1 deletion lib/structures/AutocompleteInteraction.js
Expand Up @@ -2,12 +2,13 @@

const Interaction = require("./Interaction");
const Member = require("./Member");

const Permission = require("./Permission");
const {InteractionResponseTypes} = require("../Constants");

/**
* Represents an application command autocomplete interaction. See Interaction for more properties.
* @extends Interaction
* @prop {Permission?} appPermissions The permissions the app or bot has within the channel the interaction was sent from
* @prop {PrivateChannel | TextChannel | NewsChannel} channel The channel the interaction was created in. Can be partial with only the id if the channel is not cached.
* @prop {Object} data The data attached to the interaction
* @prop {String} data.id The ID of the Application Command
Expand Down Expand Up @@ -52,6 +53,9 @@ class AutocompleteInteraction extends Interaction {
this.user = this._client.users.update(info.user, client);
}

if(info.app_permissions !== undefined) {
this.appPermissions = new Permission(info.app_permissions);
}
}

/**
Expand Down
5 changes: 5 additions & 0 deletions lib/structures/CommandInteraction.js
Expand Up @@ -7,12 +7,14 @@ const Role = require("./Role");
const Channel = require("./Channel");
const Message = require("./Message");
const Collection = require("../util/Collection");
const Permission = require("./Permission");

const {InteractionResponseTypes} = require("../Constants");

/**
* Represents an application command interaction. See Interaction for more properties.
* @extends Interaction
* @prop {Permission?} appPermissions The permissions the app or bot has within the channel the interaction was sent from
* @prop {PrivateChannel | TextChannel | NewsChannel} channel The channel the interaction was created in. Can be partial with only the id if the channel is not cached.
* @prop {Object} data The data attached to the interaction
* @prop {String} data.id The ID of the Application Command
Expand Down Expand Up @@ -115,6 +117,9 @@ class CommandInteraction extends Interaction {
this.user = this._client.users.update(info.user, client);
}

if(info.app_permissions !== undefined) {
this.appPermissions = new Permission(info.app_permissions);
}
}

/**
Expand Down
5 changes: 5 additions & 0 deletions lib/structures/ComponentInteraction.js
Expand Up @@ -3,11 +3,13 @@
const Interaction = require("./Interaction");
const Message = require("./Message");
const Member = require("./Member");
const Permission = require("./Permission");
const {InteractionResponseTypes} = require("../Constants");

/**
* Represents a message component interaction. See Interaction for more properties.
* @extends Interaction
* @prop {Permission?} appPermissions The permissions the app or bot has within the channel the interaction was sent from
* @prop {PrivateChannel | TextChannel | NewsChannel} channel The channel the interaction was created in. Can be partial with only the id if the channel is not cached.
* @prop {Object} data The data attached to the interaction
* @prop {Number} data.component_type The type of Message Component
Expand Down Expand Up @@ -50,6 +52,9 @@ class ComponentInteraction extends Interaction {
this.user = this._client.users.update(info.user, client);
}

if(info.app_permissions !== undefined) {
this.appPermissions = new Permission(info.app_permissions);
}
}

/**
Expand Down
5 changes: 5 additions & 0 deletions lib/structures/UnknownInteraction.js
Expand Up @@ -3,12 +3,14 @@
const Interaction = require("./Interaction");
const Message = require("./Message");
const Member = require("./Member");
const Permission = require("./Permission");
const {InteractionResponseTypes} = require("../Constants");

/**
* Represents an unknown interaction. See Interaction for more properties.
* Note: Methods are not guaranteed to work properly, they are all added just in case you know which to use.
* @extends Interaction
* @prop {Permission?} appPermissions The permissions the app or bot has within the channel the interaction was sent from
* @prop {(PrivateChannel | TextChannel | NewsChannel)?} channel The channel the interaction was created in. Can be partial with only the id if the channel is not cached.
* @prop {Object?} data The data attached to the interaction
* @prop {String?} guildID The ID of the guild in which the interaction was created
Expand Down Expand Up @@ -52,6 +54,9 @@ class UnknownInteraction extends Interaction {
this.user = this._client.users.update(info.user, client);
}

if(info.app_permissions !== undefined) {
this.appPermissions = new Permission(info.app_permissions);
}
}

/**
Expand Down

0 comments on commit c7689d0

Please sign in to comment.