diff --git a/src/commands/music.ts b/src/commands/music.ts index 089e15b..3a6e265 100644 --- a/src/commands/music.ts +++ b/src/commands/music.ts @@ -4,6 +4,7 @@ import {Player,useTimeline,useQueue} from 'discord-player'; import {SpotifyExtractor} from '@discord-player/extractor'; export default { async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){ + if (!client.config.botSwitches.music) return interaction.reply({content:'Music module is currently disabled.',ephemeral:true}); if (!client.isStaff(interaction.member) && !client.config.whitelist.includes(interaction.member.id)) return interaction.reply('This command is in early stages of development, some parts may be missing or broken.\nIt has been restricted to staff for time-being.'); const player = Player.singleton(client); await player.extractors.register(SpotifyExtractor, { diff --git a/src/config.json b/src/config.json index 13c3dd0..c6190ec 100644 --- a/src/config.json +++ b/src/config.json @@ -19,6 +19,7 @@ "registerCommands": true, "commands": true, "logs": true, + "music": false, "buttonRoles": true, "automod": true, "mpstats": true, diff --git a/src/index.ts b/src/index.ts index 5e3320a..b8a2f1c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -41,16 +41,18 @@ process.on('error', (error: Error)=>DZ(error, 'process-error')); client.on('error', (error: Error)=>DZ(error, 'client-error')); // Audio Player event handling -player.events.on('playerStart', (queue,track)=>queue.channel.send({embeds:[new client.embed().setColor(client.config.embedColor).setTitle(`${track.raw.title} - ${track.raw.author}`).setFooter({text:`Playing in ${queue.channel.name}`}).setThumbnail(track.raw.thumbnail)]})); -player.events.on('playerFinish', (queue,track)=>{ - if (queue.tracks.size < 1) return queue.channel.send('There\'s no songs left in the queue, leaving voice channel in 15 seconds.').then(()=>setTimeout(()=>queue.connection.disconnect(), 15000)) -}) -player.events.on('audioTrackAdd', (queue,track)=>queue.channel.send({embeds:[new client.embed().setColor(client.config.embedColorGreen).setTitle(`${track.raw.title} - ${track.raw.author}`).setFooter({text:`Added to queue`}).setThumbnail(track.raw.thumbnail)]})); -/* player.events.on('debug', (queue,message)=>{ - console.log(client.logTime(), message) -}) */ -player.events.on('playerError', (queue, error)=>DZ(error, 'playerError')); -player.events.on('error', (queue, error)=>DZ(error, 'playerInternalError')); +if (client.config.botSwitches.music){ + player.events.on('playerStart', (queue,track)=>queue.channel.send({embeds:[new client.embed().setColor(client.config.embedColor).setTitle(`${track.raw.title} - ${track.raw.author}`).setFooter({text:`Playing in ${queue.channel.name}`}).setThumbnail(track.raw.thumbnail)]})); + player.events.on('playerFinish', (queue,track)=>{ + if (queue.tracks.size < 1) return queue.channel.send('There\'s no songs left in the queue, leaving voice channel in 15 seconds.').then(()=>setTimeout(()=>queue.connection.disconnect(), 15000)) + }) + player.events.on('audioTrackAdd', (queue,track)=>queue.channel.send({embeds:[new client.embed().setColor(client.config.embedColorGreen).setTitle(`${track.raw.title} - ${track.raw.author}`).setFooter({text:`Added to queue`}).setThumbnail(track.raw.thumbnail)]})); + /* player.events.on('debug', (queue,message)=>{ + console.log(client.logTime(), message) + }) */ + player.events.on('playerError', (queue, error)=>DZ(error, 'playerError')); + player.events.on('error', (queue, error)=>DZ(error, 'playerInternalError')); +} // YouTube Upload notification and Daggerwin MP loop setInterval(()=>MPLoop(client, client.config.MPStatsLocation.channel, client.config.MPStatsLocation.message, 'Daggerwin'), 60000); diff --git a/src/typings/interfaces.d.ts b/src/typings/interfaces.d.ts index 16f2af8..2979dbc 100644 --- a/src/typings/interfaces.d.ts +++ b/src/typings/interfaces.d.ts @@ -144,6 +144,7 @@ export interface Config { registerCommands: boolean, commands: boolean, logs: boolean, + music: boolean, buttonRoles: boolean, automod: boolean, mpstats: boolean,