
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@moscowcity/shoukaku
Advanced tools
Forked Shoukaku module with player.info option and session dump & recovery
This is a modified version used in our application infrastructure.
Shoukaku: https://github.com/shipgirlproject/Shoukaku
We added the "player.info" interface, which wasn't included in Shoukaku, and implemented session recovery from a dump stored in Redis or a Database.
Please, make sure that only the added changes and examples of their usage will be shown, so it's recommended to familiarize yourself with the original repository before starting to read.
export interface Track {
encoded: string;
info: TrackInfo;
};
export interface TrackInfo {
identifier: string;
isSeekable: boolean;
author: string;
duration: number;
isStream: boolean;
position: number;
title: string;
uri?: string;
sourceName?: string;
artworkUrl?: string;
isTrackUnavailable?: string;
isrc?: string;
};
Note that "isTrackUnavailable" won't be accessible, as it's used in our Lavalink fork to check if the track is regionally restricted or a preview.
So, now information will be available by calling:
shoukaku.players.get("id").track.info
You should listen to the "raw" event from Shoukaku and redirect it to your functions, as regular "player.on" will stop working after a restart and will need to be reassigned manually.
shoukaku.on("raw", (name: string, json: any) => {
// Forward to your functions like that
this.listeners[(json.op.type || json.op) as keyof PlayerListeners]?.(name, json)
});
"this.listeners" — the "PlayerListeners" assigned through the constructor. An example class is provided below.
export class PlayerListeners {
// constructor() {};
// The function name should match "json.op.type" or "json.op" such as "TrackStartEvent"
TrackStartEvent(name: string, data: TrackStartEvent) {
// Do whatever you want
};
};
import { PlayerUpdate } from "@moscowcity/shoukaku";
export class PlayerListeners {
// constructor() {};
playerUpdate(name: string, data: PlayerUpdate) {
// Updating data for the received guild
this.database.updateData("queue", { guild: data.guildId },
{ session: this.shoukaku.playersDump.get(data.guildId) }
);
};
};
Upon restart, we retrieve the data from the model and give it to Shoukaku.
// queue.session is a PlayerDump that we previously saved using this.shoukaku.playersDump.get(data.guildId).
const queue = (await this.app.database.getAllData("queue", undefined, false)).filter((queue: any) => queue.session);
// you need to modify this part of the code, since I'm updating each player separetely from playerUpdate event and need to create an array of all sessions.
const sessions = queue.map((queue: IQueue) => queue.session); // we need to get Array<PlayerDump> — u can save an array of all sessions using shoukaku.playersDump
// setup Shoukaku as usual, add the resume parameter and pass sessions.
this.shoukaku = new Shoukaku(new Connectors.Eris(this.app.client), this.app.config.values.music.nodes, {
moveOnDisconnect: true,
resume: true
}, PreviousSessions);
FAQs
Forked Shoukaku module with player.info option and session dump & recovery
The npm package @moscowcity/shoukaku receives a total of 0 weekly downloads. As such, @moscowcity/shoukaku popularity was classified as not popular.
We found that @moscowcity/shoukaku demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.