mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 17:13:31 +01:00
feat: interactions (#5448)
Co-authored-by: izexi <43889168+izexi@users.noreply.github.com> Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com> Co-authored-by: Advaith <advaithj1@gmail.com> Co-authored-by: Shiaupiau <stu43005@gmail.com> Co-authored-by: monbrey <rsm999@uowmail.edu.au> Co-authored-by: Tiemen <ThaTiemsz@users.noreply.github.com> Co-authored-by: Carter <carter@elhnet.net>
This commit is contained in:
@@ -73,6 +73,16 @@ class APIMessage {
|
||||
return this.target instanceof Message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not the target is an interaction
|
||||
* @type {boolean}
|
||||
* @readonly
|
||||
*/
|
||||
get isInteraction() {
|
||||
const Interaction = require('./Interaction');
|
||||
return this.target instanceof Interaction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the content of this message.
|
||||
* @returns {?(string|string[])}
|
||||
@@ -129,7 +139,7 @@ class APIMessage {
|
||||
}
|
||||
|
||||
const embedLikes = [];
|
||||
if (this.isWebhook) {
|
||||
if (this.isInteraction || this.isWebhook) {
|
||||
if (this.options.embeds) {
|
||||
embedLikes.push(...this.options.embeds);
|
||||
}
|
||||
@@ -149,6 +159,8 @@ class APIMessage {
|
||||
if (this.isMessage) {
|
||||
// eslint-disable-next-line eqeqeq
|
||||
flags = this.options.flags != null ? new MessageFlags(this.options.flags).bitfield : this.target.flags.bitfield;
|
||||
} else if (this.isInteraction && this.options.ephemeral) {
|
||||
flags = MessageFlags.FLAGS.EPHEMERAL;
|
||||
}
|
||||
|
||||
let allowedMentions =
|
||||
@@ -196,7 +208,7 @@ class APIMessage {
|
||||
if (this.files) return this;
|
||||
|
||||
const embedLikes = [];
|
||||
if (this.isWebhook) {
|
||||
if (this.isInteraction || this.isWebhook) {
|
||||
if (this.options.embeds) {
|
||||
embedLikes.push(...this.options.embeds);
|
||||
}
|
||||
@@ -348,10 +360,11 @@ class APIMessage {
|
||||
* @returns {MessageOptions|WebhookMessageOptions}
|
||||
*/
|
||||
static create(target, content, options, extra = {}) {
|
||||
const Interaction = require('./Interaction');
|
||||
const Webhook = require('./Webhook');
|
||||
const WebhookClient = require('../client/WebhookClient');
|
||||
|
||||
const isWebhook = target instanceof Webhook || target instanceof WebhookClient;
|
||||
const isWebhook = target instanceof Interaction || target instanceof Webhook || target instanceof WebhookClient;
|
||||
const transformed = this.transformOptions(content, options, extra, isWebhook);
|
||||
return new this(target, transformed);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user