Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes #280

Merged
merged 33 commits into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a604d58
added better checks so won't break on loadtypes
Xenofic Sep 8, 2022
bfeca61
Added autocompletion support for other search engines
Xenofic Sep 9, 2022
9175836
chore: autocompletion support for other search engine and bug fixes
Xenofic Sep 9, 2022
f957f09
feat: autocompletion support for other search engines and bug fixes 🐛
Xenofic Sep 9, 2022
5e40b68
bug: fixed a bug on autocompletion input being the value
Xenofic Sep 10, 2022
87bea82
fix: thumbnails and url doesn't display on soundcloud tracks
Xenofic Sep 10, 2022
0afae98
feat: added cheerio dependency to parse html
Xenofic Sep 10, 2022
c7c71b1
Merge branch 'dev' of https://github.com/NotAditya69/lavamusic into dev
Xenofic Sep 10, 2022
1be0d17
Update config.js
Xenofic Sep 10, 2022
26abfd5
fix: fixed the bug dataChannel is null
Xenofic Sep 10, 2022
bb0812a
Merge branch 'dev' of https://github.com/NotAditya69/lavamusic into dev
Xenofic Sep 10, 2022
f6e35c0
fix: Issue #273 voiceStateUpdate issue
Xenofic Sep 10, 2022
90d4beb
Delete config.js
Xenofic Sep 10, 2022
73ed246
Create config.js
Xenofic Sep 10, 2022
9209cf3
fix: autoplay doesn't works 🐛
Xenofic Sep 11, 2022
677efec
fix: has issues in application command 🐛
Xenofic Sep 11, 2022
677d8f9
fix: autoplay queue randomized and not index 2
Xenofic Sep 11, 2022
481da5a
Merge branch 'dev' of https://github.com/NotAditya69/lavamusic into dev
Xenofic Sep 11, 2022
5749884
changes in git ignore
Xenofic Sep 11, 2022
fcef003
fix: Issue #281 however session id's aren't resumed
Xenofic Sep 11, 2022
586fdae
fix: fixed all of the errors on the pr
Xenofic Sep 11, 2022
64327ce
fixed some more stuff
Xenofic Sep 11, 2022
49a6949
autoplay defer loop fixed
Xenofic Sep 11, 2022
37cfada
same issue as autoplay
Xenofic Sep 11, 2022
b6765d1
fix: #281
Xenofic Sep 11, 2022
6e06a4f
recommit on #281
Xenofic Sep 11, 2022
a94763b
ignore: prototype update
Xenofic Sep 11, 2022
53742cc
#281 recommit fix
Xenofic Sep 11, 2022
518a155
recommit #281
Xenofic Sep 12, 2022
efa9aab
recommit on #281 added new emitter and changed some things
Xenofic Sep 12, 2022
facddc0
typo
Xenofic Sep 12, 2022
4d74f84
more typos
Xenofic Sep 12, 2022
e639829
reverted some updates
Xenofic Sep 12, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
node_modules
.vscode
package-lock.json
config.js
.env
yarn.lock
yarn.lock
/src/config.js
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"dependencies": {
"@discordjs/rest": "^1.0.0",
"chalk": "^4.1.2",
"cheerio": "^1.0.0-rc.12",
"delay": "^5.0.0",
"discord.js": "14.3.0",
"dotenv": "^10.0.0",
Expand Down
30 changes: 15 additions & 15 deletions src/commands/Music/autoplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,38 @@ module.exports = {
inVoiceChannel: true,
sameVoiceChannel: true,
execute: async (message, args, client, prefix) => {

const player = client.manager.get(message.guild.id);

const autoplay = player.get("autoplay");

const emojireplay = client.emoji.autoplay;

if (!player.queue.current)
return message.reply({
content: `Please play a song before using this command.`,
});

if (autoplay === false) {
const identifier = player.queue.current.identifier;
player.set("autoplay", true);
player.set("requester", message.author);
player.set("identifier", identifier);
const search = `https://www.youtube.com/watch?v=${identifier}&list=RD${identifier}`;
res = await player.search(search, message.author);
player.queue.add(res.tracks[1]);

if (autoplay) {
player.set("autoplay", false);
let thing = new EmbedBuilder()
.setColor(client.embedColor)
.setTimestamp()
.setDescription(`${emojireplay} Autoplay is now **enabled**.`);
.setDescription(`${emojireplay} Autoplay is now **disabled**.`);
return message.channel.send({ embeds: [thing] });
} else {
player.set("autoplay", false);
player.queue.clear();
const identifier = player.queue.current.identifier;
player.set("autoplay", true);
player.set("requester", client.user);
player.set("identifier", identifier);
const search = `https://www.youtube.com/watch?v=${identifier}&list=RD${identifier}`;
const res = await player.search(search, message.author);
player.queue.add(
res.tracks[Math.floor(Math.random() * res.tracks.length) ?? 1]
);
let thing = new EmbedBuilder()
.setColor(client.embedColor)
.setTimestamp()
.setDescription(`${emojireplay} Autoplay is now **disabled**.`);
.setDescription(`${emojireplay} Autoplay is now **enabled**.`);

return message.channel.send({ embeds: [thing] });
}
Expand Down
136 changes: 105 additions & 31 deletions src/commands/Music/play.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { EmbedBuilder, PermissionsBitField } = require("discord.js");
const { convertTime } = require('../../utils/convert.js');
const { convertTime } = require("../../utils/convert.js");
const { Player } = require("erela.js");

module.exports = {
name: "play",
Expand All @@ -14,43 +15,89 @@ module.exports = {
inVoiceChannel: true,
sameVoiceChannel: true,
execute: async (message, args, client, prefix) => {

if (!message.guild.members.me.permissions.has(PermissionsBitField.resolve(['Speak', 'Connect']))) return message.channel.send({ embeds: [new EmbedBuilder().setColor(client.embedColor).setDescription(`I don't have enough permissions to execute this command! Please give me permission to \`CONNECT\` or \`SPEAK\`.`)] });
if (
!message.guild.members.me.permissions.has(
PermissionsBitField.resolve(["Speak", "Connect"])
)
)
return message.channel.send({
embeds: [
new EmbedBuilder()
.setColor(client.embedColor)
.setDescription(
`I don't have enough permissions to execute this command! Please give me permission to \`CONNECT\` or \`SPEAK\`.`
),
],
});
const { channel } = message.member.voice;
if (!message.guild.members.cache.get(client.user.id).permissionsIn(channel).has(PermissionsBitField.resolve(['Speak', 'Connect']))) return message.channel.send({ embeds: [new EmbedBuilder().setColor(client.embedColor).setDescription(`I don't have enough permissions connect your VC! Please give me permission to \`CONNECT\` or \`SPEAK\`.`)] });
if (
!message.guild.members.cache
.get(client.user.id)
.permissionsIn(channel)
.has(PermissionsBitField.resolve(["Speak", "Connect"]))
)
return message.channel.send({
embeds: [
new EmbedBuilder()
.setColor(client.embedColor)
.setDescription(
`I don't have enough permissions connect your VC! Please give me permission to \`CONNECT\` or \`SPEAK\`.`
),
],
});


const emojiaddsong = message.client.emoji.addsong;
const emojiplaylist = message.client.emoji.playlist
const emojiplaylist = message.client.emoji.playlist;

const player = client.manager.create({
guild: message.guild.id,
voiceChannel: message.member.voice.channel.id,
textChannel: message.channel.id,
selfDeafen: true,
volume: 80,
});
/**
* @type {Player}
*/
let player = client.manager.get(message.guild.id);

if (!player)
player = await client.manager.create({
guild: message.guild.id,
voiceChannel: message.member.voice.channel.id,
textChannel: message.channel.id,
selfDeafen: true,
volume: 80,
});

if (player.state != "CONNECTED") await player.connect();
const search = args.join(' ');
const search = args.join(" ");
let res;

try {
res = await player.search(search, message.author);
if (!player)
return message.channel.send({ embeds: [new EmbedBuilder().setColor(client.embedColor).setTimestamp().setDescription("Nothing is playing right now...")] });
if (res.loadType === 'LOAD_FAILED') {
return message.channel.send({
embeds: [
new EmbedBuilder()
.setColor(client.embedColor)
.setTimestamp()
.setDescription("Nothing is playing right now..."),
],
});
if (res.loadType === "LOAD_FAILED") {
if (!player.queue.current) player.destroy();
throw res.exception;
}
} catch (err) {
return message.reply(`There was an error while searching: ${err.message}`);
return message.reply(
`There was an error while searching: ${err.message}`
);
}
switch (res.loadType) {
case 'NO_MATCHES':
case "NO_MATCHES":
if (!player.queue.current) player.destroy();
return message.channel.send({ embeds: [new EmbedBuilder().setColor(client.embedColor).setTimestamp().setDescription(`❌ | No matches found for - ${search}`)]});
case 'TRACK_LOADED':
return message.channel.send({
embeds: [
new EmbedBuilder()
.setColor(client.embedColor)
.setTimestamp()
.setDescription(`❌ | No matches found for - ${search}`),
],
});
case "TRACK_LOADED":
var track = res.tracks[0];
player.queue.add(track);
if (!player.playing && !player.paused && !player.queue.size) {
Expand All @@ -59,19 +106,37 @@ module.exports = {
const thing = new EmbedBuilder()
.setColor(client.embedColor)
.setTimestamp()
.setThumbnail(track.displayThumbnail("hqdefault"))
.setDescription(`${emojiaddsong} **Added song to queue**\n[${track.title}](${track.uri}) - \`[${convertTime(track.duration)}]\``)
.setThumbnail(
track.displayThumbnail("hqdefault") ??
(await client.manager.getMetaThumbnail(track.uri))
)
.setDescription(
`${emojiaddsong} **Added song to queue**\n[${track.title}](${
track.uri
}) - \`[${convertTime(track.duration)}]\``
);
return message.channel.send({ embeds: [thing] });
}
case 'PLAYLIST_LOADED':
case "PLAYLIST_LOADED":
player.queue.add(res.tracks);
if (!player.playing && !player.paused && player.queue.totalSize === res.tracks.length) player.play();
if (
!player.playing &&
!player.paused &&
player.queue.totalSize === res.tracks.length
)
player.play();
const thing = new EmbedBuilder()
.setColor(client.embedColor)
.setTimestamp()
.setDescription(`${emojiplaylist} **Added playlist to queue**\n${res.tracks.length} Songs [${res.playlist.name}](${search}) - \`[${convertTime(res.playlist.duration)}]\``)
.setDescription(
`${emojiplaylist} **Added playlist to queue**\n${
res.tracks.length
} Songs [${res.playlist.name}](${search}) - \`[${convertTime(
res.playlist.duration
)}]\``
);
return message.channel.send({ embeds: [thing] });
case 'SEARCH_RESULT':
case "SEARCH_RESULT":
var track = res.tracks[0];
player.queue.add(track);
if (!player.playing && !player.paused && !player.queue.size) {
Expand All @@ -80,10 +145,19 @@ module.exports = {
const thing = new EmbedBuilder()
.setColor(client.embedColor)
.setTimestamp()
.setThumbnail(track.displayThumbnail("hqdefault"))
.setDescription(`${emojiaddsong} **Added song to queue**\n[${track.title}](${track.uri}) - \`[${convertTime(track.duration)}]\`[<@${track.requester.id}>]`)
.setThumbnail(
track.displayThumbnail("hqdefault") ??
(await client.manager.getMetaThumbnail(track.uri))
)
.setDescription(
`${emojiaddsong} **Added song to queue**\n[${track.title}](${
track.uri
}) - \`[${convertTime(track.duration)}]\`[<@${
track.requester.id
}>]`
);
return message.channel.send({ embeds: [thing] });
}
}
}
}
},
};
53 changes: 27 additions & 26 deletions src/commands/Music/skip.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
const { EmbedBuilder } = require("discord.js");

module.exports = {
name: "skip",
aliases: ["s"],
category: "Music",
description: "Skip the song currently playing.",
args: false,
name: "skip",
aliases: ["s"],
category: "Music",
description: "Skip the song currently playing.",
args: false,
usage: "",
userPerms: [],
dj: true,
owner: false,
player: true,
inVoiceChannel: true,
sameVoiceChannel: true,
execute: async (message, args, client, prefix) => {

const player = message.client.manager.get(message.guild.id);
execute: async (message, args, client, prefix) => {
const player = message.client.manager.get(message.guild.id);

if (!player.queue.current) {
let thing = new EmbedBuilder()
.setColor("Red")
.setDescription("There is no music playing.");
return message.reply({embeds: [thing]});
}
const song = player.queue.current;
if (!player.queue.current) {
let thing = new EmbedBuilder()
.setColor("Red")
.setDescription("There is no music playing.");
return message.reply({ embeds: [thing] });
}
const song = player.queue.current;

player.stop();

const emojiskip = message.client.emoji.skip;
player.stop();

let thing = new EmbedBuilder()
.setDescription(`${emojiskip} **Skipped**\n[${song.title}](${song.uri})`)
.setColor(message.client.embedColor)
.setTimestamp()
return message.reply({embeds: [thing]}).then(msg => { setTimeout(() => {msg.delete()}, 3000);
})

}
const emojiskip = message.client.emoji.skip;

let thing = new EmbedBuilder()
.setDescription(`${emojiskip} **Skipped**\n[${song.title}](${song.uri})`)
.setColor(message.client.embedColor)
.setTimestamp();
return message.reply({ embeds: [thing] }).then((msg) => {
setTimeout(() => {
msg.delete();
}, 3000);
});
},
};
Loading