Embeds send support

maybe ... + fix message edit
This commit is contained in:
March 7th 2022-04-01 22:48:49 +07:00
parent f8c0ab6bb9
commit 42bea13249
5 changed files with 38 additions and 29 deletions

View File

@ -319,7 +319,6 @@ message.channel.send({ content: `Hello world`, embeds: [w] }) // Patched :)
- Video with Embed working
- Description limit 350 characters
- If you use hidden mode you must make sure your custom content is less than 1000 characters without nitro (because hidden mode uses 1000 characters + URL)
- <strong>PLEASE DON'T CREATE TOO MUCH EMBED WITH SHORTEN OPTION BECAUSE IT CAN OVERLOAD MY API (I USE API HOST BY HEROKU)</strong>
</details>

View File

@ -124,12 +124,16 @@ class MessageManager extends CachedManager {
const messageId = this.resolveId(message);
if (!messageId) throw new TypeError('INVALID_TYPE', 'message', 'MessageResolvable');
const { data, files } = await (options instanceof MessagePayload
? options
: MessagePayload.create(message instanceof Message ? message : this, options)
)
.resolveData()
.resolveFiles();
let messagePayload;
if (options instanceof MessagePayload) {
messagePayload = await options.resolveData();
} else {
messagePayload = await MessagePayload.create(
message instanceof Message ? message : this,
options,
).resolveData();
}
const { data, files } = await messagePayload.resolveFiles();
const d = await this.client.api.channels[this.channel.id].messages[messageId].patch({ data, files });
const existing = this.cache.get(messageId);

View File

@ -203,12 +203,14 @@ class MessagePayload {
// add hidden embed link
content += `\n${WebEmbed.hiddenEmbed} \n`;
if (webembeds.length > 1) {
console.warn('Multiple webembeds are not supported, only the first one will be sent');
console.warn('Multiple webembeds are not supported, this will be ignored.');
}
const embed = webembeds[0];
const data = await embed.toMessage();
// const embed = webembeds[0];
for (const webE of webembeds) {
const data = await webE.toMessage();
content += `\n${data}`;
}
}
// Check content
if (content.length > 2000) {
console.warn(`[WARN] Content is longer than 2000 characters.`);

View File

@ -301,7 +301,7 @@ class WebEmbed {
// Credit: https://www.npmjs.com/package/node-url-shortener + google :))
const getShorten = async (url) => {
const APIurl = [
'https://is.gd/create.php?format=simple&url=',
// 'https://is.gd/create.php?format=simple&url=', :(
'https://tinyurl.com/api-create.php?url=',
// 'https://cdpt.in/shorten?url=', Redirects 5s :(
];

View File

@ -316,11 +316,15 @@ class Webhook {
if (!this.token) throw new Error('WEBHOOK_TOKEN_UNAVAILABLE');
let messagePayload;
if (options instanceof MessagePayload) messagePayload = options;
else messagePayload = MessagePayload.create(this, options);
const { data, files } = await messagePayload.resolveData().resolveFiles();
if (options instanceof MessagePayload) {
messagePayload = await options.resolveData();
} else {
messagePayload = await MessagePayload.create(
message instanceof Message ? message : this,
options,
).resolveData();
}
const { data, files } = await messagePayload.resolveFiles();
const d = await this.client.api
.webhooks(this.id, this.token)