diff options
Diffstat (limited to 'src/commands')
-rw-r--r-- | src/commands/admin/roleAll.ts | 11 | ||||
-rw-r--r-- | src/commands/dev/eval.ts | 9 | ||||
-rw-r--r-- | src/commands/utilities/whoHasRole.ts | 27 |
3 files changed, 33 insertions, 14 deletions
diff --git a/src/commands/admin/roleAll.ts b/src/commands/admin/roleAll.ts index ec18060..2382a4b 100644 --- a/src/commands/admin/roleAll.ts +++ b/src/commands/admin/roleAll.ts @@ -45,7 +45,11 @@ export default class RoleAllCommand extends BushCommand { ); } + console.time('roleAll1'); let members = await message.guild.members.fetch(); + console.timeEnd('roleAll1'); + + console.time('roleAll2'); members = members.filter((member: GuildMember) => { try { if (member.user.bot && !args.bot) return false; @@ -55,14 +59,21 @@ export default class RoleAllCommand extends BushCommand { } return true; }); + console.timeEnd('roleAll2'); + console.time('roleAll3'); await message.util.reply(`${this.client.util.emojis.loading} adding roles to ${members.size} members`); + console.timeEnd('roleAll3'); + console.time('roleAll4'); const promises = members.map((member: GuildMember) => { return member.roles.add(args.role, `RoleAll Command - triggered by ${message.author.tag} (${message.author.id})`); }); + console.timeEnd('roleAll4'); + console.time('roleAll5'); const failed = (await Promise.allSettled(promises)).filter((val) => val.status === 'rejected'); + console.timeEnd('roleAll5'); if (!failed.length) { await message.util.reply({ diff --git a/src/commands/dev/eval.ts b/src/commands/dev/eval.ts index 294c61b..3bc2eed 100644 --- a/src/commands/dev/eval.ts +++ b/src/commands/dev/eval.ts @@ -68,12 +68,13 @@ export default class EvalCommand extends BushCommand { if (message.util.isSlash) { await (message as BushSlashMessage).interaction.deferReply({ ephemeral: args.silent }); } - args.code = args.code.replace(/[“”]/g, '"').replace(/```*(?:js|ts)?/g, ''); + const _isTypescript = args.typescript || args.code.includes('```ts'); + const _code = args.code.replace(/[“”]/g, '"').replace(/```*(?:js|ts)?/g, ''); const code: { ts: string | null; js: string; lang: 'ts' | 'js' } = { - ts: args.typescript ? args.code : null, - js: args.typescript ? transpile(args.code) : args.code, - lang: args.typescript ? 'ts' : 'js' + ts: _isTypescript ? _code : null, + js: _isTypescript ? transpile(_code) : _code, + lang: _isTypescript ? 'ts' : 'js' }; const embed = new _MessageEmbed(); diff --git a/src/commands/utilities/whoHasRole.ts b/src/commands/utilities/whoHasRole.ts index e507036..73a9920 100644 --- a/src/commands/utilities/whoHasRole.ts +++ b/src/commands/utilities/whoHasRole.ts @@ -1,10 +1,10 @@ import { BushCommand, BushMessage, BushSlashMessage } from '@lib'; -import { MessageEmbed, Role, Util } from 'discord.js'; +import { Role, Util } from 'discord.js'; export default class WhoHasRoleCommand extends BushCommand { public constructor() { super('whohasrole', { - aliases: ['whohasrole'], + aliases: ['whohasrole', 'whr', 'dump'], category: 'utilities', description: { content: 'Allows you to view what users have a certain role.', @@ -38,17 +38,24 @@ export default class WhoHasRoleCommand extends BushCommand { }); } public override async exec(message: BushMessage | BushSlashMessage, args: { role: Role }): Promise<unknown> { + // console.time('whohasrole1'); const roleMembers = args.role.members.map((member) => `${member.user} (${Util.escapeMarkdown(member.user.tag)})`); + // console.timeEnd('whohasrole1'); + // console.time('whohasrole2'); const chunkedRoleMembers = util.chunk(roleMembers, 30); - const embedPages = chunkedRoleMembers.map( - (chunk) => - new MessageEmbed({ - title: `${args.role.name}'s Members [\`${args.role.members.size.toLocaleString()}\`]`, - description: chunk.join('\n'), - color: util.colors.default - }) - ); + // console.timeEnd('whohasrole2'); + + // console.time('whohasrole3'); + const title = `${args.role.name}'s Members [\`${args.role.members.size.toLocaleString()}\`]`; + const color = util.colors.default; + const embedPages = chunkedRoleMembers.map((chunk) => ({ + title, + description: chunk.join('\n'), + color + })); + // console.timeEnd('whohasrole3'); + return await util.buttonPaginate(message, embedPages, null, true); } } |