mirror of
https://github.com/hazemKrimi/discord-bot.git
synced 2026-05-01 18:30:25 +00:00
added small changes
This commit is contained in:
@@ -33,7 +33,7 @@ module.exports = class Play extends Command {
|
|||||||
else {
|
else {
|
||||||
message.guild.music.paused = true;
|
message.guild.music.paused = true;
|
||||||
message.guild.music.dispatcher.pause(true);
|
message.guild.music.dispatcher.pause(true);
|
||||||
const embed = new MessageEmbed().setColor('#000099').setTitle(':pause_button: paused player');
|
const embed = new MessageEmbed().setColor('#000099').setTitle(':pause_button: Paused player');
|
||||||
return await message.say({ embed });
|
return await message.say({ embed });
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ module.exports = class Play extends Command {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (message.guild.music.isPlaying) {
|
if (message.guild.music.isPlaying) {
|
||||||
const embed = new MessageEmbed().setColor('#000099').setTitle(`:arrow_forward: "${playlist.title}" (${playlistVideos.length} tracks) added to queue`);
|
const embed = new MessageEmbed().setColor('#000099').setTitle(`:arrow_forward: Added "${playlist.title}" to queue (${playlistVideos.length} tracks)`);
|
||||||
return await message.say({ embed });
|
return await message.say({ embed });
|
||||||
}
|
}
|
||||||
} else if (query.match(/^(http(s)?:\/\/)?((w){3}.)?youtu(be|.be)?(\.com)?\/\S+/)) {
|
} else if (query.match(/^(http(s)?:\/\/)?((w){3}.)?youtu(be|.be)?(\.com)?\/\S+/)) {
|
||||||
@@ -100,7 +100,7 @@ module.exports = class Play extends Command {
|
|||||||
message.guild.music.isPlaying = true;
|
message.guild.music.isPlaying = true;
|
||||||
return message.guild.play(message.guild.music.queue, message);
|
return message.guild.play(message.guild.music.queue, message);
|
||||||
} else {
|
} else {
|
||||||
const embed = new MessageEmbed().setColor('#000099').setTitle(`:arrow_forward: "${data.title}" added to queue`);
|
const embed = new MessageEmbed().setColor('#000099').setTitle(`:arrow_forward: Added "${data.title}" to queue`);
|
||||||
return await message.say({ embed });
|
return await message.say({ embed });
|
||||||
}
|
}
|
||||||
} else if (query.match(/^(http(s)?:\/\/)?((w){3}.)?facebook?(\.com)?\/\S+\/videos\/\S+/)) {
|
} else if (query.match(/^(http(s)?:\/\/)?((w){3}.)?facebook?(\.com)?\/\S+\/videos\/\S+/)) {
|
||||||
@@ -149,7 +149,7 @@ module.exports = class Play extends Command {
|
|||||||
message.guild.music.isPlaying = true;
|
message.guild.music.isPlaying = true;
|
||||||
return message.guild.play(message.guild.music.queue, message);
|
return message.guild.play(message.guild.music.queue, message);
|
||||||
} else {
|
} else {
|
||||||
const embed = new MessageEmbed().setColor('#000099').setTitle(`:arrow_forward: "${data.title}" added to queue`);
|
const embed = new MessageEmbed().setColor('#000099').setTitle(`:arrow_forward: Added "${data.title}" to queue`);
|
||||||
return await message.say({ embed });
|
return await message.say({ embed });
|
||||||
}
|
}
|
||||||
} else if (query.match(/^(http(s)?:\/\/)?((w){3}\S)?\S+(\.)\S+\/\S+\.(\S){3}/)) {
|
} else if (query.match(/^(http(s)?:\/\/)?((w){3}\S)?\S+(\.)\S+\/\S+\.(\S){3}/)) {
|
||||||
@@ -184,7 +184,7 @@ module.exports = class Play extends Command {
|
|||||||
message.guild.music.isPlaying = true;
|
message.guild.music.isPlaying = true;
|
||||||
return message.guild.play(message.guild.music.queue, message);
|
return message.guild.play(message.guild.music.queue, message);
|
||||||
} else {
|
} else {
|
||||||
const embed = new MessageEmbed().setColor('#000099').setTitle(`:arrow_forward: "${data.title}" added to queue`);
|
const embed = new MessageEmbed().setColor('#000099').setTitle(`:arrow_forward: Added "${data.title}" to queue`);
|
||||||
return await message.say({ embed });
|
return await message.say({ embed });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -218,7 +218,7 @@ module.exports = class Play extends Command {
|
|||||||
message.guild.music.isPlaying = true;
|
message.guild.music.isPlaying = true;
|
||||||
return message.guild.play(message.guild.music.queue, message);
|
return message.guild.play(message.guild.music.queue, message);
|
||||||
} else {
|
} else {
|
||||||
const embed = new MessageEmbed().setColor('#000099').setTitle(`:arrow_forward: "${data.title}" added to queue`);
|
const embed = new MessageEmbed().setColor('#000099').setTitle(`:arrow_forward: Added "${data.title}" to queue`);
|
||||||
return await message.say({ embed });
|
return await message.say({ embed });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,16 +24,14 @@ module.exports = class Play extends Command {
|
|||||||
} else {
|
} else {
|
||||||
const embed = new MessageEmbed().setColor('#000099').setTitle(':musical_note: Queue');
|
const embed = new MessageEmbed().setColor('#000099').setTitle(':musical_note: Queue');
|
||||||
|
|
||||||
embed.addField('Now playing', message.guild.music.nowPlaying.title).addField('Duration', `${message.guild.music.nowPlaying.playingFor.string}/${message.guild.music.nowPlaying.duration.string}`);
|
embed
|
||||||
|
.addField('Now playing', `${message.guild.music.nowPlaying.title} ${message.guild.music.nowPlaying.by && `By ${message.guild.music.nowPlaying.by}`}`)
|
||||||
|
.addField('Duration', `${message.guild.music.nowPlaying.playingFor.string}/${message.guild.music.nowPlaying.duration.string}`);
|
||||||
|
|
||||||
if (message.guild.music.queue.length === 0) embed.addField('Queue', 'nothing in the queue');
|
if (message.guild.music.queue.length === 0) embed.addField('Queue', 'nothing in the queue');
|
||||||
else embed.addField('Queue', `${message.guild.music.queue.length} track(s)`);
|
else embed.addField('Queue', `${message.guild.music.queue.length} track(s)`);
|
||||||
|
|
||||||
message.guild.music.queue.forEach((item, index) => {
|
message.guild.music.queue.forEach((item, index) => embed.addField(index + 1, `${item.title} ${item.by && `By ${item.by}`}`));
|
||||||
let itemString = `${item.title}`;
|
|
||||||
if (item.type === 'youtube' || item.type === 'search' || item.type === 'facebook') itemString += ` By ${item.by}`;
|
|
||||||
embed.addField(index + 1, itemString);
|
|
||||||
});
|
|
||||||
|
|
||||||
return await message.say({ embed });
|
return await message.say({ embed });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ module.exports = class Play extends Command {
|
|||||||
else {
|
else {
|
||||||
message.guild.music.paused = false;
|
message.guild.music.paused = false;
|
||||||
message.guild.music.dispatcher.resume();
|
message.guild.music.dispatcher.resume();
|
||||||
const embed = new MessageEmbed().setColor('#000099').setTitle(':arrow_forward: resumed player');
|
const embed = new MessageEmbed().setColor('#000099').setTitle(':arrow_forward: Resumed player');
|
||||||
return await message.say({ embed });
|
return await message.say({ embed });
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -79,47 +79,53 @@ Structures.extend('Guild', Guild => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
startCounter = message => {
|
startCounter = message => {
|
||||||
if (!message.guild.music.nowPlaying.playingFor) message.guild.music.nowPlaying.playingFor = { hours: 0, minutes: 0, seconds: 0, string: '00:00:00' };
|
try {
|
||||||
|
if (!message.guild.music.nowPlaying.playingFor) message.guild.music.nowPlaying.playingFor = { hours: 0, minutes: 0, seconds: 0, string: '00:00:00' };
|
||||||
const interval = setInterval(() => {
|
|
||||||
if (!message.guild.music.nowPlaying || message.guild.music.paused) clearInterval(interval);
|
const interval = setInterval(() => {
|
||||||
else if (message.guild.music.nowPlaying.playingFor.seconds === 60) {
|
if (!message.guild.music.nowPlaying || message.guild.music.paused) clearInterval(interval);
|
||||||
message.guild.music.nowPlaying.playingFor = {
|
else if (message.guild.music.nowPlaying.playingFor.seconds === 60) {
|
||||||
hours: message.guild.music.nowPlaying.playingFor.hours,
|
message.guild.music.nowPlaying.playingFor = {
|
||||||
minutes: message.guild.music.nowPlaying.playingFor.minutes + 1,
|
|
||||||
seconds: 0,
|
|
||||||
string: this.formatDuration({
|
|
||||||
hours: message.guild.music.nowPlaying.playingFor.hours,
|
hours: message.guild.music.nowPlaying.playingFor.hours,
|
||||||
minutes: message.guild.music.nowPlaying.playingFor.minutes + 1,
|
minutes: message.guild.music.nowPlaying.playingFor.minutes + 1,
|
||||||
seconds: 0
|
seconds: 0,
|
||||||
})
|
string: this.formatDuration({
|
||||||
};
|
hours: message.guild.music.nowPlaying.playingFor.hours,
|
||||||
}
|
minutes: message.guild.music.nowPlaying.playingFor.minutes + 1,
|
||||||
else if (message.guild.music.nowPlaying.playingFor.minutes === 60) {
|
seconds: 0
|
||||||
message.guild.music.nowPlaying.playingFor = {
|
})
|
||||||
hours: message.guild.music.nowPlaying.playingFor.hours + 1,
|
};
|
||||||
minutes: 0,
|
}
|
||||||
seconds: 0,
|
else if (message.guild.music.nowPlaying.playingFor.minutes === 60) {
|
||||||
string: this.formatDuration({
|
message.guild.music.nowPlaying.playingFor = {
|
||||||
hours: message.guild.music.nowPlaying.playingFor.hours + 1,
|
hours: message.guild.music.nowPlaying.playingFor.hours + 1,
|
||||||
minutes: 0,
|
minutes: 0,
|
||||||
seconds: 0
|
seconds: 0,
|
||||||
})
|
string: this.formatDuration({
|
||||||
};
|
hours: message.guild.music.nowPlaying.playingFor.hours + 1,
|
||||||
}
|
minutes: 0,
|
||||||
else {
|
seconds: 0
|
||||||
message.guild.music.nowPlaying.playingFor = {
|
})
|
||||||
hours: message.guild.music.nowPlaying.playingFor.hours,
|
};
|
||||||
minutes: message.guild.music.nowPlaying.playingFor.minutes,
|
}
|
||||||
seconds: message.guild.music.nowPlaying.playingFor.seconds + 1,
|
else {
|
||||||
string: this.formatDuration({
|
message.guild.music.nowPlaying.playingFor = {
|
||||||
hours: message.guild.music.nowPlaying.playingFor.hours,
|
hours: message.guild.music.nowPlaying.playingFor.hours,
|
||||||
minutes: message.guild.music.nowPlaying.playingFor.minutes,
|
minutes: message.guild.music.nowPlaying.playingFor.minutes,
|
||||||
seconds: message.guild.music.nowPlaying.playingFor.seconds + 1
|
seconds: message.guild.music.nowPlaying.playingFor.seconds + 1,
|
||||||
})
|
string: this.formatDuration({
|
||||||
};
|
hours: message.guild.music.nowPlaying.playingFor.hours,
|
||||||
}
|
minutes: message.guild.music.nowPlaying.playingFor.minutes,
|
||||||
}, 1000);
|
seconds: message.guild.music.nowPlaying.playingFor.seconds + 1
|
||||||
|
})
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
} catch(err) {
|
||||||
|
console.error(err);
|
||||||
|
const embed = new MessageEmbed().setColor('#ff0000').setTitle(`:x: Error occured: ${err.message}`);
|
||||||
|
return message.say({ embed });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
formatDuration = durationObject => {
|
formatDuration = durationObject => {
|
||||||
|
|||||||
Reference in New Issue
Block a user