mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
cleannnn
This commit is contained in:
1 parent
05fb38aabd
commit
bc1fe82919
43 files changed
+122
-1784
No files matched your search
+2
-17
@@ -8,13 +8,11 @@ export const command = new CommandBuilder()
|
||||
.setRequirement(r => r.setOwnerOnly(true))
|
||||
.setCategory("util");
|
||||
|
||||
// Auto-remove timer: 1 minute
|
||||
const EMOJI_REMOVE_TIMEOUT = 60000;
|
||||
|
||||
export async function run(msg) {
|
||||
const guilds = [...this.client.guilds.values()];
|
||||
|
||||
// Fallback if the bot is in 0 servers
|
||||
if (guilds.length === 0) {
|
||||
const emptyEmbed = new EmbedBuilder()
|
||||
.setColor(getGlobalColor())
|
||||
@@ -27,8 +25,6 @@ export async function run(msg) {
|
||||
const MAX_DESC = 4096;
|
||||
const pages = [];
|
||||
|
||||
// Build pages dynamically — each page accumulates lines until it would
|
||||
// exceed the 4096-char description limit, then starts a new page.
|
||||
let currentLines = [];
|
||||
let currentLen = 0;
|
||||
|
||||
@@ -37,7 +33,7 @@ export async function run(msg) {
|
||||
let name = g.name || "unknown";
|
||||
if (name.length > 40) name = name.slice(0, 37) + "...";
|
||||
const line = `${i + 1}. **${name}** (\`${g.id}\`)`;
|
||||
const addedLen = line.length + (currentLines.length ? 1 : 0); // +1 for \n
|
||||
const addedLen = line.length + (currentLines.length ? 1 : 0);
|
||||
|
||||
if (currentLen + addedLen > MAX_DESC - 20 && currentLines.length > 0) {
|
||||
pages.push(currentLines.join("\n"));
|
||||
@@ -53,7 +49,6 @@ export async function run(msg) {
|
||||
|
||||
let currentPage = 0;
|
||||
|
||||
// Helper function to generate the embed for a specific page
|
||||
const buildPageContent = (pageIdx, expired = false) => {
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(getGlobalColor())
|
||||
@@ -71,10 +66,8 @@ export async function run(msg) {
|
||||
return { embeds: [embed] };
|
||||
};
|
||||
|
||||
// Send the initial message using the framework's wrapper
|
||||
const replyMsg = await msg.reply(buildPageContent(0));
|
||||
|
||||
// Safety check and single-page exit
|
||||
if (!replyMsg?.message) return;
|
||||
if (totalPages <= 1) return;
|
||||
|
||||
@@ -82,12 +75,10 @@ export async function run(msg) {
|
||||
let unobserve = null;
|
||||
let emojiTimeout = null;
|
||||
|
||||
// Add reactions
|
||||
for (const emoji of navEmojis) {
|
||||
await replyMsg.message.react(emoji).catch(() => {});
|
||||
}
|
||||
|
||||
// Helper: Clear all reactions (matches player.mjs fallback logic)
|
||||
const clearReactions = async () => {
|
||||
try {
|
||||
await replyMsg.message.removeAllReactions();
|
||||
@@ -100,7 +91,6 @@ export async function run(msg) {
|
||||
}
|
||||
};
|
||||
|
||||
// Helper: Reset the expiration timer
|
||||
const resetTimer = () => {
|
||||
clearTimeout(emojiTimeout);
|
||||
emojiTimeout = setTimeout(async () => {
|
||||
@@ -110,22 +100,17 @@ export async function run(msg) {
|
||||
}, EMOJI_REMOVE_TIMEOUT);
|
||||
};
|
||||
|
||||
// Start listening for reactions using the framework's native listener
|
||||
unobserve = replyMsg.onReaction(navEmojis, async (e) => {
|
||||
resetTimer(); // Reset the 1-minute timer when interacting
|
||||
resetTimer();
|
||||
|
||||
if (e.emoji_id === "⬅️") {
|
||||
// Go backward (loops to the end if on the first page)
|
||||
currentPage = currentPage > 0 ? currentPage - 1 : totalPages - 1;
|
||||
} else if (e.emoji_id === "➡️") {
|
||||
// Go forward (loops to the beginning if on the last page)
|
||||
currentPage = currentPage < totalPages - 1 ? currentPage + 1 : 0;
|
||||
}
|
||||
|
||||
// Update the embed using the framework's native edit method
|
||||
await replyMsg.edit(buildPageContent(currentPage)).catch(() => {});
|
||||
});
|
||||
|
||||
// Start the initial countdown
|
||||
resetTimer();
|
||||
}
|
||||
Reference in new issue
Block a user