mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 12:21:00 -05:00
Add dedicated class for music module
This commit is contained in:
parent
4b8917982e
commit
0b09fc769d
@ -1,6 +1,12 @@
|
|||||||
import Discord from 'discord.js';
|
import Discord from 'discord.js';
|
||||||
|
|
||||||
export default class MessageTool {
|
export default class MessageTool {
|
||||||
|
static embedMusic(color:Discord.ColorResolvable, title:string, thumbnail?:string, footer?:string){
|
||||||
|
const embed = new Discord.EmbedBuilder().setColor(color).setTitle(title);
|
||||||
|
if (thumbnail) embed.setThumbnail(thumbnail);
|
||||||
|
if (footer) embed.setFooter({text: footer});
|
||||||
|
return embed
|
||||||
|
}
|
||||||
static embedStruct(color:Discord.ColorResolvable, title:string, description?:string|null, image?:string|null){
|
static embedStruct(color:Discord.ColorResolvable, title:string, description?:string|null, image?:string|null){
|
||||||
const embed = new Discord.EmbedBuilder().setColor(color).setTitle(title);
|
const embed = new Discord.EmbedBuilder().setColor(color).setTitle(title);
|
||||||
if (description) embed.setDescription(description);
|
if (description) embed.setDescription(description);
|
||||||
|
@ -25,13 +25,13 @@ client.on('error', (error: Error)=>DZ(error, 'clientError'));
|
|||||||
|
|
||||||
// Audio Player event handling
|
// Audio Player event handling
|
||||||
if (client.config.botSwitches.music){
|
if (client.config.botSwitches.music){
|
||||||
player.events.on('playerStart', (queue,track)=>queue.channel.send({embeds:[MessageTool.embedStruct(client.config.embedColor, `Next up: ${track.raw.title} - ${track.raw.author}`,track.raw.thumbnail)]}));
|
player.events.on('playerStart', (queue,track)=>queue.channel.send({embeds:[MessageTool.embedMusic(client.config.embedColor, `Next up: ${track.raw.title} - ${track.raw.author}`,track.raw.thumbnail)]}));
|
||||||
player.events.on('audioTrackAdd', (queue,track)=>queue.channel.send({embeds:[MessageTool.embedStruct(client.config.embedColorGreen, `Added: ${track.raw.title} - ${track.raw.author}`,track.raw.thumbnail)]}));
|
player.events.on('audioTrackAdd', (queue,track)=>queue.channel.send({embeds:[MessageTool.embedMusic(client.config.embedColorGreen, `Added: ${track.raw.title} - ${track.raw.author}`,track.raw.thumbnail)]}));
|
||||||
player.events.on('audioTrackRemove', (queue, track)=>queue.channel.send({embeds:[MessageTool.embedStruct(client.config.embedColor, `Removed: ${track.raw.title} - ${track.raw.author}`,track.raw.thumbnail)]}));
|
player.events.on('audioTrackRemove', (queue, track)=>queue.channel.send({embeds:[MessageTool.embedMusic(client.config.embedColor, `Removed: ${track.raw.title} - ${track.raw.author}`,track.raw.thumbnail)]}));
|
||||||
player.events.on('emptyQueue', queue=>{
|
player.events.on('emptyQueue', queue=>{
|
||||||
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))
|
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('playerPause', queue=>queue.channel.send({embeds:[MessageTool.embedStruct(client.config.embedColor, 'Player has been paused.\nRun the command to unpause it')]}));
|
player.events.on('playerPause', queue=>queue.channel.send({embeds:[MessageTool.embedMusic(client.config.embedColor, 'Player has been paused.\nRun the command to unpause it')]}));
|
||||||
player.events.on('playerError', (queue, error)=>DZ(error, 'playerError')); // I don't know if both of these actually works, because most
|
player.events.on('playerError', (queue, error)=>DZ(error, 'playerError')); // I don't know if both of these actually works, because most
|
||||||
player.events.on('error', (queue, error)=>DZ(error, 'playerInternalError')); // errors from the player is coming from unhandledRejection
|
player.events.on('error', (queue, error)=>DZ(error, 'playerInternalError')); // errors from the player is coming from unhandledRejection
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user