From 1fef7e724e8fb9eddd9dd226d83d7063dc129111 Mon Sep 17 00:00:00 2001 From: MrSerge01 <86667481+MrSerge01@users.noreply.github.com> Date: Sun, 3 Nov 2024 22:24:45 +0500 Subject: [PATCH] (fix) 60 -> 30s, imageColor fix, user nickname --- src/commands/Leaderboard.ts | 4 ++-- src/commands/Serverboard.ts | 4 ++-- src/commands/User.ts | 6 +++--- src/commands/news/View.ts | 4 ++-- src/utils/imageColor.ts | 4 +++- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/commands/Leaderboard.ts b/src/commands/Leaderboard.ts index bbedffc..fa778a5 100644 --- a/src/commands/Leaderboard.ts +++ b/src/commands/Leaderboard.ts @@ -82,7 +82,7 @@ export default class Leaderboard { if (totalPages > 1) { const collector = reply.createMessageComponentCollector({ - time: 60000 + time: 30000 }); collector.on("collect", async (i: ButtonInteraction) => { @@ -95,7 +95,7 @@ export default class Leaderboard { if (i.user.id != interaction.user.id) return errorEmbed(i, "You are not the person who executed this command."); - collector.resetTimer({ time: 60000 }); + collector.resetTimer({ time: 30000 }); if (i.customId == "left") page = page > 1 ? page - 1 : totalPages; else page = page < totalPages ? page + 1 : 1; diff --git a/src/commands/Serverboard.ts b/src/commands/Serverboard.ts index 30323ac..cef27aa 100644 --- a/src/commands/Serverboard.ts +++ b/src/commands/Serverboard.ts @@ -59,7 +59,7 @@ export default class Serverboard { }); if (pages == 1) return; - const collector = reply.createMessageComponentCollector({ time: 60000 }); + const collector = reply.createMessageComponentCollector({ time: 30000 }); collector.on("collect", async (i: ButtonInteraction) => { if (i.message.id != (await reply.fetch()).id) return await errorEmbed( @@ -70,7 +70,7 @@ export default class Serverboard { if (i.user.id != interaction.user.id) return await errorEmbed(i, "You aren't the person who executed this command."); - collector.resetTimer({ time: 60000 }); + collector.resetTimer({ time: 30000 }); switch (i.customId) { case "left": page--; diff --git a/src/commands/User.ts b/src/commands/User.ts index 246fe6a..05c0c47 100644 --- a/src/commands/User.ts +++ b/src/commands/User.ts @@ -35,7 +35,7 @@ export default class User { let embed = new EmbedBuilder() .setAuthor({ - name: `${avatar ? "• " : ""}${user.displayName}`, + name: `${avatar ? "• " : ""}${target?.nickname ?? user.displayName}`, iconURL: avatar }) .setFields({ @@ -107,7 +107,7 @@ export default class User { 100 * difficulty * (level + 1) ** 2 - 85 * difficulty * level ** 2 )?.toLocaleString("en-US"); - const collector = reply.createMessageComponentCollector({ time: 60000 }); + const collector = reply.createMessageComponentCollector({ time: 30000 }); collector.on("collect", async (i: ButtonInteraction) => { if (i.message.id != (await reply.fetch()).id) return await errorEmbed( @@ -118,7 +118,7 @@ export default class User { if (i.user.id != interaction.user.id) return await errorEmbed(i, "You aren't the person who executed this command."); - collector.resetTimer({ time: 60000 }); + collector.resetTimer({ time: 30000 }); i.customId == "general" ? row.components[0].setDisabled(true) : row.components[1].setDisabled(true); diff --git a/src/commands/news/View.ts b/src/commands/news/View.ts index 1e723f8..bfc2da4 100644 --- a/src/commands/news/View.ts +++ b/src/commands/news/View.ts @@ -61,7 +61,7 @@ export default class View { ); const reply = await interaction.reply({ embeds: [getEmbed()], components: [row] }); - const collector = reply.createMessageComponentCollector({ time: 60000 }); + const collector = reply.createMessageComponentCollector({ time: 30000 }); collector.on("collect", async (i: ButtonInteraction) => { if (i.message.id != (await reply.fetch()).id) return await errorEmbed( @@ -72,7 +72,7 @@ export default class View { if (i.user.id != interaction.user.id) return await errorEmbed(i, "You aren't the person who executed this command."); - collector.resetTimer({ time: 60000 }); + collector.resetTimer({ time: 30000 }); switch (i.customId) { case "left": page--; diff --git a/src/utils/imageColor.ts b/src/utils/imageColor.ts index 4a14ff0..22a162c 100644 --- a/src/utils/imageColor.ts +++ b/src/utils/imageColor.ts @@ -11,7 +11,9 @@ import sharp from "sharp"; import { genRGBColor } from "./colorGen"; export async function imageColor(guildURL?: string, memberURL?: string) { - const imageBuffer = await (await fetch(guildURL! ?? memberURL)).arrayBuffer(); + if (!guildURL || !memberURL) return; + + const imageBuffer = await (await fetch(guildURL ?? memberURL)).arrayBuffer(); const { r, g, b } = ( await new Vibrant(await sharp(imageBuffer).toFormat("jpg").toBuffer()).getPalette() ).Vibrant!;