mirror of
https://github.com/musix-org/musix-oss
synced 2024-11-10 05:10:17 +00:00
Updated the way currently playing music is declared.
This should get arid of the problem when skipping/stopping music causes the bot to error.
This commit is contained in:
parent
a05b069f99
commit
0c72a2d9b1
@ -8,7 +8,7 @@ module.exports = {
|
||||
const serverQueue = client.queue.get(message.guild.id);
|
||||
const permissions = message.channel.permissionsFor(message.author);
|
||||
const { voiceChannel } = message.member;
|
||||
if (serverQueue) {
|
||||
if (serverQueue.playing) {
|
||||
if (message.author.id !== client.config.dev) {
|
||||
if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voice channel as Musix to loop the queue!');
|
||||
if (client.global.db.guilds[message.guild.id].permissions === true) {
|
||||
|
@ -7,7 +7,7 @@ module.exports = {
|
||||
async execute(message, args, client, Discord, prefix) {
|
||||
const ytdl = require('ytdl-core');
|
||||
const serverQueue = client.queue.get(message.guild.id);
|
||||
if (!serverQueue) return message.channel.send(':x: There is nothing playing.');
|
||||
if (!serverQueue.playing) return message.channel.send(':x: There is nothing playing.');
|
||||
let data = await Promise.resolve(ytdl.getInfo(serverQueue.songs[0].url));
|
||||
let songtime = (data.length_seconds * 1000).toFixed(0);
|
||||
let completed = (serverQueue.connection.dispatcher.time).toFixed(0);
|
||||
|
@ -8,7 +8,7 @@ module.exports = {
|
||||
const serverQueue = client.queue.get(message.guild.id);
|
||||
const permissions = message.channel.permissionsFor(message.author);
|
||||
const { voiceChannel } = message.member;
|
||||
if (serverQueue && serverQueue.playing === true) {
|
||||
if (serverQueue.playing && !serverQueue.paused) {
|
||||
if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voice channel as Musix to pause the music!');
|
||||
if (message.author.id !== client.config.dev) {
|
||||
if (client.global.db.guilds[message.guild.id].permissions === true) {
|
||||
@ -17,10 +17,9 @@ module.exports = {
|
||||
} else if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to pause the music!');
|
||||
}
|
||||
}
|
||||
serverQueue.playing = false;
|
||||
serverQueue.paused = true;
|
||||
serverQueue.connection.dispatcher.pause();
|
||||
return message.channel.send('⏸ Paused the music!');
|
||||
}
|
||||
return message.channel.send(':x: There is nothing playing.');
|
||||
} else return message.channel.send(':x: There is nothing playing.');
|
||||
}
|
||||
};
|
||||
|
@ -6,7 +6,7 @@ module.exports = {
|
||||
onlyDev: false,
|
||||
async execute(message, args, client, Discord, prefix) {
|
||||
const serverQueue = client.queue.get(message.guild.id);
|
||||
if (!serverQueue) return message.channel.send(':x: There is nothing playing.');
|
||||
if (!serverQueue.playing) return message.channel.send(':x: There is nothing playing.');
|
||||
if (args[1]) {
|
||||
if (isNaN(args[1])) return msg.channel.send(':x: I\'m sorry, But you need to enter a valid __number__.');
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ module.exports = {
|
||||
const { voiceChannel } = message.member;
|
||||
const serverQueue = client.queue.get(message.guild.id);
|
||||
const permissions = message.channel.permissionsFor(message.author);
|
||||
if (!serverQueue) return message.channel.send(':x: There is nothing playing');
|
||||
if (!serverQueue.playing) return message.channel.send(':x: There is nothing playing');
|
||||
if (!args[1]) return message.channel.send(':x: Please provide a song position in queue for me to remove!');
|
||||
const pos = parseInt(args[1]);
|
||||
if (isNaN(pos)) return message.channel.send(':x: You need to enter a number!');
|
||||
|
@ -8,7 +8,7 @@ module.exports = {
|
||||
const serverQueue = client.queue.get(message.guild.id);
|
||||
const permissions = message.channel.permissionsFor(message.author);
|
||||
const { voiceChannel } = message.member;
|
||||
if (serverQueue && !serverQueue.playing) {
|
||||
if (serverQueue.playing && serverQueue.paused) {
|
||||
if (message.author.id !== client.config.dev) {
|
||||
if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voice channel as Musix to loop the queue!');
|
||||
if (client.global.db.guilds[message.guild.id].permissions === true) {
|
||||
@ -17,7 +17,7 @@ module.exports = {
|
||||
} else if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to resume the music!');
|
||||
}
|
||||
}
|
||||
serverQueue.playing = true;
|
||||
serverQueue.paused = false;
|
||||
serverQueue.connection.dispatcher.resume();
|
||||
return message.channel.send('▶ Resumed the music!');
|
||||
}
|
||||
|
@ -3,16 +3,15 @@ module.exports = {
|
||||
description: 'seek command.',
|
||||
alias: 'seek',
|
||||
cooldown: 10,
|
||||
onlyDev: false,
|
||||
onlyDev: true,
|
||||
async execute(message, args, client, Discord, prefix) {
|
||||
const ytdl = require('ytdl-core');
|
||||
const serverQueue = client.queue.get(message.guild.id);
|
||||
const permissions = message.channel.permissionsFor(message.author);
|
||||
const { voiceChannel } = message.member;
|
||||
let data = await Promise.resolve(ytdl.getInfo(serverQueue.songs[0].url));
|
||||
if (serverQueue) {
|
||||
if (message.author.id !== client.config.dev) {
|
||||
return message.channel.send(':x: This command is currently disabled!');
|
||||
if (serverQueue.playing) {
|
||||
if (message.author.id !== client.config.devId) {
|
||||
if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voice channel as Musix to seek the song!');
|
||||
if (client.global.db.guilds[message.guild.id].permissions === true) {
|
||||
if (client.global.db.guilds[message.guild.id].dj) {
|
||||
|
@ -8,7 +8,7 @@ module.exports = {
|
||||
const { voiceChannel } = message.member;
|
||||
const serverQueue = client.queue.get(message.guild.id);
|
||||
const permissions = message.channel.permissionsFor(message.author);
|
||||
if (!serverQueue) return message.channel.send(':x: There is nothing playing that I could skip for you.');
|
||||
if (!serverQueue.playing) return message.channel.send(':x: There is nothing playing that I could skip for you.');
|
||||
if (message.author.id !== client.config.dev) {
|
||||
if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voice channel as Musix to skip the song!');
|
||||
if (client.global.db.guilds[message.guild.id].permissions === true) {
|
||||
|
@ -9,7 +9,7 @@ module.exports = {
|
||||
const serverQueue = client.queue.get(message.guild.id);
|
||||
const permissions = message.channel.permissionsFor(message.author);
|
||||
if (message.author.id !== client.config.dev) {
|
||||
if (!serverQueue) return message.channel.send(':x: There is nothing playing that I could stop for you.');
|
||||
if (!serverQueue.playing) return message.channel.send(':x: There is nothing playing that I could stop for you.');
|
||||
if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voice channel as Musix to stop the music!');
|
||||
if (client.global.db.guilds[message.guild.id].permissions === true) {
|
||||
if (client.global.db.guilds[message.guild.id].dj) {
|
||||
|
@ -8,7 +8,7 @@ module.exports = {
|
||||
const { voiceChannel } = message.member;
|
||||
const serverQueue = client.queue.get(message.guild.id);
|
||||
const permissions = message.channel.permissionsFor(message.author);
|
||||
if (!serverQueue) return message.channel.send(':x: There is nothing playing.');
|
||||
if (!serverQueue.playing) return message.channel.send(':x: There is nothing playing.');
|
||||
if (!args[1]) return message.channel.send(`:loud_sound: The current volume is: **${serverQueue.volume}**`);
|
||||
const volume = parseFloat(args[1]);
|
||||
if (message.author.id !== client.config.dev) {
|
||||
|
@ -21,7 +21,8 @@ module.exports = async function (video, message, voiceChannel, client, playlist
|
||||
connection: null,
|
||||
songs: [],
|
||||
volume: client.global.db.guilds[message.guild.id].defaultVolume,
|
||||
playing: true,
|
||||
playing: false,
|
||||
paused: false,
|
||||
looping: false,
|
||||
votes: 0,
|
||||
voters: [],
|
||||
|
@ -33,6 +33,7 @@ module.exports = async function (guild, song, client, message, seek, play) {
|
||||
.setTitle(`:musical_note: Start playing: **${song.title}**`)
|
||||
.setDescription(`Song duration: \`${client.funcs.msToTime(songtime)}\``)
|
||||
.setColor("#b50002")
|
||||
serverQueue.playing = true;
|
||||
serverQueue.textChannel.send(embed);
|
||||
}
|
||||
}
|
||||
|
1094
package-lock.json
generated
1094
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user