Added embed field splitter
parent
126c3253b2
commit
e07ebed824
10
src/Util.ts
10
src/Util.ts
|
@ -42,4 +42,14 @@ export default class Util {
|
|||
if (message) message.channel.createMessage(`***${this.client.stores.emojis.error} An unexpected error has occured - please contact a member of the Engineering Team.${command ? ' This command has been disabled.' : ''}***`);
|
||||
return stack;
|
||||
}
|
||||
|
||||
public splitFields(fields: {name: string, value: string, inline?: boolean}[]): {name: string, value: string, inline?: boolean}[][] {
|
||||
let index = 0;
|
||||
const array: {name: string, value: string, inline?: boolean}[][] = [[]];
|
||||
while (fields.length) {
|
||||
if (array[index].length >= 25) { index += 1; array[index] = []; }
|
||||
array[index].push(fields[0]); fields.shift();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ export default class Help extends Command {
|
|||
const embed = new RichEmbed();
|
||||
embed.setTimestamp(); embed.setFooter(`Requested by ${message.author.username}#${message.author.discriminator}`, message.author.avatarURL);
|
||||
embed.setAuthor(`${this.client.user.username}#${this.client.user.discriminator}`, this.client.user.avatarURL);
|
||||
embed.setDescription(`Command list for ${this.client.user.username}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ export default class Modlogs extends Command {
|
|||
const query = await this.client.db.Moderation.find({ $or: [{ account: args.join(' ') }, { userID: args.filter((a) => a)[0].replace(/[<@!>]/g, '') }] });
|
||||
if (!query.length) return msg.edit(`***${this.client.stores.emojis.error} Cannot locate modlogs for ${args.join(' ')}***`);
|
||||
|
||||
let index = 0; const logs: {name: string, value: string, inline: boolean}[][] = [[]];
|
||||
const formatted = query.map((log) => {
|
||||
const { account, moderatorID, reason, type, date } = log;
|
||||
const name = type;
|
||||
|
@ -32,10 +31,7 @@ export default class Modlogs extends Command {
|
|||
});
|
||||
const users = [...new Set(query.map((log) => log.userID))].map((u) => `<@${u}>`);
|
||||
|
||||
while (query.length) {
|
||||
if (logs[index].length >= 25) { index += 1; logs[index] = []; }
|
||||
logs[index].push(formatted[0]); formatted.shift();
|
||||
}
|
||||
const logs = this.util.splitFields(formatted);
|
||||
|
||||
const embeds = logs.map((l) => {
|
||||
const embed = new RichEmbed();
|
||||
|
|
Loading…
Reference in New Issue