Embeds send support
maybe ... + fix message edit
This commit is contained in:
parent
f8c0ab6bb9
commit
42bea13249
@ -319,7 +319,6 @@ message.channel.send({ content: `Hello world`, embeds: [w] }) // Patched :)
|
|||||||
- Video with Embed working
|
- Video with Embed working
|
||||||
- Description limit 350 characters
|
- 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)
|
- 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>
|
</details>
|
||||||
|
|
||||||
|
@ -124,12 +124,16 @@ class MessageManager extends CachedManager {
|
|||||||
const messageId = this.resolveId(message);
|
const messageId = this.resolveId(message);
|
||||||
if (!messageId) throw new TypeError('INVALID_TYPE', 'message', 'MessageResolvable');
|
if (!messageId) throw new TypeError('INVALID_TYPE', 'message', 'MessageResolvable');
|
||||||
|
|
||||||
const { data, files } = await (options instanceof MessagePayload
|
let messagePayload;
|
||||||
? options
|
if (options instanceof MessagePayload) {
|
||||||
: MessagePayload.create(message instanceof Message ? message : this, options)
|
messagePayload = await options.resolveData();
|
||||||
)
|
} else {
|
||||||
.resolveData()
|
messagePayload = await MessagePayload.create(
|
||||||
.resolveFiles();
|
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 d = await this.client.api.channels[this.channel.id].messages[messageId].patch({ data, files });
|
||||||
|
|
||||||
const existing = this.cache.get(messageId);
|
const existing = this.cache.get(messageId);
|
||||||
|
@ -203,12 +203,14 @@ class MessagePayload {
|
|||||||
// add hidden embed link
|
// add hidden embed link
|
||||||
content += `\n${WebEmbed.hiddenEmbed} \n`;
|
content += `\n${WebEmbed.hiddenEmbed} \n`;
|
||||||
if (webembeds.length > 1) {
|
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 embed = webembeds[0];
|
||||||
const data = await embed.toMessage();
|
for (const webE of webembeds) {
|
||||||
|
const data = await webE.toMessage();
|
||||||
content += `\n${data}`;
|
content += `\n${data}`;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Check content
|
// Check content
|
||||||
if (content.length > 2000) {
|
if (content.length > 2000) {
|
||||||
console.warn(`[WARN] Content is longer than 2000 characters.`);
|
console.warn(`[WARN] Content is longer than 2000 characters.`);
|
||||||
|
@ -301,7 +301,7 @@ class WebEmbed {
|
|||||||
// Credit: https://www.npmjs.com/package/node-url-shortener + google :))
|
// Credit: https://www.npmjs.com/package/node-url-shortener + google :))
|
||||||
const getShorten = async (url) => {
|
const getShorten = async (url) => {
|
||||||
const APIurl = [
|
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://tinyurl.com/api-create.php?url=',
|
||||||
// 'https://cdpt.in/shorten?url=', Redirects 5s :(
|
// 'https://cdpt.in/shorten?url=', Redirects 5s :(
|
||||||
];
|
];
|
||||||
|
@ -316,11 +316,15 @@ class Webhook {
|
|||||||
if (!this.token) throw new Error('WEBHOOK_TOKEN_UNAVAILABLE');
|
if (!this.token) throw new Error('WEBHOOK_TOKEN_UNAVAILABLE');
|
||||||
|
|
||||||
let messagePayload;
|
let messagePayload;
|
||||||
|
if (options instanceof MessagePayload) {
|
||||||
if (options instanceof MessagePayload) messagePayload = options;
|
messagePayload = await options.resolveData();
|
||||||
else messagePayload = MessagePayload.create(this, options);
|
} else {
|
||||||
|
messagePayload = await MessagePayload.create(
|
||||||
const { data, files } = await messagePayload.resolveData().resolveFiles();
|
message instanceof Message ? message : this,
|
||||||
|
options,
|
||||||
|
).resolveData();
|
||||||
|
}
|
||||||
|
const { data, files } = await messagePayload.resolveFiles();
|
||||||
|
|
||||||
const d = await this.client.api
|
const d = await this.client.api
|
||||||
.webhooks(this.id, this.token)
|
.webhooks(this.id, this.token)
|
||||||
|
Loading…
Reference in New Issue
Block a user