1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-09-29 08:20:59 -04:00

Add botSwitch for music module

This commit is contained in:
toast-ts 2023-06-25 12:17:35 +10:00
parent 44cf971363
commit a57d8069c3
4 changed files with 15 additions and 10 deletions

View File

@ -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, {

View File

@ -19,6 +19,7 @@
"registerCommands": true,
"commands": true,
"logs": true,
"music": false,
"buttonRoles": true,
"automod": true,
"mpstats": true,

View File

@ -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);

View File

@ -144,6 +144,7 @@ export interface Config {
registerCommands: boolean,
commands: boolean,
logs: boolean,
music: boolean,
buttonRoles: boolean,
automod: boolean,
mpstats: boolean,