forked from engineering/cloudservices
Workaround for embed limits
parent
43943fce5d
commit
259c5d15c8
|
@ -22,12 +22,10 @@ export default class Parseall extends Command {
|
||||||
embed.setTitle('Certificate Validation');
|
embed.setTitle('Certificate Validation');
|
||||||
embed.setAuthor(this.client.user.username, this.client.user.avatarURL);
|
embed.setAuthor(this.client.user.username, this.client.user.avatarURL);
|
||||||
embed.setFooter(`Requested by ${message.member.username}#${message.member.discriminator}`, message.member.avatarURL);
|
embed.setFooter(`Requested by ${message.member.username}#${message.member.discriminator}`, message.member.avatarURL);
|
||||||
|
embed.setTimestamp();
|
||||||
const search = await this.client.db.Account.find();
|
const search = await this.client.db.Account.find();
|
||||||
const accounts = search.map((acc) => acc.username);
|
const accounts = search.map((acc) => acc.username);
|
||||||
const initial = accounts.map((acc) => `${this.client.stores.emojis.loading} **${acc}** Loading...`);
|
const final: string[] = [];
|
||||||
embed.setDescription(initial.join('\n'));
|
|
||||||
// @ts-ignore
|
|
||||||
const msg = await message.channel.createMessage({ embed });
|
|
||||||
|
|
||||||
accounts.forEach(async (a) => {
|
accounts.forEach(async (a) => {
|
||||||
try {
|
try {
|
||||||
|
@ -36,21 +34,24 @@ export default class Parseall extends Command {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const time = moment.preciseDiff(new Date(), notAfter);
|
const time = moment.preciseDiff(new Date(), notAfter);
|
||||||
|
|
||||||
if (notAfter < new Date()) initial[accounts.findIndex((acc) => acc === a)] = `${this.client.stores.emojis.error} **${a}** Certificate expired ${time} ago`;
|
if (notAfter < new Date()) final.push(`${this.client.stores.emojis.error} **${a}** Certificate expired ${time} ago`);
|
||||||
else initial[accounts.findIndex((acc) => acc === a)] = `${this.client.stores.emojis.success} **${a}** Certificate expires in ${time}`;
|
else final.push(`${this.client.stores.emojis.success} **${a}** Certificate expires in ${time}`);
|
||||||
|
|
||||||
embed.setDescription(initial.join('\n'));
|
|
||||||
await msg.edit({ embed });
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.message.includes('no such file or directory') || error.message.includes('File doesn\'t exist.')) {
|
if (error.message.includes('no such file or directory') || error.message.includes('File doesn\'t exist.')) final.push(`${this.client.stores.emojis.error} **${a}** Unable to locate certificate`);
|
||||||
initial[accounts.findIndex((acc) => acc === a)] = `${this.client.stores.emojis.error} **${a}** Unable to locate certificate`;
|
else throw error;
|
||||||
embed.setDescription(initial.join('\n'));
|
|
||||||
await msg.edit({ embed });
|
|
||||||
} else throw error;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (final.join('\n').length < 2048) embed.setDescription(final.join('\n'));
|
||||||
|
else {
|
||||||
|
const split = this.client.util.splitString(final.join('\n'), 1024);
|
||||||
|
split.forEach((s) => embed.addField('\u200B', s));
|
||||||
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
return await message.channel.createMessage({ embed });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.client.util.handleError(error, message, this);
|
return this.client.util.handleError(error, message, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue