mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 19:13:31 +01:00
feat(InteractionReponses): allow fetching of ephemeral messages (#6426)
This commit is contained in:
@@ -131,8 +131,7 @@ const Messages = {
|
|||||||
|
|
||||||
INTERACTION_ALREADY_REPLIED: 'The reply to this interaction has already been sent or deferred.',
|
INTERACTION_ALREADY_REPLIED: 'The reply to this interaction has already been sent or deferred.',
|
||||||
INTERACTION_NOT_REPLIED: 'The reply to this interaction has not been sent or deferred.',
|
INTERACTION_NOT_REPLIED: 'The reply to this interaction has not been sent or deferred.',
|
||||||
INTERACTION_EPHEMERAL_REPLIED: 'Ephemeral responses cannot be fetched or deleted.',
|
INTERACTION_EPHEMERAL_REPLIED: 'Ephemeral responses cannot be deleted.',
|
||||||
INTERACTION_FETCH_EPHEMERAL: 'Ephemeral responses cannot be fetched.',
|
|
||||||
|
|
||||||
COMMAND_INTERACTION_OPTION_NOT_FOUND: name => `Required option "${name}" not found.`,
|
COMMAND_INTERACTION_OPTION_NOT_FOUND: name => `Required option "${name}" not found.`,
|
||||||
COMMAND_INTERACTION_OPTION_TYPE: (name, type, expected) =>
|
COMMAND_INTERACTION_OPTION_TYPE: (name, type, expected) =>
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ class InteractionResponses {
|
|||||||
*/
|
*/
|
||||||
async deferReply(options = {}) {
|
async deferReply(options = {}) {
|
||||||
if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED');
|
if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED');
|
||||||
if (options.fetchReply && options.ephemeral) throw new Error('INTERACTION_FETCH_EPHEMERAL');
|
|
||||||
this.ephemeral = options.ephemeral ?? false;
|
this.ephemeral = options.ephemeral ?? false;
|
||||||
await this.client.api.interactions(this.id, this.token).callback.post({
|
await this.client.api.interactions(this.id, this.token).callback.post({
|
||||||
data: {
|
data: {
|
||||||
@@ -87,7 +86,6 @@ class InteractionResponses {
|
|||||||
*/
|
*/
|
||||||
async reply(options) {
|
async reply(options) {
|
||||||
if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED');
|
if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED');
|
||||||
if (options.fetchReply && options.ephemeral) throw new Error('INTERACTION_FETCH_EPHEMERAL');
|
|
||||||
this.ephemeral = options.ephemeral ?? false;
|
this.ephemeral = options.ephemeral ?? false;
|
||||||
|
|
||||||
let messagePayload;
|
let messagePayload;
|
||||||
@@ -119,7 +117,6 @@ class InteractionResponses {
|
|||||||
* .catch(console.error);
|
* .catch(console.error);
|
||||||
*/
|
*/
|
||||||
fetchReply() {
|
fetchReply() {
|
||||||
if (this.ephemeral) throw new Error('INTERACTION_EPHEMERAL_REPLIED');
|
|
||||||
return this.webhook.fetchMessage('@original');
|
return this.webhook.fetchMessage('@original');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,9 +174,6 @@ class InteractionResponses {
|
|||||||
*/
|
*/
|
||||||
async deferUpdate(options = {}) {
|
async deferUpdate(options = {}) {
|
||||||
if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED');
|
if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED');
|
||||||
if (options.fetchReply && new MessageFlags(this.message.flags).has(MessageFlags.FLAGS.EPHEMERAL)) {
|
|
||||||
throw new Error('INTERACTION_FETCH_EPHEMERAL');
|
|
||||||
}
|
|
||||||
await this.client.api.interactions(this.id, this.token).callback.post({
|
await this.client.api.interactions(this.id, this.token).callback.post({
|
||||||
data: {
|
data: {
|
||||||
type: InteractionResponseTypes.DEFERRED_MESSAGE_UPDATE,
|
type: InteractionResponseTypes.DEFERRED_MESSAGE_UPDATE,
|
||||||
@@ -205,9 +199,6 @@ class InteractionResponses {
|
|||||||
*/
|
*/
|
||||||
async update(options) {
|
async update(options) {
|
||||||
if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED');
|
if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED');
|
||||||
if (options.fetchReply && new MessageFlags(this.message.flags).has(MessageFlags.FLAGS.EPHEMERAL)) {
|
|
||||||
throw new Error('INTERACTION_FETCH_EPHEMERAL');
|
|
||||||
}
|
|
||||||
|
|
||||||
let messagePayload;
|
let messagePayload;
|
||||||
if (options instanceof MessagePayload) messagePayload = options;
|
if (options instanceof MessagePayload) messagePayload = options;
|
||||||
|
|||||||
Reference in New Issue
Block a user