mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
fix: resolve bugs in voice, filter, dashboard, and stats handling
- Fix filter command using stale track reference instead of current queue track - Fix playnext null check before editing status message - Fix join command using raw channel ID before cleaning it - Fix GatewayHandler passing wrong isBot flag in voice state cache - Fix Dashboard shared server filtering (was returning empty, now filters correctly) - Fix avatar fallback using discriminator (deprecated) → use user ID instead - Refactor Player.mjs: extract ConnectionState/LKRoomEvent to FluxerRevoice constants - Refactor Player.mjs: replace local formatMsHelper with Utils.prettifyMS - Add Logger.guild() method; use it in GatewayHandler instead of logger.info() - Remove rbl-stats module from modules.json - Remove unused empty event listeners in PlayerManager - Remove unused CRITICAL_PERMISSIONS import from GatewayHandler
This commit is contained in:
1 parent
58464e6862
commit
b581722c46
19 files changed
+45
-92
No files matched your search
@@ -9,7 +9,6 @@ export const command = new CommandBuilder()
|
|||||||
.addAliases("ap");
|
.addAliases("ap");
|
||||||
|
|
||||||
export async function run(msg, data) {
|
export async function run(msg, data) {
|
||||||
const prefix = this.handler?.getPrefix?.(msg.message?.guildId) ?? "%";
|
|
||||||
const p = await this.getPlayer(msg, true, true, false);
|
const p = await this.getPlayer(msg, true, true, false);
|
||||||
if (!p) return;
|
if (!p) return;
|
||||||
|
|
||||||
@@ -19,7 +18,7 @@ export async function run(msg, data) {
|
|||||||
if (!p._autoplayHandler) {
|
if (!p._autoplayHandler) {
|
||||||
p._autoplayHandler = async () => {
|
p._autoplayHandler = async () => {
|
||||||
if (!p._autoplay) return;
|
if (!p._autoplay) return;
|
||||||
if (p.queue?.getCurrent() || !p.queue?.isEmpty()) return;
|
if (p.queue?.getCurrent() && !p.queue?.isEmpty()) return;
|
||||||
|
|
||||||
const lastTrack = p._lastPlayedTrack;
|
const lastTrack = p._lastPlayedTrack;
|
||||||
if (!lastTrack) return;
|
if (!lastTrack) return;
|
||||||
|
|||||||
@@ -79,15 +79,6 @@ export async function run(msg, data) {
|
|||||||
|
|
||||||
{
|
{
|
||||||
let groupJson = "";
|
let groupJson = "";
|
||||||
let groupStart = 0;
|
|
||||||
|
|
||||||
const flushGroup = () => {
|
|
||||||
if (!groupJson) return;
|
|
||||||
const codeBlock = "```json\n" + groupJson + "\n```";
|
|
||||||
pages.push(codeBlock.slice(0, MAX_DESC));
|
|
||||||
groupJson = "";
|
|
||||||
groupStart = i;
|
|
||||||
};
|
|
||||||
|
|
||||||
let i = 0;
|
let i = 0;
|
||||||
for (i = 0; i < servers.length; i++) {
|
for (i = 0; i < servers.length; i++) {
|
||||||
|
|||||||
+1
-1
@@ -403,7 +403,7 @@ export async function run(msg) {
|
|||||||
await menuMsg.edit({ embeds: [errEmbed] }).catch(() => {});
|
await menuMsg.edit({ embeds: [errEmbed] }).catch(() => {});
|
||||||
await Utils.sleep(1500);
|
await Utils.sleep(1500);
|
||||||
await menuMsg.edit({
|
await menuMsg.edit({
|
||||||
embeds: [buildPageEmbed(this.t.bind(this), msg, page, activeKeys, track)]
|
embeds: [buildPageEmbed(this.t.bind(this), msg, page, activeKeys, player.queue.getCurrent())]
|
||||||
}).catch(() => {});
|
}).catch(() => {});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export async function run(msg, data) {
|
|||||||
const cid = cleanId(data.get("channelId").value);
|
const cid = cleanId(data.get("channelId").value);
|
||||||
const targetChannel = this.client.channels.get(cid);
|
const targetChannel = this.client.channels.get(cid);
|
||||||
if (!targetChannel) return msg.reply(embed(this.t(msg, "responses.forceleave.channelNotFound")));
|
if (!targetChannel) return msg.reply(embed(this.t(msg, "responses.forceleave.channelNotFound")));
|
||||||
if (cleanId(msg.message.guildId) !== cleanId(targetChannel.guildId))
|
if (cleanId(msg.message?.guildId) !== cleanId(targetChannel.guildId))
|
||||||
return msg.reply(embed(this.t(msg, "responses.forceleave.wrongServer")));
|
return msg.reply(embed(this.t(msg, "responses.forceleave.wrongServer")));
|
||||||
const p = this.players.playerMap.get(cid)
|
const p = this.players.playerMap.get(cid)
|
||||||
?? [...this.players.playerMap.values()].find((player) => cleanId(player?._channelId) === cid);
|
?? [...this.players.playerMap.values()].find((player) => cleanId(player?._channelId) === cid);
|
||||||
|
|||||||
+2
-2
@@ -19,13 +19,13 @@ function cleanId(value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function joinChannel(message, cid, cb = () => {}, ecb = () => {}) {
|
export async function joinChannel(message, cid, cb = () => {}, ecb = () => {}) {
|
||||||
if (!this.client.channels.has(cid)) {
|
const cleanChannelId = cleanId(cid);
|
||||||
|
if (!this.client.channels.has(cleanChannelId)) {
|
||||||
ecb();
|
ecb();
|
||||||
const embed = new EmbedBuilder().setColor(getGlobalColor())
|
const embed = new EmbedBuilder().setColor(getGlobalColor())
|
||||||
.setDescription(this.t(message, "responses.join.channelNotFound", { channel: cid }));
|
.setDescription(this.t(message, "responses.join.channelNotFound", { channel: cid }));
|
||||||
return message.reply({ embeds: [embed] });
|
return message.reply({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
const cleanChannelId = cleanId(cid);
|
|
||||||
const existing = this.players.playerMap.get(cleanChannelId)
|
const existing = this.players.playerMap.get(cleanChannelId)
|
||||||
?? [...this.players.playerMap.values()].find((player) => cleanId(player?._channelId) === cleanChannelId);
|
?? [...this.players.playerMap.values()].find((player) => cleanId(player?._channelId) === cleanChannelId);
|
||||||
if (existing) {
|
if (existing) {
|
||||||
|
|||||||
+2
-2
@@ -991,7 +991,7 @@ export async function run(msg, data) {
|
|||||||
fields.push({ name: "Listeners", value: Utils.formatNumber(info.stats?.listeners ?? 0), inline: true });
|
fields.push({ name: "Listeners", value: Utils.formatNumber(info.stats?.listeners ?? 0), inline: true });
|
||||||
fields.push({ name: "Global Plays", value: Utils.formatNumber(info.stats?.playcount ?? 0), inline: true });
|
fields.push({ name: "Global Plays", value: Utils.formatNumber(info.stats?.playcount ?? 0), inline: true });
|
||||||
|
|
||||||
if (info.userplaycount !== null && user) {
|
if (info.userplaycount != null && user) {
|
||||||
fields.push({ name: "Your Plays", value: Utils.formatNumber(info.userplaycount), inline: true });
|
fields.push({ name: "Your Plays", value: Utils.formatNumber(info.userplaycount), inline: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1085,7 +1085,7 @@ export async function run(msg, data) {
|
|||||||
fields.push({ name: "Artist", value: info.artist, inline: true });
|
fields.push({ name: "Artist", value: info.artist, inline: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.userplaycount !== null && user) {
|
if (info.userplaycount != null && user) {
|
||||||
fields.push({ name: "Your Plays", value: Utils.formatNumber(info.userplaycount), inline: true });
|
fields.push({ name: "Your Plays", value: Utils.formatNumber(info.userplaycount), inline: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -294,7 +294,7 @@ export async function run(msg) {
|
|||||||
try {
|
try {
|
||||||
switch (control.action) {
|
switch (control.action) {
|
||||||
case "previous":
|
case "previous":
|
||||||
reply = this.t(msg, "responses.player.previousNotImplemented");
|
reply = "Previous track is not available yet.";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "resume":
|
case "resume":
|
||||||
|
|||||||
@@ -55,6 +55,6 @@ export async function run(message, data) {
|
|||||||
const messages = p.playFirst(query, provider);
|
const messages = p.playFirst(query, provider);
|
||||||
messages.on("message", d => {
|
messages.on("message", d => {
|
||||||
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(d);
|
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(d);
|
||||||
statusMsg.edit({ embeds: [embed] }).catch(() => {});
|
if (statusMsg) statusMsg.edit({ embeds: [embed] }).catch(() => {});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,6 @@ function getUserCount(client) {
|
|||||||
|
|
||||||
function getLivePlayerCount(playerMap) {
|
function getLivePlayerCount(playerMap) {
|
||||||
let live = 0;
|
let live = 0;
|
||||||
const seenGuilds = new Set();
|
|
||||||
|
|
||||||
for (const [mapKey, player] of playerMap ?? []) {
|
for (const [mapKey, player] of playerMap ?? []) {
|
||||||
if (!player || player._destroyed || player.leaving) continue;
|
if (!player || player._destroyed || player.leaving) continue;
|
||||||
@@ -87,9 +86,6 @@ function getLivePlayerCount(playerMap) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
live++;
|
live++;
|
||||||
|
|
||||||
const guildId = String(player._guildId ?? "").replace(/\D/g, "");
|
|
||||||
if (guildId) seenGuilds.add(guildId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return live;
|
return live;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { logger } from "./constants/Logger.mjs";
|
|||||||
import { ServerSettings } from "./Settings.mjs";
|
import { ServerSettings } from "./Settings.mjs";
|
||||||
import { get247ChannelMode, remove247ChannelMode } from "./constants/Helpers247.mjs";
|
import { get247ChannelMode, remove247ChannelMode } from "./constants/Helpers247.mjs";
|
||||||
import { VoiceStateCache } from "./constants/VoiceStateCache.mjs";
|
import { VoiceStateCache } from "./constants/VoiceStateCache.mjs";
|
||||||
import { REQUIRED_BOT_PERMISSIONS, CRITICAL_PERMISSIONS } from "./MessageHandler.mjs";
|
import { REQUIRED_BOT_PERMISSIONS } from "./MessageHandler.mjs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GatewayHandler — manages raw WebSocket gateway events, voice-state tracking,
|
* GatewayHandler — manages raw WebSocket gateway events, voice-state tracking,
|
||||||
@@ -126,7 +126,7 @@ export class GatewayHandler {
|
|||||||
` All missing: ${missingNames.join(", ")}`
|
` All missing: ${missingNames.join(", ")}`
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
logger.info(
|
logger.guild(
|
||||||
`[GuildCreate] Server ${guildId} is missing optional permissions: ${result.optionalMissing.join(", ")}`
|
`[GuildCreate] Server ${guildId} is missing optional permissions: ${result.optionalMissing.join(", ")}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -745,12 +745,12 @@ export class GatewayHandler {
|
|||||||
if (evictGuildId && evictUserId) {
|
if (evictGuildId && evictUserId) {
|
||||||
const currentLoc = remix.voiceCache.getUserLocation(evictGuildId, evictUserId);
|
const currentLoc = remix.voiceCache.getUserLocation(evictGuildId, evictUserId);
|
||||||
if (currentLoc && currentLoc.channelId === evictEntry.channelId) {
|
if (currentLoc && currentLoc.channelId === evictEntry.channelId) {
|
||||||
remix.voiceCache.updateUser({ guildId: evictGuildId, userId: evictUserId, channelId: null, isBot: false });
|
remix.voiceCache.updateUser({ guildId: evictGuildId, userId: evictUserId, channelId: null, isBot: evictEntry.isBot ?? false });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nextKey) this._prevVoiceState.set(nextKey, { channelId, guildId: guildId ?? prev?.guildId });
|
if (nextKey) this._prevVoiceState.set(nextKey, { channelId, guildId: guildId ?? prev?.guildId, isBot: isBot === true });
|
||||||
} else {
|
} else {
|
||||||
if (prevKey) this._prevVoiceState.delete(prevKey);
|
if (prevKey) this._prevVoiceState.delete(prevKey);
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-25
@@ -15,19 +15,7 @@
|
|||||||
import Revoicejs from "revoice.js";
|
import Revoicejs from "revoice.js";
|
||||||
const { MediaPlayer } = Revoicejs;
|
const { MediaPlayer } = Revoicejs;
|
||||||
|
|
||||||
const ConnectionState = Object.freeze({
|
import { ConnectionState, LKRoomEvent } from "./constants/FluxerRevoice.mjs";
|
||||||
CONN_DISCONNECTED: 0,
|
|
||||||
CONN_CONNECTED: 1,
|
|
||||||
CONN_RECONNECTING: 2,
|
|
||||||
});
|
|
||||||
|
|
||||||
const LKRoomEvent = Object.freeze({
|
|
||||||
ConnectionStateChanged: "connectionStateChanged",
|
|
||||||
Disconnected: "disconnected",
|
|
||||||
ParticipantConnected: "participantConnected",
|
|
||||||
ParticipantDisconnected:"participantDisconnected",
|
|
||||||
});
|
|
||||||
|
|
||||||
import { getVoiceManager } from "@fluxerjs/voice";
|
import { getVoiceManager } from "@fluxerjs/voice";
|
||||||
import { Utils } from "./Utils.mjs";
|
import { Utils } from "./Utils.mjs";
|
||||||
import { EventEmitter } from "node:events";
|
import { EventEmitter } from "node:events";
|
||||||
@@ -46,15 +34,6 @@ function mkEmbed(desc) {
|
|||||||
return { embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc)] };
|
return { embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc)] };
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatMsHelper(ms) {
|
|
||||||
if (ms == null || ms < 0) return "0:00";
|
|
||||||
const totalSeconds = Math.floor(ms / 1000);
|
|
||||||
const hours = Math.floor(totalSeconds / 3600);
|
|
||||||
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
|
||||||
const seconds = totalSeconds % 60;
|
|
||||||
if (hours > 0) return `${hours}:${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}`;
|
|
||||||
return `${minutes}:${String(seconds).padStart(2, "0")}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** NodeLink default password — centralised so it doesn't need to be hardcoded in two places. */
|
/** NodeLink default password — centralised so it doesn't need to be hardcoded in two places. */
|
||||||
const NL_DEFAULT_PASSWORD = "youshallnotpass";
|
const NL_DEFAULT_PASSWORD = "youshallnotpass";
|
||||||
@@ -568,8 +547,10 @@ export default class Player extends EventEmitter {
|
|||||||
try {
|
try {
|
||||||
const room = this.connection?.room;
|
const room = this.connection?.room;
|
||||||
if (room?.isConnected && room.remoteParticipants) {
|
if (room?.isConnected && room.remoteParticipants) {
|
||||||
|
const botId = this.client?.user?.id;
|
||||||
for (const [, participant] of room.remoteParticipants) {
|
for (const [, participant] of room.remoteParticipants) {
|
||||||
if (participant?.identity || participant?.sid) {
|
const pId = participant?.identity || participant?.sid;
|
||||||
|
if (pId && pId !== botId) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1893,8 +1874,8 @@ export default class Player extends EventEmitter {
|
|||||||
const progressBar = this._createProgressBar(20);
|
const progressBar = this._createProgressBar(20);
|
||||||
let trackOptLine = "";
|
let trackOptLine = "";
|
||||||
if (this._activeTrackOpt) {
|
if (this._activeTrackOpt) {
|
||||||
const optStart = formatMsHelper(this._activeTrackOpt.startMs);
|
const optStart = Utils.prettifyMS(this._activeTrackOpt.startMs);
|
||||||
const optEnd = this._activeTrackOpt.endMs > 0 ? formatMsHelper(this._activeTrackOpt.endMs) : "end";
|
const optEnd = this._activeTrackOpt.endMs > 0 ? Utils.prettifyMS(this._activeTrackOpt.endMs) : "end";
|
||||||
trackOptLine = `\n✂️ Custom: ${optStart} → ${optEnd}`;
|
trackOptLine = `\n✂️ Custom: ${optStart} → ${optEnd}`;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -356,9 +356,6 @@ export class PlayerManager {
|
|||||||
this.dashboard.playerUpdate({ type: "update" }, player);
|
this.dashboard.playerUpdate({ type: "update" }, player);
|
||||||
});
|
});
|
||||||
|
|
||||||
player.on("message", (message) => {
|
|
||||||
});
|
|
||||||
|
|
||||||
player.on("autoleave", () => {
|
player.on("autoleave", () => {
|
||||||
sendUserUpdates("leave");
|
sendUserUpdates("leave");
|
||||||
emitGlobal("close");
|
emitGlobal("close");
|
||||||
@@ -912,8 +909,6 @@ export class PlayerManager {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
player.on("leave", () => {});
|
|
||||||
|
|
||||||
player.on("message", (m) => {
|
player.on("message", (m) => {
|
||||||
let ch = player.textChannel;
|
let ch = player.textChannel;
|
||||||
const guildId = cleanId(player._guildId ?? ch?.guildId ?? ch?.guild?.id ?? getMessageGuildId({ channel: ch }));
|
const guildId = cleanId(player._guildId ?? ch?.guildId ?? ch?.guild?.id ?? getMessageGuildId({ channel: ch }));
|
||||||
|
|||||||
@@ -29,19 +29,22 @@
|
|||||||
import { EventEmitter } from "node:events";
|
import { EventEmitter } from "node:events";
|
||||||
import { joinVoiceChannel, getVoiceManager } from "@fluxerjs/voice";
|
import { joinVoiceChannel, getVoiceManager } from "@fluxerjs/voice";
|
||||||
|
|
||||||
const ConnectionState = Object.freeze({
|
export const ConnectionState = Object.freeze({
|
||||||
CONN_DISCONNECTED: 0,
|
CONN_DISCONNECTED: 0,
|
||||||
CONN_CONNECTED: 1,
|
CONN_CONNECTED: 1,
|
||||||
CONN_RECONNECTING: 2,
|
CONN_RECONNECTING: 2,
|
||||||
});
|
});
|
||||||
|
|
||||||
const RoomEvent = Object.freeze({
|
export const LKRoomEvent = Object.freeze({
|
||||||
ConnectionStateChanged: "connectionStateChanged",
|
ConnectionStateChanged: "connectionStateChanged",
|
||||||
Disconnected: "disconnected",
|
Disconnected: "disconnected",
|
||||||
ParticipantConnected: "participantConnected",
|
ParticipantConnected: "participantConnected",
|
||||||
ParticipantDisconnected:"participantDisconnected",
|
ParticipantDisconnected:"participantDisconnected",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/** @deprecated Use LKRoomEvent instead — kept for backward compat within this file */
|
||||||
|
const RoomEvent = LKRoomEvent;
|
||||||
|
|
||||||
import { logger } from "./Logger.mjs";
|
import { logger } from "./Logger.mjs";
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -47,6 +47,10 @@ export const logger = {
|
|||||||
if (_config?.enabled === false) return;
|
if (_config?.enabled === false) return;
|
||||||
console.warn(`[${ts()}] ${tag}`, ...args);
|
console.warn(`[${ts()}] ${tag}`, ...args);
|
||||||
},
|
},
|
||||||
|
info(tag, ...args) {
|
||||||
|
if (_config?.enabled === false) return;
|
||||||
|
console.log(`[${ts()}] ${tag}`, ...args);
|
||||||
|
},
|
||||||
|
|
||||||
player(...args) { if (isEnabled("player")) console.log(`[${ts()}]`, ...args); },
|
player(...args) { if (isEnabled("player")) console.log(`[${ts()}]`, ...args); },
|
||||||
inactivity(...args) { if (isEnabled("inactivity")) console.log(`[${ts()}]`, ...args); },
|
inactivity(...args) { if (isEnabled("inactivity")) console.log(`[${ts()}]`, ...args); },
|
||||||
|
|||||||
@@ -93,13 +93,9 @@ export class VoiceStateCache {
|
|||||||
if (!set) { set = new Set(); channelIdx.set(cKey, set); }
|
if (!set) { set = new Set(); channelIdx.set(cKey, set); }
|
||||||
set.add(cleanUser);
|
set.add(cleanUser);
|
||||||
|
|
||||||
|
locations.delete(uKey);
|
||||||
locations.set(uKey, { channelId: cleanChannel, guildId: cleanGuild, userId: cleanUser });
|
locations.set(uKey, { channelId: cleanChannel, guildId: cleanGuild, userId: cleanUser });
|
||||||
|
|
||||||
if (locations.has(uKey)) {
|
|
||||||
locations.delete(uKey);
|
|
||||||
locations.set(uKey, { channelId: cleanChannel, guildId: cleanGuild, userId: cleanUser });
|
|
||||||
}
|
|
||||||
|
|
||||||
while (locations.size > maxEntries) {
|
while (locations.size > maxEntries) {
|
||||||
const evictKey = locations.keys().next().value;
|
const evictKey = locations.keys().next().value;
|
||||||
if (evictKey === uKey) {
|
if (evictKey === uKey) {
|
||||||
|
|||||||
@@ -8,19 +8,19 @@ class Tuna {
|
|||||||
}
|
}
|
||||||
get(path, params = {}) {
|
get(path, params = {}) {
|
||||||
return new Promise((resolve, rej) => {
|
return new Promise((resolve, rej) => {
|
||||||
var query = "";
|
let query = "";
|
||||||
for (let key in params) {
|
for (let key in params) {
|
||||||
query += ((query.length === 0) ? "?" : "&") + key + "=" + encodeURIComponent(params[key]);
|
query += ((query.length === 0) ? "?" : "&") + key + "=" + encodeURIComponent(params[key]);
|
||||||
}
|
}
|
||||||
var options = {
|
const options = {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
hostname: "tuna-api.voicemod.net",
|
hostname: "tuna-api.voicemod.net",
|
||||||
path: path + query,
|
path: path + query,
|
||||||
headers: { "x-api-key": this.apiKey },
|
headers: { "x-api-key": this.apiKey },
|
||||||
maxRedirects: 20
|
maxRedirects: 20
|
||||||
};
|
};
|
||||||
var req = https.request(options, function(res) {
|
const req = https.request(options, function(res) {
|
||||||
var chunks = [];
|
const chunks = [];
|
||||||
res.on("data", (chunk) => { chunks.push(chunk); });
|
res.on("data", (chunk) => { chunks.push(chunk); });
|
||||||
res.on("end", () => {
|
res.on("end", () => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -76,21 +76,26 @@ export class Dashboard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "allServers": {
|
case "allServers": {
|
||||||
|
let guilds;
|
||||||
try {
|
try {
|
||||||
const guilds = await this.remix.client.user.fetchGuilds();
|
guilds = await this.remix.client.user.fetchGuilds();
|
||||||
return guilds.map(g => Dashboard.convertServer(g));
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const id = Utils.uid();
|
const id = Utils.uid();
|
||||||
logger.dashboard("[Dashboard] allServers error:", id, e);
|
logger.dashboard("[Dashboard] allServers error:", id, e);
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
let result = guilds.map(g => Dashboard.convertServer(g));
|
||||||
if (data.accessor) {
|
if (data.accessor) {
|
||||||
try {
|
try {
|
||||||
const accessorUser = await this.remix.client.users.fetch(data.accessor).catch(() => null);
|
const accessorUser = await this.remix.client.users.fetch(data.accessor).catch(() => null);
|
||||||
if (accessorUser) return await this.remix.getSharedServers(accessorUser);
|
if (accessorUser) {
|
||||||
|
const shared = await this.remix.getSharedServers(accessorUser);
|
||||||
|
const sharedIds = new Set(shared.map(s => s.id));
|
||||||
|
result = result.filter(g => sharedIds.has(g.id));
|
||||||
|
}
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
return [];
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "commands": {
|
case "commands": {
|
||||||
@@ -434,8 +439,8 @@ export class Dashboard {
|
|||||||
} else if (typeof user.avatarURL === "function") {
|
} else if (typeof user.avatarURL === "function") {
|
||||||
try { avatarUrl = user.avatarURL() ?? ""; } catch (_) {}
|
try { avatarUrl = user.avatarURL() ?? ""; } catch (_) {}
|
||||||
}
|
}
|
||||||
if (!avatarUrl && user.discriminator) {
|
if (!avatarUrl) {
|
||||||
avatarUrl = `https://fluxerusercontent.com/embed/avatars/${parseInt(user.discriminator || "0") % 5}.png`;
|
avatarUrl = `https://fluxerusercontent.com/embed/avatars/${parseInt(user.id?.slice(-4) ?? "0") % 5}.png`;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
id: user.id,
|
id: user.id,
|
||||||
@@ -476,7 +481,7 @@ export class Dashboard {
|
|||||||
*/
|
*/
|
||||||
static convertChannel(channel) {
|
static convertChannel(channel) {
|
||||||
const type = channel.type ?? 0;
|
const type = channel.type ?? 0;
|
||||||
const isVoice = channel.isVoice?.() ?? (type === 2) ?? false;
|
const isVoice = channel.isVoice?.() || type === 2;
|
||||||
const isCategory = type === 4;
|
const isCategory = type === 4;
|
||||||
const isText = !isVoice && !isCategory && (
|
const isText = !isVoice && !isCategory && (
|
||||||
type === 0 || type === 5 || type === 13 ||
|
type === 0 || type === 5 || type === 13 ||
|
||||||
|
|||||||
@@ -544,26 +544,14 @@ const post = (event, payload) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
utils.on("message", (m) => {
|
utils.on("message", (m) => {
|
||||||
if (jobId === "dev") { logger.worker("[Message]", m); return; }
|
|
||||||
post("message", m);
|
post("message", m);
|
||||||
});
|
});
|
||||||
|
|
||||||
utils.on("error", (m) => {
|
utils.on("error", (m) => {
|
||||||
if (jobId === "dev") { logger.worker("[Error]", m); return; }
|
|
||||||
post("error", m);
|
post("error", m);
|
||||||
});
|
});
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
if (jobId === "dev") {
|
|
||||||
try {
|
|
||||||
const result = await utils.getVideoData("Neoni funeral", "ytm");
|
|
||||||
logger.worker("[Worker result]", result);
|
|
||||||
} catch (e) {
|
|
||||||
logger.error("[Worker error]", e);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
switch (jobId) {
|
switch (jobId) {
|
||||||
case "generalQuery": {
|
case "generalQuery": {
|
||||||
|
|||||||
@@ -3,10 +3,5 @@
|
|||||||
"name": "wb-dashboard",
|
"name": "wb-dashboard",
|
||||||
"index": "./dashboard/index.js",
|
"index": "./dashboard/index.js",
|
||||||
"enabled": false
|
"enabled": false
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "rbl-stats",
|
|
||||||
"index": "./rbl.js",
|
|
||||||
"enabled": false
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
Reference in new issue
Block a user