mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-23 21:52:45 -05:00
ok that alot
This commit is contained in:
1 parent
df1a783fde
commit
5f33ee231d
17 files changed
+64
-47
No files matched your search
@@ -553,7 +553,6 @@ export class CommandHandler extends EventEmitter {
|
||||
let usedArgumentCount = 0;
|
||||
|
||||
for (let i = 0, argIndex = 1; i < options.length; i++) {
|
||||
if (options[i] instanceof Flag) i++;
|
||||
const o = options[i];
|
||||
if (o?.type === "text") { texts.push(o); continue; }
|
||||
if ((args[argIndex] || "").startsWith("-")) {
|
||||
|
||||
@@ -538,7 +538,7 @@ export class GatewayHandler {
|
||||
logger.guild(`[GuildDelete] Removed from server ${guildId} — cleaning up.`);
|
||||
|
||||
for (const [channelId, player] of remix.players.playerMap) {
|
||||
if (!player._guildId || player._guildId === guildId) {
|
||||
if (!player._guildId || String(player._guildId).replace(/\D/g, "") === String(guildId).replace(/\D/g, "")) {
|
||||
remix.players.playerMap.delete(channelId);
|
||||
try { player.leave().catch(() => {}); } catch (_) {}
|
||||
try { player.destroy(); } catch (_) {}
|
||||
@@ -547,10 +547,10 @@ export class GatewayHandler {
|
||||
}
|
||||
|
||||
for (const [userId, info] of [...remix.observedVoiceUsers]) {
|
||||
if (info.guildId === guildId) remix.observedVoiceUsers.delete(userId);
|
||||
if (String(info.guildId).replace(/\D/g, "") === String(guildId).replace(/\D/g, "")) remix.observedVoiceUsers.delete(userId);
|
||||
}
|
||||
for (const [userId, info] of [...remix.observedVoiceBots]) {
|
||||
if (info.guildId === guildId) remix.observedVoiceBots.delete(userId);
|
||||
if (String(info.guildId).replace(/\D/g, "") === String(guildId).replace(/\D/g, "")) remix.observedVoiceBots.delete(userId);
|
||||
}
|
||||
for (const [stateKey, info] of [...this._prevVoiceState]) {
|
||||
if (String(info.guildId).replace(/\D/g, "") === String(guildId).replace(/\D/g, ""))
|
||||
|
||||
@@ -319,7 +319,7 @@ export class MessageHandler {
|
||||
async sendMessage(channel, message) {
|
||||
if (this.checkPermissions(["SendMessages"], channel).length !== 0) {
|
||||
logger.warn("[MessageHandler] Missing SendMessages permission in channel", channel.id);
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
let opts;
|
||||
if (typeof message === "string") {
|
||||
|
||||
+1
-1
@@ -891,7 +891,7 @@ export default class Player extends EventEmitter {
|
||||
}
|
||||
if (![200, 204, 206].includes(res.statusCode)) {
|
||||
res.resume();
|
||||
return reject(new Error(`HTTP ${res.statusCode} at ${target}`));
|
||||
return reject(new Error(`HTTP ${res.statusCode}`));
|
||||
}
|
||||
if (returnStream) return resolve(res);
|
||||
|
||||
|
||||
@@ -921,7 +921,7 @@ export class PlayerManager {
|
||||
if (current.title !== song.title && current.url !== song.url) return;
|
||||
if (player._paused) return; // don't scrobble if paused
|
||||
|
||||
const playedMs = Date.now() - (player.startedPlaying ?? startedAtMs);
|
||||
const playedMs = Date.now() - (player.startedPlaying ?? startedAtMs ?? Date.now());
|
||||
if (lastfm.shouldScrobble(song, playedMs)) {
|
||||
for (const userId of humanUserIds) {
|
||||
lastfm.scrobble(userId, song, startedAtMs).catch(() => {});
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ export class RemoteSettingsManager extends EventEmitter {
|
||||
// exponential backoff with a cap of 30s instead of forever-at-2s
|
||||
const delay = Math.min(1000 * Math.pow(2, this._loadAttempts - 1), 30_000);
|
||||
logger.error("[Settings] Init error (attempt", this._loadAttempts, "retrying in", delay + "ms):", res.error);
|
||||
return setTimeout(() => { this.load(); }, delay);
|
||||
return setTimeout(() => { this.load().catch(err => logger.error("[Settings] Retry load error:", err?.message ?? err)); }, delay);
|
||||
}
|
||||
this._loadAttempts = 0;
|
||||
res.results.forEach((r) => {
|
||||
|
||||
@@ -13,6 +13,7 @@ class StreamMerger extends Transform {
|
||||
}
|
||||
_transform(chunk, _enc, cb) {
|
||||
if (!this.ffmpeg) { this.push(chunk); return cb(); }
|
||||
if (!this.ffmpeg.stdio?.[3]?.writable) { this.push(chunk); return cb(); }
|
||||
this.ffmpeg.stdio[3].write(chunk);
|
||||
cb();
|
||||
}
|
||||
|
||||
@@ -38,28 +38,30 @@ class Tuna {
|
||||
});
|
||||
}
|
||||
search(query, page = 1, size = 10) {
|
||||
return new Promise(async res => {
|
||||
const results = await this.get("/v1/sounds/search", { size, page, search: query });
|
||||
return this.get("/v1/sounds/search", { size, page, search: query }).then(results => {
|
||||
results.items = results.items.map(s => {
|
||||
s.download = function() {
|
||||
return new Promise(resolve => {
|
||||
https.get(this.oggPath, (r) => { resolve(r); });
|
||||
return new Promise((resolve, reject) => {
|
||||
const req = https.get(this.oggPath, (r) => { resolve(r); });
|
||||
req.on("error", (err) => { reject(err); });
|
||||
req.setTimeout(15_000, () => { req.destroy(); reject(new Error("Tuna download timeout")); });
|
||||
});
|
||||
};
|
||||
return s;
|
||||
});
|
||||
res(results);
|
||||
return results;
|
||||
});
|
||||
}
|
||||
getSound(id) {
|
||||
return new Promise(async res => {
|
||||
const sound = await this.get("/v1/sounds/" + id);
|
||||
return this.get("/v1/sounds/" + id).then(sound => {
|
||||
sound.download = function() {
|
||||
return new Promise(res => {
|
||||
https.get(this.oggPath, (result) => { res(result); });
|
||||
return new Promise((resolve, reject) => {
|
||||
const req = https.get(this.oggPath, (result) => { resolve(result); });
|
||||
req.on("error", (err) => { reject(err); });
|
||||
req.setTimeout(15_000, () => { req.destroy(); reject(new Error("Tuna download timeout")); });
|
||||
});
|
||||
};
|
||||
res(sound);
|
||||
return sound;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+15
-3
@@ -300,7 +300,7 @@ class YTUtils extends EventEmitter {
|
||||
|
||||
let tracks = [];
|
||||
if (data.loadType === "search") tracks = data.data ?? [];
|
||||
else if (data.loadType === "track") tracks = [data.data];
|
||||
else if (data.loadType === "track") tracks = data.data ? [data.data] : [];
|
||||
else if (data.loadType === "playlist") tracks = data.data?.tracks ?? [];
|
||||
|
||||
const resultTracks = this._rankTracks(tracks, provider);
|
||||
@@ -335,12 +335,18 @@ class YTUtils extends EventEmitter {
|
||||
}
|
||||
|
||||
// Handle single track
|
||||
if (data.loadType === "track") {
|
||||
if (data.loadType === "track" && data.data) {
|
||||
const video = trackToVideo(data.data);
|
||||
if (!video) return { type: "error", data: "Failed to parse track data." };
|
||||
this.emit("message", `Successfully added [${video.title}](${video.url}) to the queue.`);
|
||||
return { type: "video", data: video };
|
||||
}
|
||||
|
||||
if (data.loadType === "track" && !data.data) {
|
||||
this.emit("message", `**Track data was empty for '${query}'.**`);
|
||||
return { type: "error", data: "Empty track data returned." };
|
||||
}
|
||||
|
||||
// Handle search results (take first)
|
||||
if (data.loadType === "search" && data.data?.length) {
|
||||
const bestTrack = this._pickBestTrack(data.data, provider) ?? data.data[0];
|
||||
@@ -383,12 +389,18 @@ class YTUtils extends EventEmitter {
|
||||
}
|
||||
|
||||
// Single track from search
|
||||
if (data.loadType === "track") {
|
||||
if (data.loadType === "track" && data.data) {
|
||||
const video = trackToVideo(data.data);
|
||||
if (!video) return { type: "error", data: "Failed to parse track data." };
|
||||
this.emit("message", `Successfully added [${video.title}](${video.url}) to the queue.`);
|
||||
return { type: "video", data: video };
|
||||
}
|
||||
|
||||
if (data.loadType === "track" && !data.data) {
|
||||
this.emit("message", `**Track data was empty for '${query}'.**`);
|
||||
return { type: "error", data: "Empty track data returned." };
|
||||
}
|
||||
|
||||
// Nothing found
|
||||
this.emit("message", `**No results found for '${query}'.**`);
|
||||
return { type: "error", data: null, error: "No results found" };
|
||||
|
||||
Reference in new issue
Block a user