aboutsummaryrefslogtreecommitdiff
path: root/src/commands/utilities/whoHasRole.ts
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-09-01 21:03:38 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-09-01 21:03:38 -0400
commit855aa36c46e250fd3063eb200d784903a8c388d3 (patch)
treefb883fcfc9addc0a5a23e200d04ae456dd29de1c /src/commands/utilities/whoHasRole.ts
parenta2eee77d300723bc1e3e2d75cfda3c1d457b3b8c (diff)
downloadtanzanite-855aa36c46e250fd3063eb200d784903a8c388d3.tar.gz
tanzanite-855aa36c46e250fd3063eb200d784903a8c388d3.tar.bz2
tanzanite-855aa36c46e250fd3063eb200d784903a8c388d3.zip
performance improvements & fixes
Diffstat (limited to 'src/commands/utilities/whoHasRole.ts')
-rw-r--r--src/commands/utilities/whoHasRole.ts27
1 files changed, 17 insertions, 10 deletions
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);
}
}