aboutsummaryrefslogtreecommitdiff
path: root/src/lib/extensions/discord-akairo/BushClientUtil.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/lib/extensions/discord-akairo/BushClientUtil.ts
parenta2eee77d300723bc1e3e2d75cfda3c1d457b3b8c (diff)
downloadtanzanite-855aa36c46e250fd3063eb200d784903a8c388d3.tar.gz
tanzanite-855aa36c46e250fd3063eb200d784903a8c388d3.tar.bz2
tanzanite-855aa36c46e250fd3063eb200d784903a8c388d3.zip
performance improvements & fixes
Diffstat (limited to 'src/lib/extensions/discord-akairo/BushClientUtil.ts')
-rw-r--r--src/lib/extensions/discord-akairo/BushClientUtil.ts21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts
index 55f525b..fa5e3b0 100644
--- a/src/lib/extensions/discord-akairo/BushClientUtil.ts
+++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts
@@ -39,6 +39,7 @@ import {
MessageComponentInteraction,
MessageEditOptions,
MessageEmbed,
+ MessageEmbedOptions,
MessageOptions,
Snowflake,
TextChannel,
@@ -677,7 +678,7 @@ export class BushClientUtil extends ClientUtil {
*/
public async buttonPaginate(
message: BushMessage | BushSlashMessage,
- embeds: MessageEmbed[],
+ embeds: MessageEmbed[] | MessageEmbedOptions[],
text: string | null = null,
deleteOnExit?: boolean,
startOn?: number
@@ -690,7 +691,11 @@ export class BushClientUtil extends ClientUtil {
}
embeds.forEach((_e, i) => {
- embeds[i] = embeds[i].setFooter(`Page ${i + 1}/${embeds.length}`);
+ embeds[i] instanceof MessageEmbed
+ ? (embeds[i] as MessageEmbed).setFooter(`Page ${(i + 1).toLocaleString()}/${embeds.length.toLocaleString()}`)
+ : ((embeds[i] as MessageEmbedOptions).footer = {
+ text: `Page ${(i + 1).toLocaleString()}/${embeds.length.toLocaleString()}`
+ });
});
const style = Constants.MessageButtonStyles.PRIMARY;
@@ -772,13 +777,13 @@ export class BushClientUtil extends ClientUtil {
style,
customId: 'paginate_beginning',
emoji: paginateEmojis.beginning,
- disabled: disableAll || curPage == 0
+ disabled: disableAll || curPage === 0
}),
new MessageButton({
style,
customId: 'paginate_back',
emoji: paginateEmojis.back,
- disabled: disableAll || curPage == 0
+ disabled: disableAll || curPage === 0
}),
new MessageButton({
style,
@@ -790,13 +795,13 @@ export class BushClientUtil extends ClientUtil {
style,
customId: 'paginate_next',
emoji: paginateEmojis.forward,
- disabled: disableAll || curPage == embeds.length - 1
+ disabled: disableAll || curPage === embeds.length - 1
}),
new MessageButton({
style,
customId: 'paginate_end',
emoji: paginateEmojis.end,
- disabled: disableAll || curPage == embeds.length - 1
+ disabled: disableAll || curPage === embeds.length - 1
})
);
}
@@ -1176,11 +1181,13 @@ export class BushClientUtil extends ClientUtil {
const guild = client.guilds.resolveId(options.guild);
const type = this.#findTypeEnum(options.type);
+ if (!user || !guild) return false;
+
let success = true;
const entries = await ActivePunishment.findAll({
// finding all cases of a certain type incase there were duplicates or something
- where: { user, guild, type }
+ where: { user: user.id, guild: guild, type }
}).catch(async (e) => {
await util.handleError('removePunishmentEntry', e);
success = false;