forgot to push it lmaoooooo is like 3 days

This commit is contained in:
NoLogicAlan committed 2026-04-16 16:01:18 +03:00
1 parent 6341f4e68f
commit 47b1615cbc
9 files changed
+136 -67

No files matched your search

+12 -12
View File
@@ -31,7 +31,7 @@ Remix is a free and open-source music bot for Fluxer, built using [fluxerjs](htt
## 🚀 Getting Started
Want to use Remix in your server right away?
Want to use Remix in your server right away?
1. **[Invite Remix](https://web.fluxer.app/oauth2/authorize?client_id=1478084469635211806&scope=bot&permissions=3206208)** to your Fluxer server.
2. Join a voice channel.
@@ -91,17 +91,17 @@ If you prefer to host Remix yourself, please note: **You must make it clear that
```
3. **Configure the bot:**
- Rename `config.example.json` to `config.json`.
- Fill out the missing values (Bot Token, DB credentials, etc.).
- *Note: You can generate Spotify credentials [here](https://developer.spotify.com/).*
- Configure your NodeLink instance inside the `config.json` file:
```json
"nodelink": {
"host": "localhost",
"port": 3000,
"password": "youshallnotpass"
}
```
- Rename `config.example.json` to `config.json`.
- Fill out the missing values (Bot Token, DB credentials, etc.).
- *Note: You can generate Spotify credentials [here](https://developer.spotify.com/).*
- Configure your NodeLink instance inside the `config.json` file:
```json
"nodelink": {
"host": "localhost",
"port": 3000,
"password": "youshallnotpass"
}
```
4. **Setup the Database:** *(See instructions below)*
+10 -3
View File
@@ -118,15 +118,22 @@ export async function run(msg) {
`⏱️ Session expires in ${Math.ceil(timeout / 60000)}m of inactivity`
].join("\n");
// avatarURL may be a plain property (Fluxer) or a method— call it if
// it's a function, otherwise use it as-is so the footer icon works in both cases.
const avatarUrl = typeof msg.author?.avatarURL === "function"
? msg.author.avatarURL()
: msg.author?.avatarURL ?? null;
const builder = new EmbedBuilder()
.setColor(getGlobalColor())
.setTitle("🎧 Music Player Controls")
.setDescription(description)
.setFooter({
text: `Requested by ${msg.author?.username || "Unknown"} • Controls active`,
iconURL: msg.author?.avatarURL
})
.setTimestamp();
iconURL: avatarUrl
});
// setTimestamp() is not verified on @fluxerjs/core's EmbedBuilder — guard it.
if (typeof builder.setTimestamp === "function") builder.setTimestamp();
if (current?.thumbnail) builder.setThumbnail(current.thumbnail);
return builder.toJSON();
};
+6 -1
View File
@@ -434,7 +434,12 @@ export async function run(message, data) {
// List all settings
const d = set.getAll();
const guildName = getGuildName(message);
const iconUrl = message.message?.guild?.iconURL?.() ?? null;
// Use the Fluxer CDN raw property pattern (guild.icon is a hash string, not a URL).
// guild.iconURL() is a method that does not exist on @fluxerjs/core Guild objects.
const rawGuild = message.message?.guild;
const iconUrl = rawGuild?.icon
? `https://cdn.fluxer.app/icons/${rawGuild.id}/${rawGuild.icon}.webp`
: null;
const lines = Object.entries(d)
.filter(([k]) => k !== "stay_247_mode") // surfaced inline with stay_247
+15 -22
View File
@@ -12,25 +12,16 @@ export const command = new CommandBuilder()
// ── User count ────────────────────────────────────────────────────────────────
async function fetchUserCount(client) {
const guildIds = Array.from(client.guilds.cache.keys());
if (guildIds.length === 0) return 0;
// client.rest is a concept and is not available on @fluxerjs/core.
// Use guild.memberCount (a cached integer Fluxer exposes on every Guild object)
// instead of paginating the REST members endpoint.
// Falls back to 0 per guild if the property is absent so the stat still renders.
try {
const counts = await Promise.all(guildIds.map(async (id) => {
let total = 0, after = "0", done = false;
try {
while (!done) {
const batch = await client.rest?.get(`/guilds/${id}/members?limit=1000&after=${after}`);
if (!batch?.length) { done = true; }
else {
total += batch.length;
done = batch.length < 1000;
if (!done) after = batch[batch.length - 1].user.id;
}
}
return total;
} catch { return 0; }
}));
return counts.reduce((a, b) => a + b, 0);
let total = 0;
for (const guild of client.guilds.cache.values()) {
total += guild.memberCount ?? guild.member_count ?? 0;
}
return total;
} catch { return 0; }
}
@@ -53,13 +44,15 @@ function buildEmbed({ guildCount, userCount, playerCount, ping, uptime, comHash,
`💬 [Community](https://fluxer.gg/Remix)`,
].filter(l => l !== null).join("\n");
return new EmbedBuilder()
const builder = new EmbedBuilder()
.setColor(getGlobalColor())
.setAuthor({ name: "Remix Music Bot" })
.setDescription(description)
.setFooter({ text: footer || "Remix Music Bot" })
.setTimestamp()
.toJSON();
.setFooter({ text: footer || "Remix Music Bot" });
// setTimestamp() is not verified on @fluxerjs/core's EmbedBuilder — call it only
// if the method exists so the command doesn't throw when building the embed.
if (typeof builder.setTimestamp === "function") builder.setTimestamp();
return builder.toJSON();
}
// ── Runner ────────────────────────────────────────────────────────────────────
+43 -12
View File
@@ -121,7 +121,9 @@ class Remix {
try {
let channel = client.channels.cache.get(cleanChannelId);
if (!channel || typeof channel.guild?.voiceAdapterCreator !== "function") {
if (!channel) {
// voiceAdapterCreator is a concept and not meaningful in Fluxer.
// A simple cache-miss check is sufficient — fetch only when not already cached.
try {
channel = await client.channels.fetch(cleanChannelId);
} catch (e) {
@@ -158,8 +160,12 @@ class Remix {
try {
const prefix = this.handler?.getPrefix?.(guildId) ?? "%";
const guild = this.client.guilds.cache.get(guildId);
// isTextBased() and permissionsFor() are APIs — use optional
// chaining so missing implementations fail gracefully. Fall back to channel_type
// string check which is the raw Fluxer gateway field.
const ch = guild?.channels?.cache?.find(c =>
c.isTextBased?.() && c.permissionsFor?.(this.client.user)?.has?.("SendMessages")
(c.isTextBased?.() ?? c.channel_type === "TextChannel" ?? true) &&
(c.permissionsFor?.(this.client.user)?.has?.("SendMessages") ?? true)
);
if (ch) {
const embed = new EmbedBuilder()
@@ -193,7 +199,8 @@ class Remix {
}
if (!ch) {
ch = guild?.channels?.cache?.find(c =>
c.isTextBased?.() && c.permissionsFor?.(this.client.user)?.has?.("SendMessages")
(c.isTextBased?.() ?? c.channel_type === "TextChannel" ?? true) &&
(c.permissionsFor?.(this.client.user)?.has?.("SendMessages") ?? true)
);
if (ch) this._announcementChannelCache.set(guildId, ch.id);
}
@@ -336,6 +343,9 @@ class Remix {
}
for (const [gId, guild] of client.guilds.cache) {
// guild.voice_states — raw snake_case array from @fluxerjs/core gateway payload (preferred).
// guild.voiceStates?.cache — voiceStateManager collection (fallback, may not exist).
// guild.voiceStates — bare iterable fallback if cache sub-property is absent.
const voiceStatesRaw =
guild.voice_states ??
guild.voiceStates?.cache ??
@@ -363,6 +373,11 @@ class Remix {
if (!wsListenerAttached) {
wsListenerAttached = true;
try {
// NOTE: client.ws.shards is declared private in @fluxerjs/ws, but there is
// no public API for attaching a raw message listener to the underlying socket.
// ws.send(shardId, payload) exists for sending, but not for receiving.
// This access is intentional — if @fluxerjs/core ever exposes a public
// onRawMessage() hook, replace these two lines with that API instead.
const shard0 = client.ws?.shards?.get?.(0);
const wsObj = shard0?.ws ?? null;
@@ -430,10 +445,15 @@ class Remix {
afk: false,
custom_status: { text: presenceContents[presenceIndex] },
};
const shard = client.ws.shards.get(0);
if (shard) {
shard.options.presence = presence;
shard.send({ op: GatewayOpcodes.PresenceUpdate, d: presence });
// Use the public ws.send(shardId, payload) API instead of accessing the
// private shards Map directly — shards is declared private in @fluxerjs/ws
// and accessing it works at runtime but breaks on any internal refactor.
if (client.ws?.send) {
client.ws.send(0, { op: GatewayOpcodes.PresenceUpdate, d: presence });
} else {
// Fallback: access shards directly only if public API is unavailable
const shard = client.ws?.shards?.get?.(0);
if (shard) shard.send({ op: GatewayOpcodes.PresenceUpdate, d: presence });
}
presenceIndex = (presenceIndex + 1) % presenceContents.length;
};
@@ -562,7 +582,7 @@ class Remix {
// Track previous voice state per-user so we can detect channel moves.
// @fluxerjs/core fires VoiceStateUpdate with ONE arg (raw gateway data),
// not two args (oldState, newState) like discord.js. We maintain prev state manually.
// not two args (oldState, newState) We maintain prev state manually.
const _prevVoiceState = new Map(); // userId → { channelId, guildId }
client.on(Events.VoiceStateUpdate, (data) => {
@@ -818,25 +838,36 @@ class Remix {
const observed = self.observedVoiceUsers.get(userId);
if (observed && observed.guildId === guildId) return observed.channelId;
// vm.getVoiceChannelId() is an unverified @fluxerjs/voice method — optional-chained
// so it fails silently and falls through to the next strategy if absent.
try {
const vm = getVoiceManager(client);
const channelId = vm?.getVoiceChannelId?.(guildId, userId);
if (channelId) return seed(channelId);
} catch (_) {}
// @fluxerjs/core member objects may not carry a .voice property.
// Optional-chained so it's a silent no-op if absent.
const memberVoice =
message?.member?.voice?.channelId ??
message?.message?.member?.voice?.channelId ??
null;
if (memberVoice) return seed(memberVoice);
// @fluxerjs/core may expose voice states differently (e.g. raw voice_states array
// on the guild object from the gateway payload, which is handled in GuildCreate).
// The dual snake_case/camelCase probe covers both shapes.
try {
const guild = client.guilds.cache.get(guildId);
const voiceStates = guild?.voiceStates?.cache ?? guild?.voiceStates ?? null;
// guild.voice_states = raw array from gateway (Fluxer-native)
// guild.voiceStates?.cache = VoiceStateManager (fallback)
const voiceStates = guild?.voice_states ?? guild?.voiceStates?.cache ?? guild?.voiceStates ?? null;
if (voiceStates) {
const entries = typeof voiceStates.values === "function"
? voiceStates.values()
: Object.values(voiceStates);
const entries = Array.isArray(voiceStates)
? voiceStates
: typeof voiceStates.values === "function"
? voiceStates.values()
: Object.values(voiceStates);
for (const state of entries) {
const sid = state.userId ?? state.user_id ?? state.id;
const sch = state.channelId ?? state.channel_id;
+11 -4
View File
@@ -61,7 +61,7 @@ export class CommandRequirement {
}
setOwnerOnly(bool) { this.ownerOnly = bool; return this; }
/**
* @param {string} p Fluxer permission string (discord.js-style, e.g. "ManageChannels", "ManageGuild")
* @param {string} p Fluxer permission string (ManageChannels", "ManageGuild")
*/
addPermission(p) { this.permissions.push(p); return this; }
addPermissions(...p) { this.permissions.push(...p); return this; }
@@ -70,7 +70,7 @@ export class CommandRequirement {
}
export class Option {
// Fluxer uses discord.js-like channel mentions: <#id> and user mentions <@id>
// Fluxer uses channel mentions: <#id> and user mentions <@id>
channelRegex = /^<#(?<id>\d+)>/;
userRegex = /^<@!?(?<id>\d+)>/;
idRegex = /^(?<id>\d+)/;
@@ -602,7 +602,7 @@ export class CommandHandler extends EventEmitter {
}
/**
* Checks requirements using fluxerjs (discord.js-like) permission API.
* Checks requirements using fluxerjs permission API.
*/
assertRequirements(cmd, msg) {
const authorId = msg.message?.author?.id;
@@ -625,7 +625,14 @@ export class CommandHandler extends EventEmitter {
}
} else {
// not cached — fetch async and re-run
guild.fetchMember(authorId).then(member => {
// guild.fetchMember(id) is a Fluxer shorthand; guild.members.fetch(id) is the
// standard compatible form. Try both so either API name works.
const fetchPromise = typeof guild.fetchMember === "function"
? guild.fetchMember(authorId)
: typeof guild.members?.fetch === "function"
? guild.members.fetch(authorId)
: Promise.reject(new Error("No member fetch API available"));
fetchPromise.then(member => {
const missing = req.permissions.filter(p => !member.permissions.has(PermissionFlags[p] ?? p));
if (missing.length > 0) {
this.replyHandler(req.permissionError, msg);
+21 -10
View File
@@ -2,11 +2,13 @@ import { Client, Events, EmbedBuilder } from "@fluxerjs/core";
import { logger } from "./constants/Logger.mjs";
import { Utils } from "./Utils.mjs";
/** Parse a color value from config — accepts hex string "0xe9196c" or number */
/** Parse a color value from config — accepts hex string "0xe9196c", "#e9196c", or number */
export function parseColor(value, fallback = 0xe9196c) {
if (!value) return fallback;
if (typeof value === "number") return value;
const n = parseInt(value, 16);
// Strip leading # ("‌#ff0000" → "ff0000") or 0x prefix ("0xe9196c" → "e9196c")
const cleaned = String(value).replace(/^#/, "").replace(/^0x/i, "");
const n = parseInt(cleaned, 16);
return isNaN(n) ? fallback : n;
}
@@ -74,9 +76,13 @@ export class MessageHandler {
*/
checkPermissions(permissions, channel) {
if (!channel?.guild) return []; // DMs — no guild perms
const me = channel.guild.members.me;
if (!me) return []; // ← change: can't verify, assume OK instead of blocking
const perms = channel.permissionsFor(me);
// guild.members.me and channel.permissionsFor()
// @fluxerjs/core may expose them or may not — guard with optional chaining so
// a missing implementation fails open (assume OK) rather than throwing.
const me = channel.guild.members?.me ?? null;
if (!me) return []; // can't verify — assume OK
const perms = channel.permissionsFor?.(me) ?? null;
if (!perms) return []; // API unavailable — assume OK
return permissions.filter(p => !perms.has(p));
}
@@ -125,10 +131,10 @@ export class MessageHandler {
* @returns {Message|null}
*/
get(id) {
// fluxerjs messages are per-channel; search across cached channels
// 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()) {
if (!channel.messages) continue;
const msg = channel.messages.cache.get(id);
const msg = channel.messages?.cache?.get?.(id) ?? null;
if (msg) return new Message(msg, this);
}
return null;
@@ -144,7 +150,12 @@ export class MessageHandler {
const cached = this.get(id);
if (cached) return cached;
const channel = await this.client.channels.fetch(channelId);
return new Message(await channel.messages.fetch(id), this);
// channel.fetchMessage() is the @fluxerjs/core method.
// Fall back to the channel.messages.fetch() if the former is absent.
const raw = typeof channel.fetchMessage === "function"
? await channel.fetchMessage(id)
: await channel.messages?.fetch?.(id);
return raw ? new Message(raw, this) : null;
}
/**
@@ -393,7 +404,7 @@ export class MessageHandler {
const { joinVoiceChannel } = await import("@fluxerjs/voice");
const channel = await this.client.channels.fetch(channelId);
if (!channel || !("guildId" in channel)) throw new Error("Cannot join a non-guild voice channel.");
// @fluxerjs/voice API: joinVoiceChannel(client, channel) — NOT the old discord-voip object style
// @fluxerjs/voice API: joinVoiceChannel(client, channel) — NOT the old object style
return joinVoiceChannel(this.client, channel);
}
}
+13 -2
View File
@@ -99,13 +99,21 @@ export class MoonlinkManager extends EventEmitter {
}
/**
* Send voice payload to Discord via Fluxer's WebSocket
* Send voice payload to Fluxer's WebSocket
* @param {string} guildId
* @param {{ op: number, d: object }} payload
* @private
*/
_sendPayload(guildId, payload) {
try {
// Prefer the public ws.send(shardId, payload) API — shards is a private field
// in @fluxerjs/ws and accessing it directly risks breaking on internal refactors.
if (typeof this._client?.ws?.send === "function") {
this._client.ws.send(0, payload);
return;
}
// Fallback: access shard directly only if the public API is unavailable
const shard = this._client?.ws?.shards?.get?.(0);
if (!shard) {
logger.warn("[MoonlinkManager] No WebSocket shard available");
@@ -132,7 +140,6 @@ export class MoonlinkManager extends EventEmitter {
_setupVoiceForwarding(client) {
// @fluxerjs/core emits VoiceStateUpdate with a SINGLE argument:
// (data: GatewayVoiceStateUpdateDispatchData) — raw gateway snake_case fields.
// This is NOT discord.js style (oldState, newState).
client.on(Events.VoiceStateUpdate, (data) => {
try {
// data is the raw GatewayVoiceStateUpdateDispatchData — always snake_case
@@ -174,6 +181,10 @@ export class MoonlinkManager extends EventEmitter {
// on gateway reconnects. Without this, each reconnect stacks another handler on the socket.
const attachRawWs = () => {
try {
// NOTE: client.ws.shards is private in @fluxerjs/ws. There is no public API for
// attaching a raw inbound message listener — ws.send() only covers outbound.
// This access is intentional. If @fluxerjs/core exposes a public onRawMessage()
// hook in a future release, replace shard0/wsObj extraction with that API.
const shard0 = client.ws?.shards?.get?.(0);
const wsObj = shard0?.ws ?? null;
if (!wsObj) return;
+5 -1
View File
@@ -137,8 +137,12 @@ export class RemoteSettingsManager extends EventEmitter {
return this.remoteSave(server);
}
// Use mysql.escape() for every user-supplied value to prevent SQL injection.
// Preserve native boolean/number types — mysql.escape(String(false)) stores "false"
// (a truthy string) which breaks strict equality checks like songAnnouncements === false.
const escapedPath = mysql.escape(`$.${key}`);
const escapedVal = mysql.escape(String(val));
const escapedVal = (typeof val === "boolean" || typeof val === "number")
? mysql.escape(val)
: mysql.escape(String(val));
const escapedId = mysql.escape(server.id);
const r = await this.query(`UPDATE settings SET data = JSON_SET(data, ${escapedPath}, ${escapedVal}) WHERE id=${escapedId}`);
if (r.error) logger.error("[Settings] remoteUpdate error:", r.error);