move default player options to constants
This commit is contained in:
parent
0ff076b583
commit
c505b177ad
3 changed files with 28 additions and 19 deletions
|
@ -1,11 +1,17 @@
|
||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import { Client, Collection, Snowflake, Collector, Message, VoiceChannel, VoiceState } from 'discord.js';
|
import { Client, Collection, Snowflake, Collector, Message, VoiceChannel, VoiceState } from 'discord.js';
|
||||||
import { LyricsData, PlayerOptions, PlayerProgressbarOptions, PlayerStats, QueueFilters } from './types/types';
|
import {
|
||||||
|
LyricsData,
|
||||||
|
PlayerOptions as PlayerOptionsType,
|
||||||
|
PlayerProgressbarOptions,
|
||||||
|
PlayerStats,
|
||||||
|
QueueFilters
|
||||||
|
} from './types/types';
|
||||||
import Util from './utils/Util';
|
import Util from './utils/Util';
|
||||||
import AudioFilters from './utils/AudioFilters';
|
import AudioFilters from './utils/AudioFilters';
|
||||||
import { Queue } from './Structures/Queue';
|
import { Queue } from './Structures/Queue';
|
||||||
import { Track } from './Structures/Track';
|
import { Track } from './Structures/Track';
|
||||||
import { PlayerErrorEventCodes, PlayerEvents } from './utils/Constants';
|
import { PlayerErrorEventCodes, PlayerEvents, PlayerOptions } from './utils/Constants';
|
||||||
import PlayerError from './utils/PlayerError';
|
import PlayerError from './utils/PlayerError';
|
||||||
import ytdl from 'discord-ytdl-core';
|
import ytdl from 'discord-ytdl-core';
|
||||||
import { ExtractorModel } from './Structures/ExtractorModel';
|
import { ExtractorModel } from './Structures/ExtractorModel';
|
||||||
|
@ -27,7 +33,7 @@ export class Player extends EventEmitter {
|
||||||
* The discord client that instantiated this player
|
* The discord client that instantiated this player
|
||||||
*/
|
*/
|
||||||
public client!: Client;
|
public client!: Client;
|
||||||
public options: PlayerOptions;
|
public options: PlayerOptionsType;
|
||||||
public filters: typeof AudioFilters;
|
public filters: typeof AudioFilters;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,7 +53,7 @@ export class Player extends EventEmitter {
|
||||||
* @param client The discord.js client
|
* @param client The discord.js client
|
||||||
* @param options Player options
|
* @param options Player options
|
||||||
*/
|
*/
|
||||||
constructor(client: Client, options?: PlayerOptions) {
|
constructor(client: Client, options?: PlayerOptionsType) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
Object.defineProperty(this, 'client', {
|
Object.defineProperty(this, 'client', {
|
||||||
|
@ -58,7 +64,7 @@ export class Player extends EventEmitter {
|
||||||
/**
|
/**
|
||||||
* The player options
|
* The player options
|
||||||
*/
|
*/
|
||||||
this.options = Object.assign({}, Util.DefaultPlayerOptions, options ?? {});
|
this.options = Object.assign({}, PlayerOptions, options ?? {});
|
||||||
|
|
||||||
// check FFmpeg
|
// check FFmpeg
|
||||||
void Util.alertFFmpeg();
|
void Util.alertFFmpeg();
|
||||||
|
@ -895,7 +901,10 @@ export class Player extends EventEmitter {
|
||||||
return {
|
return {
|
||||||
uptime: this.client.uptime,
|
uptime: this.client.uptime,
|
||||||
connections: this.client.voice.connections.size,
|
connections: this.client.voice.connections.size,
|
||||||
users: this.client.voice.connections.reduce((a, c) => a + c.channel.members.filter(a => a.user.id !== this.client.user.id).size, 0),
|
users: this.client.voice.connections.reduce(
|
||||||
|
(a, c) => a + c.channel.members.filter((a) => a.user.id !== this.client.user.id).size,
|
||||||
|
0
|
||||||
|
),
|
||||||
queues: this.queues.size,
|
queues: this.queues.size,
|
||||||
extractors: this.Extractors.size,
|
extractors: this.Extractors.size,
|
||||||
versions: {
|
versions: {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { PlayerOptions as DP_OPTIONS } from '../types/types';
|
||||||
|
|
||||||
export const PlayerEvents = {
|
export const PlayerEvents = {
|
||||||
BOT_DISCONNECT: 'botDisconnect',
|
BOT_DISCONNECT: 'botDisconnect',
|
||||||
CHANNEL_EMPTY: 'channelEmpty',
|
CHANNEL_EMPTY: 'channelEmpty',
|
||||||
|
@ -26,3 +28,13 @@ export const PlayerErrorEventCodes = {
|
||||||
VIDEO_UNAVAILABLE: 'VideoUnavailable',
|
VIDEO_UNAVAILABLE: 'VideoUnavailable',
|
||||||
MUSIC_STARTING: 'MusicStarting'
|
MUSIC_STARTING: 'MusicStarting'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const PlayerOptions: DP_OPTIONS = {
|
||||||
|
leaveOnEnd: true,
|
||||||
|
leaveOnStop: true,
|
||||||
|
leaveOnEmpty: true,
|
||||||
|
leaveOnEmptyCooldown: 0,
|
||||||
|
autoSelfDeaf: true,
|
||||||
|
enableLive: false,
|
||||||
|
ytdlDownloadOptions: {}
|
||||||
|
};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { PlayerOptions, QueryType } from '../types/types';
|
import { QueryType } from '../types/types';
|
||||||
import { FFmpeg } from 'prism-media';
|
import { FFmpeg } from 'prism-media';
|
||||||
import YouTube from 'youtube-sr';
|
import YouTube from 'youtube-sr';
|
||||||
import { Track } from '../Structures/Track';
|
import { Track } from '../Structures/Track';
|
||||||
|
@ -19,18 +19,6 @@ export class Util {
|
||||||
throw new Error(`The ${this.constructor.name} class is static and cannot be instantiated!`);
|
throw new Error(`The ${this.constructor.name} class is static and cannot be instantiated!`);
|
||||||
}
|
}
|
||||||
|
|
||||||
static get DefaultPlayerOptions() {
|
|
||||||
return {
|
|
||||||
leaveOnEnd: true,
|
|
||||||
leaveOnStop: true,
|
|
||||||
leaveOnEmpty: true,
|
|
||||||
leaveOnEmptyCooldown: 0,
|
|
||||||
autoSelfDeaf: true,
|
|
||||||
enableLive: false,
|
|
||||||
ytdlDownloadOptions: {}
|
|
||||||
} as PlayerOptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
static getFFmpegVersion(force?: boolean) {
|
static getFFmpegVersion(force?: boolean) {
|
||||||
try {
|
try {
|
||||||
const info = FFmpeg.getInfo(Boolean(force));
|
const info = FFmpeg.getInfo(Boolean(force));
|
||||||
|
|
Loading…
Reference in a new issue