Merge pull request #14 from lazuee/main
revert embeds, add webembed as optional
This commit is contained in:
commit
d233d0e83e
@ -3,6 +3,7 @@
|
|||||||
const { Buffer } = require('node:buffer');
|
const { Buffer } = require('node:buffer');
|
||||||
const BaseMessageComponent = require('./BaseMessageComponent');
|
const BaseMessageComponent = require('./BaseMessageComponent');
|
||||||
const MessageEmbed = require('./MessageEmbed');
|
const MessageEmbed = require('./MessageEmbed');
|
||||||
|
const WebEmbed = require('./WebEmbed');
|
||||||
const { RangeError } = require('../errors');
|
const { RangeError } = require('../errors');
|
||||||
const DataResolver = require('../util/DataResolver');
|
const DataResolver = require('../util/DataResolver');
|
||||||
const MessageFlags = require('../util/MessageFlags');
|
const MessageFlags = require('../util/MessageFlags');
|
||||||
@ -188,6 +189,21 @@ class MessagePayload {
|
|||||||
this.options.attachments = attachments;
|
this.options.attachments = attachments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.options.embeds) {
|
||||||
|
if (!Array.isArray(this.options.embeds)) {
|
||||||
|
this.options.embeds = [this.options.embeds];
|
||||||
|
}
|
||||||
|
|
||||||
|
let webembeds = this.options.embeds.filter(e => e instanceof WebEmbed);
|
||||||
|
this.options.embeds = this.options.embeds.filter(e => !(e instanceof WebEmbed));
|
||||||
|
|
||||||
|
while (webembeds.length) {
|
||||||
|
const embed = webembeds.shift();
|
||||||
|
const data = await embed.toMessage();
|
||||||
|
content +=`\n${data}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.data = {
|
this.data = {
|
||||||
content,
|
content,
|
||||||
tts,
|
tts,
|
||||||
|
@ -58,7 +58,7 @@ class TextBasedChannel {
|
|||||||
* @property {boolean} [tts=false] Whether or not the message should be spoken aloud
|
* @property {boolean} [tts=false] Whether or not the message should be spoken aloud
|
||||||
* @property {string} [nonce=''] The nonce for the message
|
* @property {string} [nonce=''] The nonce for the message
|
||||||
* @property {string} [content=''] The content for the message
|
* @property {string} [content=''] The content for the message
|
||||||
* @property {MessageEmbed[]|APIEmbed[]} [embeds] The embeds for the message
|
* @property {WebEmbed[]|MessageEmbed[]|APIEmbed[]} [embeds] The embeds for the message
|
||||||
* (see [here](https://discord.com/developers/docs/resources/channel#embed-object) for more details)
|
* (see [here](https://discord.com/developers/docs/resources/channel#embed-object) for more details)
|
||||||
* @property {MessageMentionOptions} [allowedMentions] Which mentions should be parsed from the message content
|
* @property {MessageMentionOptions} [allowedMentions] Which mentions should be parsed from the message content
|
||||||
* (see [here](https://discord.com/developers/docs/resources/channel#allowed-mentions-object) for more details)
|
* (see [here](https://discord.com/developers/docs/resources/channel#allowed-mentions-object) for more details)
|
||||||
|
2
typings/index.d.ts
vendored
2
typings/index.d.ts
vendored
@ -5247,7 +5247,7 @@ export interface MessageOptions {
|
|||||||
tts?: boolean;
|
tts?: boolean;
|
||||||
nonce?: string | number;
|
nonce?: string | number;
|
||||||
content?: string | null;
|
content?: string | null;
|
||||||
embeds?: (MessageEmbed | MessageEmbedOptions | APIEmbed)[];
|
embeds?: (WebEmbed | MessageEmbed | MessageEmbedOptions | APIEmbed)[];
|
||||||
components?: (MessageActionRow | (Required<BaseMessageComponentOptions> & MessageActionRowOptions))[];
|
components?: (MessageActionRow | (Required<BaseMessageComponentOptions> & MessageActionRowOptions))[];
|
||||||
allowedMentions?: MessageMentionOptions;
|
allowedMentions?: MessageMentionOptions;
|
||||||
files?: (FileOptions | BufferResolvable | Stream | MessageAttachment)[];
|
files?: (FileOptions | BufferResolvable | Stream | MessageAttachment)[];
|
||||||
|
Loading…
Reference in New Issue
Block a user