Skip to content

Commit

Permalink
Development (#183) (#184)
Browse files Browse the repository at this point in the history
* Update index.js (#178)

* Handle error LavaLink not connect (#180)

* Delete .replit

* Handle error node not connect ..

* Handle error lavalink not connect

* Create .replit

* Master branch to development (#171)

* Latest commits to fix stuff (#169)

* 24/7 Stay in vc stuff

* edits and fixes (#168)

Co-authored-by: Joseph <[email protected]>

* ;-; (#170)

* 24/7 Stay in vc stuff

* edits and fixes (#168)

* add: YouTube Tutorial at readme

Co-authored-by: Joseph <[email protected]>

Co-authored-by: Joseph <[email protected]>

* edits and some fixes, but not all

* split loop and loopqueue to make it simpler

* Fixed single Spotify track "no matches" error

* Small edits

Co-authored-by: A cute Blob <[email protected]>
Co-authored-by: ColonelOU <[email protected]>
Co-authored-by: Sudhan <[email protected]>

Co-authored-by: Joseph <[email protected]>
Co-authored-by: A cute Blob <[email protected]>
Co-authored-by: ColonelOU <[email protected]>
  • Loading branch information
4 people authored May 6, 2021
1 parent e0710ad commit 2623e3d
Show file tree
Hide file tree
Showing 16 changed files with 219 additions and 173 deletions.
2 changes: 1 addition & 1 deletion commands/clear.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { MessageEmbed } = require("discord.js");

module.exports = {
name: "clear",
description: "To clear the queue in this server",
description: "Clears the server queue",
usage: "",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
Expand Down
2 changes: 1 addition & 1 deletion commands/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { MessageEmbed, MessageReaction } = require("discord.js");

module.exports = {
name: "config",
description: "To setup server settings",
description: "Edit the bot settings",
usage: "",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
Expand Down
80 changes: 80 additions & 0 deletions commands/grab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
const { MessageEmbed } = require("discord.js");
const prettyMilliseconds = require("pretty-ms");

module.exports = {
name: "grab",
description: "Saves the current playing song to your Direct Messages",
usage: "",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
aliases: ["save"],
/**
*
* @param {import("../structures/DiscordMusicBot")} client
* @param {import("discord.js").Message} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, message, args, { GuildDB }) => {
let player = await client.Manager.get(message.guild.id);
if (!player) return client.sendTime(message.channel, "❌ | **Nothing is playing right now...**");
message.author.send(new MessageEmbed()
.setAuthor(`Saved Song:`, client.user.displayAvatarURL({
dynamic: true
}))
.setThumbnail(`https://img.youtube.com/vi/${player.queue.current.identifier}/mqdefault.jpg`)
.setURL(player.queue.current.uri)
.setColor("RANDOM")
.setTitle(`**${player.queue.current.title}**`)
.addField(`⌛ Duration: `, `\`${prettyMilliseconds(player.queue.current.duration, {colonNotation: true})}\``, true)
.addField(`🎵 Author: `, `\`${player.queue.current.author}\``, true)
.addField(`▶ Play it:`, `\`${GuildDB ? GuildDB.prefix : client.config.DefaultPrefix
}play ${player.queue.current.uri}\``)
.addField(`🔎 Saved in:`, `<#${message.channel.id}>`)
.setFooter(`Requested by: ${player.queue.current.requester.tag} | Guild: ${message.guild.name}`, player.queue.current.requester.displayAvatarURL({
dynamic: true
}))
).catch(e=>{
return message.channel.send("**:x: Your Dm's are disabled**")
})

message.react("✅").catch(e=>console.log("Could not react"))
},
SlashCommand: {
/**
*
* @param {import("../structures/DiscordMusicBot")} client
* @param {import("discord.js").Message} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, interaction, args, { GuildDB }) => {
let player = await client.Manager.get(interaction.guild_id);
if (!player) return client.sendTime(interaction, "❌ | **Nothing is playing right now...**");
try{
let embed = new MessageEmbed()
.setAuthor(`Saved from `, interaction.guild.name, client.user.displayAvatarURL())
.setThumbnail(`https://img.youtube.com/vi/${player.queue.current.identifier}/mqdefault.jpg`)
.setURL(player.queue.current.uri)
.setColor("RANDOM")
.setTimestamp()
.setTitle(`**${player.queue.current.title}**`)
.addField(`⌛ Duration: `, `\`${prettyMilliseconds(player.queue.current.duration, {colonNotation: true})}\``, true)
.addField(`🎵 Author: `, `\`${player.queue.current.author}\``, true)
.addField(`▶ Play it:`, `\`${GuildDB ? GuildDB.prefix : client.config.DefaultPrefix
}play ${player.queue.current.uri}\``)
.addField(`🔎 Saved in:`, `<#${interaction.channel_id}>`)
.setFooter(`Requested by: ${player.queue.current.requester.tag} | Guild: ${interaction.guild.name}`, player.queue.current.requester.displayAvatarURL({
dynamic: true
}))
interaction.send(embed);
}catch(e) {
return client.sendTime(interaction, "**:x: Your DM's are disabled**")
}

interaction.react("✅").catch(e => console.log("Could not react"))
},
},
};
2 changes: 1 addition & 1 deletion commands/leave.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { MessageEmbed } = require("discord.js");

module.exports = {
name: "leave",
description: "To leave the voice channel",
description: "Disconnecting the bot from the voice channel",
usage: "",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
Expand Down
189 changes: 54 additions & 135 deletions commands/loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,141 +2,60 @@ const { MessageEmbed } = require("discord.js");
const { TrackUtils } = require("erela.js");

module.exports = {
name: "loop",
description: "To loop the current song/queue",
usage: "",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
aliases: ["l", "repeat"],
/**
*
* @param {import("../structures/DiscordMusicBot")} client
* @param {import("discord.js").Message} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, message, args, { GuildDB }) => {
let player = await client.Manager.get(message.guild.id);
if (!player) return client.sendTime(message.channel, "❌ | **Nothing is playing right now...**");
let Config = new MessageEmbed()
.setAuthor("Server Config", client.config.IconURL)
.setColor("GREEN")
.addField("Song loop", player.trackRepeat?"✅":"❌", true)
.addField("Queue loop", player.queueRepeat?"✅":"❌", true)
.setFooter("React to your choice below.")
.setDescription(`
What do you want to loop?
name: "loop",
description: "Loop the current song",
usage: "",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
aliases: ["l", "repeat"],
/**
*
* @param {import("../structures/DiscordMusicBot")} client
* @param {import("discord.js").Message} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, message, args, { GuildDB }) => {
let player = await client.Manager.get(message.guild.id);
if (!player) return client.sendTime(message.channel, "❌ | **Nothing is playing right now...**");
if (!message.member.voice.channel) return client.sendTime(message.channel, "❌ | **You must be in a voice channel to play something!**");
//else if(message.guild.me.voice && message.guild.me.voice.channel.id !== message.member.voice.channel.id)return client.sendTime(message.channel, `❌ | **You must be in ${guild.me.voice.channel} to use this command.**`);

:one: - **Song Loop** (This will loop the current song)
:two: - **Queue Loop** (This will loop the whole queue)
`);

let LoopingMessage = await message.channel.send(Config);
await LoopingMessage.react("1️⃣");
await LoopingMessage.react("2️⃣");
let emoji = await LoopingMessage.awaitReactions(
(reaction, user) =>
user.id === message.author.id &&
["1️⃣", "2️⃣"].includes(reaction.emoji.name),
{ max: 1, errors: ["time"], time: 30000 }
).catch(() => {
LoopingMessage.reactions.removeAll();
Config.setDescription(
"You took too long to respond. Run the command again !"
);
Config.setFooter("")
LoopingMessage.edit(Config);
});
emoji = emoji.first();
/**@type {MessageReaction} */
let em = emoji;
LoopingMessage.reactions.removeAll();
let config = new MessageEmbed()

if (em._emoji.name === "1️⃣") {
if(player.trackRepeat){
player.setTrackRepeat(false)
config.setAuthor("Server Config", client.config.IconURL)
config.setColor("GREEN")
config.setDescription("**Loop** \`disabled\`")
config.addField("Song loop", player.trackRepeat?"✅":"❌", true)
config.addField("Queue loop", player.queueRepeat?"✅":"❌", true)
config.setTimestamp();
LoopingMessage.edit(config);
}else if (em._emoji.name === "1️⃣") {
player.setTrackRepeat(true)
config.setAuthor("Server Config", client.config.IconURL)
config.setColor("GREEN")
config.setDescription("**Loop** \`enabled\`")
config.addField("Song loop", player.trackRepeat?"✅":"❌", true)
config.addField("Queue loop", player.queueRepeat?"✅":"❌", true)
config.setTimestamp();
LoopingMessage.edit(config);
if (player.trackRepeat) {
player.setTrackRepeat(false)
client.sendTime(message.channel, `Loop \`disabled\``);
} else {
player.setTrackRepeat(true)
client.sendTime(message.channel, `Loop \`enabled\``);
}
} if (em._emoji.name === "2️⃣") {
if(player.queueRepeat){
player.setQueueRepeat(false)
config.setAuthor("Server Config", client.config.IconURL)
config.setColor("GREEN")
config.setDescription("**Queue loop** \`disabled\`")
config.addField("Song loop", player.trackRepeat?"✅":"❌", true)
config.addField("Queue loop", player.queueRepeat?"✅":"❌", true)
config.setTimestamp();
LoopingMessage.edit(config);
}else if (em._emoji.name === "2️⃣"){
player.setQueueRepeat(true)
config.setAuthor("Server Config", client.config.IconURL)
config.setColor("GREEN")
config.setDescription("**Queue loop** \`enabled\`")
config.addField("Song loop", player.trackRepeat?"✅":"❌", true)
config.addField("Queue loop", player.queueRepeat?"✅":"❌", true)
config.setTimestamp();
LoopingMessage.edit(config);
}
}
},
},
SlashCommand: {
/**
*
* @param {import("../structures/DiscordMusicBot")} client
* @param {import("discord.js").Message} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, interaction, args, { GuildDB }) => {
const guild = client.guilds.cache.get(interaction.guild_id);
const member = guild.members.cache.get(interaction.member.user.id);
const voiceChannel = member.voice.channel;
let player = await client.Manager.get(interaction.guild_id);
if (!player) return client.sendTime(interaction, "❌ | **Nothing is playing right now...**");
if (!member.voice.channel) return interaction.send("❌ | You must be on a voice channel.");
if (guild.me.voice.channel && !guild.me.voice.channel.equals(member.voice.channel)) return interaction.send(`❌ | You must be on ${guild.me.voice.channel} to use this command.`);

SlashCommand: {
options: [
{
name: "Song",
value: "song",
type: 1,
description: "Loops the song"
},
{
name: "Queue",
value: "queue",
type: 2,
description: "Loops the queue"
}
],

run: async (client, interaction, args, { GuildDB }) => {
let player = await client.Manager.get(interaction.guild_id);
if (!player) return interaction.send("Nothing is playing right now...");
let loop = (args.value);
if (loop === "song") {
if(player.trackRepeat){
player.setTrackRepeat(false)
interaction.send("Loop disabled")
}else{
player.setTrackRepeat(true)
interaction.send("Loop enabled")
}
} else {
if (loop === "queue") {
if(player.queueRepeat){
player.setQueueRepeat(false)
interaction.send("Queue loop disabled")
}else{
player.setTrackRepeat(true)
interaction.send("Queue loop enabled")
}
}}
console.log(interaction.data)
}
}
};
if(player.trackRepeat){
player.setTrackRepeat(false)
client.sendTime(interaction, `Loop \`disabled\``);
}else{
player.setTrackRepeat(true)
client.sendTime(interaction, `Loop \`enabled\``);
}
console.log(interaction.data)
}
}
};
62 changes: 62 additions & 0 deletions commands/loopqueue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
const { MessageEmbed } = require("discord.js");
const { TrackUtils } = require("erela.js");

module.exports = {
name: "loopqueue",
description: "Loop the whole queue",
usage: "",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
aliases: ["lq", "repeatqueue", "rq"],
/**
*
* @param {import("../structures/DiscordMusicBot")} client
* @param {import("discord.js").Message} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, message, args, { GuildDB }) => {
let player = await client.Manager.get(message.guild.id);
if (!player) return client.sendTime(message.channel, "❌ | **Nothing is playing right now...**");
if (!message.member.voice.channel) return client.sendTime(message.channel, "❌ | **You must be in a voice channel to play something!**");
//else if(message.guild.me.voice && message.guild.me.voice.channel.id !== message.member.voice.channel.id)return client.sendTime(message.channel, `❌ | **You must be in ${guild.me.voice.channel} to use this command.**`);

if (player.QueueRepeat) {
player.setQueueRepeat(false)
client.sendTime(message.channel, `Queue loop \`disabled\``);
} else {
player.setQueueRepeat(true)
client.sendTime(message.channel, `Queue loop \`enabled\``);
}
},
SlashCommand: {
/**
*
* @param {import("../structures/DiscordMusicBot")} client
* @param {import("discord.js").Message} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, interaction, args, { GuildDB }) => {
let player = await client.Manager.get(interaction.guild_id);
const guild = client.guilds.cache.get(interaction.guild_id);
const member = guild.members.cache.get(interaction.member.user.id);
const voiceChannel = member.voice.channel;
let awaitchannel = client.channels.cache.get(interaction.channel_id); /// thanks Reyansh for this idea ;-;
if (!player) return client.sendTime(interaction, "❌ | **Nothing is playing right now...**");
if (!member.voice.channel) return client.sendTime(interaction, "❌ | **You must be in a voice channel to use this command.**");
if (guild.me.voice.channel && !guild.me.voice.channel.equals(voiceChannel)) return client.sendTime(interaction, `❌ | **You must be in ${guild.me.voice.channel} to use this command.**`);

if(player.queueRepeat){
player.setQueueRepeat(false)
client.sendTime(interaction, `Queue loop \`disabled\``);
}else{
player.setQueueRepeat(true)
client.sendTime(interaction, `Queue loop \`enabled\``);
}
console.log(interaction.data)
}
}
};
4 changes: 2 additions & 2 deletions commands/lyrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const _ = require("lodash");

module.exports = {
name: "lyrics",
description: "To get and search lyrics of a song",
description: "Search lyrics for any song",
usage: "[Song Name]",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
Expand Down Expand Up @@ -98,4 +98,4 @@ module.exports = {
return interaction.send(Pages[0]);
}
}
}
}
Loading

0 comments on commit 2623e3d

Please sign in to comment.