Version 2.1.0 - Passage sur Lavalink V4 et Moonlink.js
This commit is contained in:
15
node_modules/moonlink.js/dist/src/@Utils/MoonlinkDatabase.d.ts
generated
vendored
Normal file
15
node_modules/moonlink.js/dist/src/@Utils/MoonlinkDatabase.d.ts
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
type Data = Record<string, any>;
|
||||
export declare class MoonlinkDatabase {
|
||||
data: Data;
|
||||
id: string;
|
||||
constructor(clientId: string);
|
||||
set<T>(key: string, value: T): void;
|
||||
get<T>(key: string): T | undefined;
|
||||
push<T>(key: string, value: T): void;
|
||||
delete(key: string): boolean;
|
||||
private updateData;
|
||||
private getFilePath;
|
||||
fetch(): void;
|
||||
private save;
|
||||
}
|
||||
export {};
|
113
node_modules/moonlink.js/dist/src/@Utils/MoonlinkDatabase.js
generated
vendored
Normal file
113
node_modules/moonlink.js/dist/src/@Utils/MoonlinkDatabase.js
generated
vendored
Normal file
@ -0,0 +1,113 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MoonlinkDatabase = void 0;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
class MoonlinkDatabase {
|
||||
data = {};
|
||||
id;
|
||||
constructor(clientId) {
|
||||
this.fetch();
|
||||
this.id = clientId;
|
||||
}
|
||||
set(key, value) {
|
||||
if (!key)
|
||||
throw new Error('@Moonlink(Database) - "key" is empty');
|
||||
const keys = key.split(".");
|
||||
if (keys.length === 0)
|
||||
return;
|
||||
this.updateData(this.data, keys, value);
|
||||
this.save();
|
||||
}
|
||||
get(key) {
|
||||
if (!key)
|
||||
throw new Error('[ @Moonlink(Database) - "key" is empty');
|
||||
if (Object.keys(this.data).length === 0)
|
||||
this.fetch();
|
||||
return (key.split(".").reduce((acc, curr) => acc?.[curr], this.data) ?? null);
|
||||
}
|
||||
push(key, value) {
|
||||
if (!key)
|
||||
throw new Error('@Moonlink(Database) - "key" is empty');
|
||||
const oldArray = this.get(key) || [];
|
||||
if (Array.isArray(oldArray)) {
|
||||
oldArray.push(value);
|
||||
this.set(key, oldArray);
|
||||
}
|
||||
else {
|
||||
throw new Error("@Moonlink(Database) - Key does not point to an array");
|
||||
}
|
||||
}
|
||||
delete(key) {
|
||||
if (!key)
|
||||
throw new Error('@Moonlink(Database) - "key" is empty');
|
||||
const keys = key.split(".");
|
||||
if (keys.length === 0)
|
||||
return false;
|
||||
const lastKey = keys.pop() || "";
|
||||
let currentObj = this.data;
|
||||
keys.forEach(k => {
|
||||
if (typeof currentObj[k] === "object") {
|
||||
currentObj = currentObj[k];
|
||||
}
|
||||
else {
|
||||
throw new Error(`@Moonlink(Database) - Key path "${key}" does not exist`);
|
||||
}
|
||||
});
|
||||
if (currentObj && lastKey in currentObj) {
|
||||
delete currentObj[lastKey];
|
||||
this.save();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
updateData(data, keys, value) {
|
||||
let currentObj = data;
|
||||
keys.forEach((key, index) => {
|
||||
if (index === keys.length - 1) {
|
||||
currentObj[key] = value;
|
||||
}
|
||||
else {
|
||||
if (typeof currentObj[key] !== "object") {
|
||||
currentObj[key] = {};
|
||||
}
|
||||
currentObj = currentObj[key];
|
||||
}
|
||||
});
|
||||
}
|
||||
getFilePath() {
|
||||
return path_1.default.join(__dirname, "../@Datastore", `database-${this.id}.json`);
|
||||
}
|
||||
fetch() {
|
||||
try {
|
||||
const directory = path_1.default.join(__dirname, "../@Datastore");
|
||||
if (!fs_1.default.existsSync(directory)) {
|
||||
fs_1.default.mkdirSync(directory, { recursive: true });
|
||||
}
|
||||
const filePath = this.getFilePath();
|
||||
const rawData = fs_1.default.readFileSync(filePath, "utf-8");
|
||||
this.data = JSON.parse(rawData) || {};
|
||||
}
|
||||
catch (err) {
|
||||
if (err.code === "ENOENT") {
|
||||
this.data = {};
|
||||
}
|
||||
else {
|
||||
throw new Error("@Moonlink(Database) - Failed to fetch data (Error):", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
save() {
|
||||
try {
|
||||
const filePath = this.getFilePath();
|
||||
fs_1.default.writeFileSync(filePath, JSON.stringify(this.data, null, 2));
|
||||
}
|
||||
catch (error) {
|
||||
throw new Error("@Moonlink(Database) - Failed to save data");
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.MoonlinkDatabase = MoonlinkDatabase;
|
29
node_modules/moonlink.js/dist/src/@Utils/MoonlinkFilters.d.ts
generated
vendored
Normal file
29
node_modules/moonlink.js/dist/src/@Utils/MoonlinkFilters.d.ts
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
import { Equalizer, Karaoke, Timescale, Tremolo, Vibrato, Rotation, Distortion, ChannelMix, LowPass } from "../@Typings";
|
||||
export declare class MoonlinkFilters {
|
||||
private player;
|
||||
private manager;
|
||||
private rest;
|
||||
volume: number | null;
|
||||
equalizer: Equalizer[] | null;
|
||||
karaoke: Karaoke | null;
|
||||
timescale: Timescale | null;
|
||||
tremolo: Tremolo | null;
|
||||
vibrato: Vibrato | null;
|
||||
rotation: Rotation | null;
|
||||
distortion: Distortion | null;
|
||||
channelMix: ChannelMix | null;
|
||||
lowPass: LowPass | null;
|
||||
constructor(player: any);
|
||||
setVolume(volume: number | null): this;
|
||||
setEqualizer(equalizer: Equalizer[] | null): this;
|
||||
setKaraoke(karaoke: Karaoke | null): this;
|
||||
setTimescale(timescale: Timescale | null): this;
|
||||
setTremolo(tremolo: Tremolo | null): this;
|
||||
setVibrato(vibrato: Vibrato | null): this;
|
||||
setRotation(rotation: Rotation | null): this;
|
||||
setDistortion(distortion: Distortion | null): this;
|
||||
setChannelMix(channelMix: ChannelMix | null): this;
|
||||
setLowPass(lowPass: LowPass | null): this;
|
||||
resetFilters(): this;
|
||||
private updateFiltersFromRest;
|
||||
}
|
131
node_modules/moonlink.js/dist/src/@Utils/MoonlinkFilters.js
generated
vendored
Normal file
131
node_modules/moonlink.js/dist/src/@Utils/MoonlinkFilters.js
generated
vendored
Normal file
@ -0,0 +1,131 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MoonlinkFilters = void 0;
|
||||
const index_1 = require("../../index");
|
||||
class MoonlinkFilters {
|
||||
player;
|
||||
manager;
|
||||
rest;
|
||||
volume;
|
||||
equalizer;
|
||||
karaoke;
|
||||
timescale;
|
||||
tremolo;
|
||||
vibrato;
|
||||
rotation;
|
||||
distortion;
|
||||
channelMix;
|
||||
lowPass;
|
||||
constructor(player) {
|
||||
this.player = player;
|
||||
this.rest = player.node.rest;
|
||||
this.manager = index_1.Structure.manager;
|
||||
this.volume = this.player.get("Fvolume") || null;
|
||||
this.equalizer = this.player.get("equalizer") || null;
|
||||
this.karaoke = this.player.get("karaoke") || null;
|
||||
this.timescale = this.player.get("timescale") || null;
|
||||
this.tremolo = this.player.get("tremolo") || null;
|
||||
this.vibrato = this.player.get("vibrato") || null;
|
||||
this.rotation = this.player.get("rotation") || null;
|
||||
this.distortion = this.player.get("distortion") || null;
|
||||
this.channelMix = this.player.get("channelMix") || null;
|
||||
this.lowPass = this.player.get("lowPass") || null;
|
||||
}
|
||||
setVolume(volume) {
|
||||
this.player.set("Fvolume", volume);
|
||||
this.volume = volume;
|
||||
this.updateFiltersFromRest();
|
||||
return this;
|
||||
}
|
||||
setEqualizer(equalizer) {
|
||||
this.player.set("equalizer", equalizer);
|
||||
this.equalizer = equalizer;
|
||||
this.updateFiltersFromRest();
|
||||
return this;
|
||||
}
|
||||
setKaraoke(karaoke) {
|
||||
this.player.set("karaoke", karaoke);
|
||||
this.karaoke = karaoke;
|
||||
this.updateFiltersFromRest();
|
||||
return this;
|
||||
}
|
||||
setTimescale(timescale) {
|
||||
this.player.set("timescale", timescale);
|
||||
this.timescale = timescale;
|
||||
this.updateFiltersFromRest();
|
||||
return this;
|
||||
}
|
||||
setTremolo(tremolo) {
|
||||
this.player.set("tremolo", tremolo);
|
||||
this.tremolo = tremolo;
|
||||
this.updateFiltersFromRest();
|
||||
return this;
|
||||
}
|
||||
setVibrato(vibrato) {
|
||||
this.player.set("vibrato", vibrato);
|
||||
this.vibrato = vibrato;
|
||||
this.updateFiltersFromRest();
|
||||
return this;
|
||||
}
|
||||
setRotation(rotation) {
|
||||
this.player.set("rotation", rotation);
|
||||
this.rotation = rotation;
|
||||
this.updateFiltersFromRest();
|
||||
return this;
|
||||
}
|
||||
setDistortion(distortion) {
|
||||
this.player.set("distortion", distortion);
|
||||
this.distortion = distortion;
|
||||
this.updateFiltersFromRest();
|
||||
return this;
|
||||
}
|
||||
setChannelMix(channelMix) {
|
||||
this.player.set("channelMix", channelMix);
|
||||
this.channelMix = channelMix;
|
||||
this.updateFiltersFromRest();
|
||||
return this;
|
||||
}
|
||||
setLowPass(lowPass) {
|
||||
this.player.set("lowPass", lowPass);
|
||||
this.lowPass = lowPass;
|
||||
this.updateFiltersFromRest();
|
||||
return this;
|
||||
}
|
||||
resetFilters() {
|
||||
this.setVolume(null);
|
||||
this.setEqualizer(null);
|
||||
this.setKaraoke(null);
|
||||
this.setTimescale(null);
|
||||
this.setTremolo(null);
|
||||
this.setVibrato(null);
|
||||
this.setRotation(null);
|
||||
this.setDistortion(null);
|
||||
this.setChannelMix(null);
|
||||
this.setLowPass(null);
|
||||
this.updateFiltersFromRest();
|
||||
return this;
|
||||
}
|
||||
async updateFiltersFromRest() {
|
||||
let { volume, equalizer, karaoke, timescale, tremolo, vibrato, rotation, distortion, channelMix, lowPass } = this;
|
||||
const dataToUpdate = {
|
||||
guildId: this.player.guildId,
|
||||
data: {
|
||||
filters: {
|
||||
...(volume !== null && { volume }),
|
||||
...(equalizer !== null && { equalizer }),
|
||||
...(karaoke !== null && { karaoke }),
|
||||
...(timescale !== null && { timescale }),
|
||||
...(tremolo !== null && { tremolo }),
|
||||
...(vibrato !== null && { vibrato }),
|
||||
...(rotation !== null && { rotation }),
|
||||
...(distortion !== null && { distortion }),
|
||||
...(channelMix !== null && { channelMix }),
|
||||
...(lowPass !== null && { lowPass })
|
||||
}
|
||||
}
|
||||
};
|
||||
await this.rest.update(dataToUpdate);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
exports.MoonlinkFilters = MoonlinkFilters;
|
20
node_modules/moonlink.js/dist/src/@Utils/MoonlinkTrack.d.ts
generated
vendored
Normal file
20
node_modules/moonlink.js/dist/src/@Utils/MoonlinkTrack.d.ts
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
import { MoonlinkTrackOptions } from "../@Typings";
|
||||
export declare class MoonlinkTrack {
|
||||
encoded: string | null;
|
||||
identifier: string;
|
||||
title: string;
|
||||
author: string;
|
||||
url: string;
|
||||
duration: number;
|
||||
position: number;
|
||||
isSeekable: boolean;
|
||||
isStream: boolean;
|
||||
sourceName: string;
|
||||
requester: any;
|
||||
artworkUrl: string;
|
||||
isrc: string;
|
||||
time?: number;
|
||||
constructor(data?: MoonlinkTrackOptions, requester?: string | any);
|
||||
get calculateRealTimePosition(): number;
|
||||
setRequester(data: any): void;
|
||||
}
|
52
node_modules/moonlink.js/dist/src/@Utils/MoonlinkTrack.js
generated
vendored
Normal file
52
node_modules/moonlink.js/dist/src/@Utils/MoonlinkTrack.js
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MoonlinkTrack = void 0;
|
||||
class MoonlinkTrack {
|
||||
encoded;
|
||||
identifier;
|
||||
title;
|
||||
author;
|
||||
url;
|
||||
duration;
|
||||
position;
|
||||
isSeekable;
|
||||
isStream;
|
||||
sourceName;
|
||||
requester;
|
||||
artworkUrl;
|
||||
isrc;
|
||||
time = 0;
|
||||
constructor(data, requester) {
|
||||
this.encoded = data.encoded;
|
||||
this.title = data.info.title;
|
||||
this.author = data.info.author;
|
||||
this.url = data.info.uri;
|
||||
this.duration = data.info.length;
|
||||
this.position = data.info.position;
|
||||
this.identifier = data.info.identifier;
|
||||
this.isSeekable = Boolean(data.info.isSeekable);
|
||||
this.isStream = Boolean(data.info.isStream);
|
||||
this.sourceName = data.info.sourceName || null;
|
||||
this.requester = requester;
|
||||
this.artworkUrl = data.info.artworkUrl;
|
||||
this.isrc = data.info.isrc;
|
||||
}
|
||||
get calculateRealTimePosition() {
|
||||
if (this.position >= this.duration) {
|
||||
return this.duration;
|
||||
}
|
||||
if (this.time) {
|
||||
const elapsed = Date.now() - this.time;
|
||||
const calculatedPosition = this.position + elapsed / 1000;
|
||||
if (calculatedPosition >= this.duration) {
|
||||
return this.duration;
|
||||
}
|
||||
return calculatedPosition;
|
||||
}
|
||||
return this.position;
|
||||
}
|
||||
setRequester(data) {
|
||||
this.requester = data;
|
||||
}
|
||||
}
|
||||
exports.MoonlinkTrack = MoonlinkTrack;
|
13
node_modules/moonlink.js/dist/src/@Utils/Structure.d.ts
generated
vendored
Normal file
13
node_modules/moonlink.js/dist/src/@Utils/Structure.d.ts
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
import { Extendable } from "../@Typings";
|
||||
import { MoonlinkManager, MoonlinkDatabase } from "../../index";
|
||||
export declare abstract class Structure {
|
||||
static manager: MoonlinkManager;
|
||||
static db: MoonlinkDatabase;
|
||||
static extend<K extends keyof Extendable, T extends Extendable[K]>(name: K, extender: (target: Extendable[K]) => T): T;
|
||||
static init(manager: MoonlinkManager): void;
|
||||
static get<K extends keyof Extendable>(name: K): Extendable[K];
|
||||
}
|
||||
export declare class Plugin {
|
||||
load(manager: MoonlinkManager): void;
|
||||
unload(manager: MoonlinkManager): void;
|
||||
}
|
46
node_modules/moonlink.js/dist/src/@Utils/Structure.js
generated
vendored
Normal file
46
node_modules/moonlink.js/dist/src/@Utils/Structure.js
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Plugin = exports.Structure = void 0;
|
||||
const index_1 = require("../../index");
|
||||
const structures = {
|
||||
MoonlinkManager: index_1.MoonlinkManager,
|
||||
MoonlinkRestFul: index_1.MoonlinkRestFul,
|
||||
MoonlinkPlayer: index_1.MoonlinkPlayer,
|
||||
MoonlinkFilters: index_1.MoonlinkFilters,
|
||||
MoonlinkDatabase: index_1.MoonlinkDatabase,
|
||||
MoonlinkQueue: index_1.MoonlinkQueue,
|
||||
MoonlinkNode: index_1.MoonlinkNode,
|
||||
MoonlinkTrack: index_1.MoonlinkTrack,
|
||||
PlayerManager: index_1.PlayerManager,
|
||||
NodeManager: index_1.NodeManager
|
||||
};
|
||||
class Structure {
|
||||
static manager;
|
||||
static db;
|
||||
static extend(name, extender) {
|
||||
if (!(name in structures)) {
|
||||
throw new TypeError(`"${name}" is not a valid structure`);
|
||||
}
|
||||
const extended = extender(structures[name]);
|
||||
structures[name] = extended;
|
||||
return extended;
|
||||
}
|
||||
static init(manager) {
|
||||
this.manager = manager;
|
||||
this.db = new (Structure.get("MoonlinkDatabase"))(manager.clientId);
|
||||
this.manager.emit("debug", `@Moonlink(Structure) - The main class and database are assigned to structure :)`);
|
||||
}
|
||||
static get(name) {
|
||||
const structure = structures[name];
|
||||
if (!structure) {
|
||||
throw new TypeError(`"${name}" structure must be provided.`);
|
||||
}
|
||||
return structure;
|
||||
}
|
||||
}
|
||||
exports.Structure = Structure;
|
||||
class Plugin {
|
||||
load(manager) { }
|
||||
unload(manager) { }
|
||||
}
|
||||
exports.Plugin = Plugin;
|
Reference in New Issue
Block a user