mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-23 21:52:45 -05:00
fix: migrate all commands & src to @fluxerjs native API
- Replace replyEmbed/sendEmbed/editEmbed with reply/send/edit across all 33 command files and 5 src/ files - Remove unnecessary .toJSON() on EmbedBuilder (Fluxer auto-converts) - Fix voice channel type checks: channel_type === "VoiceChannel" → type === 2 - Add missing edit() and send() methods to Message/ChannelContext wrappers - Fix filter command: reactions now update per page on navigation Closes channel cache crash (guild.channels.cache.keys undefined)
This commit is contained in:
1 parent
19820e7209
commit
85f11fe34b
38 files changed
+395
-314
No files matched your search
+27
-11
@@ -133,8 +133,8 @@ export class MessageHandler {
|
||||
get(id) {
|
||||
// channel.messages is a MessageManager — @fluxerjs/core may not expose it.
|
||||
// Guard with optional chaining so the loop is a no-op if the property is absent.
|
||||
for (const channel of this.client.channels.cache.values()) {
|
||||
const msg = channel.messages?.cache?.get?.(id) ?? null;
|
||||
for (const channel of this.client.channels.values()) {
|
||||
const msg = channel.messages?.get?.(id) ?? null;
|
||||
if (msg) return new Message(msg, this);
|
||||
}
|
||||
return null;
|
||||
@@ -164,7 +164,7 @@ export class MessageHandler {
|
||||
* @returns {Channel}
|
||||
*/
|
||||
getChannel(id) {
|
||||
const c = this.client.channels.cache.get(id);
|
||||
const c = this.client.channels.get(id);
|
||||
return new Channel(c, this);
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ export class MessageHandler {
|
||||
}
|
||||
}
|
||||
|
||||
return builder.toJSON();
|
||||
return builder;
|
||||
}
|
||||
|
||||
#createEmbed(text, message, options = {}) {
|
||||
@@ -384,7 +384,7 @@ export class MessageHandler {
|
||||
const currPage = { n: 0 };
|
||||
const send = () => builder.getPage(currPage.n);
|
||||
|
||||
const m = await msg.replyEmbed(send());
|
||||
const m = await msg.reply(send());
|
||||
if (!m) return;
|
||||
|
||||
m.message.react(arrows[0]).catch(() => {});
|
||||
@@ -396,13 +396,13 @@ export class MessageHandler {
|
||||
} else {
|
||||
currPage.n = Math.min(pages.length - 1, currPage.n + 1);
|
||||
}
|
||||
m.editEmbed(send()).catch(() => {});
|
||||
m.edit(send()).catch(() => {});
|
||||
});
|
||||
|
||||
// Auto-close after 5 minutes
|
||||
setTimeout(() => {
|
||||
unobserve();
|
||||
m.editEmbed(send() + "\nSession closed - Changing pages **won't work** from here.").catch(() => {});
|
||||
m.edit(send() + "\nSession closed - Changing pages **won't work** from here.").catch(() => {});
|
||||
}, 5 * 60 * 1000);
|
||||
}
|
||||
|
||||
@@ -482,6 +482,14 @@ export class Channel {
|
||||
return this.handler.sendMessage(this.channel, content);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string|Object} content
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
send(content) {
|
||||
return this.handler.sendMessage(this.channel, content);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string|Object} content
|
||||
* @param {Object} embedOptions
|
||||
@@ -582,6 +590,15 @@ export class Message {
|
||||
editEmbed(content, embedOptions = {}) {
|
||||
return this.handler.editEmbed(this.message, content, embedOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string|Object} content
|
||||
* @param {Object} embedOptions
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
edit(content, embedOptions = {}) {
|
||||
return this.handler.editEmbed(this.message, content, embedOptions);
|
||||
}
|
||||
}
|
||||
|
||||
export class PageBuilder {
|
||||
@@ -731,8 +748,7 @@ export class RichPaginator {
|
||||
.setAuthor({ name: tab.header })
|
||||
.setTitle(tab.title)
|
||||
.setDescription(content)
|
||||
.setFooter({ text: footerParts.join(" ") })
|
||||
.toJSON();
|
||||
.setFooter({ text: footerParts.join(" ") });
|
||||
}
|
||||
|
||||
async send() {
|
||||
@@ -1142,13 +1158,13 @@ export class HelpCommand {
|
||||
c.aliases.some(a => a.toLowerCase() === word.toLowerCase())
|
||||
);
|
||||
if (!found) {
|
||||
msg.replyEmbed(`❌ Unknown command \`${word}\`. Use \`${prefix}help\` to browse.`);
|
||||
msg.reply(`❌ Unknown command \`${word}\`. Use \`${prefix}help\` to browse.`);
|
||||
return;
|
||||
}
|
||||
currCmd = found;
|
||||
}
|
||||
if (currCmd) {
|
||||
msg.replyEmbed(this._commands.helpHandler.getCommandHelp(currCmd, msg));
|
||||
msg.reply(this._commands.helpHandler.getCommandHelp(currCmd, msg));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user