@@ -1,21 +1,18 @@
|
||||
const Discord = require("discord.js")
|
||||
const fs = require("fs")
|
||||
const emotes = require ("../config/emojis.json")
|
||||
const emotes = require ("../config/emojis.json");
|
||||
|
||||
module.exports.run = async (client, message, args) => {
|
||||
module.exports.run = async (client, message) => {
|
||||
|
||||
if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`)
|
||||
if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`);
|
||||
|
||||
if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`**No music playing on this server ${emotes.error}**`)
|
||||
if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`**No music playing on this server ${emotes.error}**`);
|
||||
|
||||
client.player.clearQueue(message.guild.id);
|
||||
|
||||
message.channel.send(`**Queue cleared ${emotes.success}**`);
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.config = {
|
||||
name: "clear-queue",
|
||||
aliases: []
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
const Discord = require("discord.js")
|
||||
const fs = require("fs")
|
||||
const emotes = require ("../config/emojis.json")
|
||||
const emotes = require ("../config/emojis.json");
|
||||
|
||||
module.exports.run = async (client, message, args) => {
|
||||
module.exports.run = async (client, message) => {
|
||||
|
||||
if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`)
|
||||
if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`);
|
||||
|
||||
if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`**No music playing on this server ${emotes.error}**`)
|
||||
if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`**No music playing on this server ${emotes.error}**`);
|
||||
|
||||
let song = await client.player.nowPlaying(message.guild.id);
|
||||
const song = await client.player.nowPlaying(message.guild.id);
|
||||
|
||||
message.channel.send(`**Currently playing ${song.name} ${emotes.music}**`);
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.config = {
|
||||
name: "now-playing",
|
||||
aliases: []
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,18 +2,17 @@ const Discord = require("discord.js")
|
||||
const fs = require("fs")
|
||||
const emotes = require ("../config/emojis.json")
|
||||
|
||||
module.exports.run = async (client, message, args) => {
|
||||
module.exports.run = async (client, message) => {
|
||||
|
||||
if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`)
|
||||
if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`);
|
||||
|
||||
let song = await client.player.pause(message.guild.id);
|
||||
if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`**No music playing on this server ${emotes.error}**`);
|
||||
|
||||
if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`**No music playing on this server ${emotes.error}**`)
|
||||
const song = await client.player.pause(message.guild.id);
|
||||
|
||||
message.channel.send(`**Song ${song.name} paused ${emotes.success}**`);
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.config = {
|
||||
name: "pause",
|
||||
|
||||
@@ -1,28 +1,27 @@
|
||||
const Discord = require("discord.js")
|
||||
const fs = require("fs")
|
||||
const emotes = require ("../config/emojis.json")
|
||||
const emotes = require ("../config/emojis.json");
|
||||
|
||||
module.exports.run = async (client, message, args) => {
|
||||
|
||||
if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`)
|
||||
if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`);
|
||||
|
||||
if (!args[0]) return message.channel.send(`**Please enter a music ${emotes.error}**`)
|
||||
if (!args[0]) return message.channel.send(`**Please enter a music ${emotes.error}**`);
|
||||
|
||||
const aSongIsAlreadyPlaying = client.player.isPlaying(message.guild.id);
|
||||
|
||||
let aSongIsAlreadyPlaying = client.player.isPlaying(message.guild.id);
|
||||
// If there's already a song playing
|
||||
if(aSongIsAlreadyPlaying){
|
||||
// Add the song to the queue
|
||||
let song = await client.player.addToQueue(message.guild.id, args.join(" "));
|
||||
const song = await client.player.addToQueue(message.guild.id, args.join(" "));
|
||||
message.channel.send(`**Song ${song.name} added to queue ${emotes.music}**`);
|
||||
} else {
|
||||
// Else, play the song
|
||||
let song = await client.player.play(message.member.voice.channel, args.join(" "));
|
||||
const song = await client.player.play(message.member.voice.channel, args.join(" "));
|
||||
message.channel.send(`**Currently playing ${song.name} ${emotes.music}**`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
module.exports.config = {
|
||||
name: "play",
|
||||
aliases: []
|
||||
}
|
||||
};
|
||||
@@ -1,12 +1,10 @@
|
||||
const Discord = require("discord.js")
|
||||
const fs = require("fs")
|
||||
const emotes = require ("../config/emojis.json")
|
||||
const emotes = require ("../config/emojis.json");
|
||||
|
||||
module.exports.run = async (client, message, args) => {
|
||||
module.exports.run = async (client, message) => {
|
||||
|
||||
if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`)
|
||||
if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`);
|
||||
|
||||
let queue = client.player.getQueue(message.guild.id);
|
||||
const queue = client.player.getQueue(message.guild.id);
|
||||
|
||||
if(!queue) return message.channel.send(`**No songs currently playing ${emotes.error}**`);
|
||||
|
||||
@@ -14,10 +12,10 @@ module.exports.run = async (client, message, args) => {
|
||||
return `${i === 0 ? 'Current' : `#${i+1}`} - ${song.name} | ${song.author}`
|
||||
}).join('\n')));
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
module.exports.config = {
|
||||
name: "queue",
|
||||
aliases: []
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
const Discord = require("discord.js")
|
||||
const fs = require("fs")
|
||||
const emotes = require ("../config/emojis.json")
|
||||
const emotes = require ("../config/emojis.json");
|
||||
|
||||
module.exports.run = async (client, message, args) => {
|
||||
module.exports.run = async (client, message) => {
|
||||
|
||||
if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`)
|
||||
if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`);
|
||||
|
||||
let song = await client.player.resume(message.guild.id);
|
||||
const song = await client.player.resume(message.guild.id);
|
||||
|
||||
if(!song) return message.channel.send(`**No songs currently playing ${emotes.error}**`);
|
||||
|
||||
message.channel.send(`**Song ${song.name} resumed ${emotes.success}**`);
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.config = {
|
||||
name: "resume",
|
||||
aliases: []
|
||||
}
|
||||
};
|
||||
@@ -1,23 +1,21 @@
|
||||
const Discord = require("discord.js")
|
||||
const fs = require("fs")
|
||||
const emotes = require ("../config/emojis.json")
|
||||
const emotes = require ("../config/emojis.json");
|
||||
|
||||
module.exports.run = async (client, message, args) => {
|
||||
|
||||
if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`)
|
||||
if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`);
|
||||
|
||||
if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`**No music playing on this server ${emotes.error}**`)
|
||||
if (!args[0]) return message.channel.send(`**Please enter a number ${emotes.error}**`)
|
||||
if (isNaN(args[0])) return message.channel.send(`**Please enter a valid number ${emotes.error}**`)
|
||||
if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`**No music playing on this server ${emotes.error}**`);
|
||||
if(!args[0]) return message.channel.send(`**Please enter a number ${emotes.error}**`);
|
||||
if(isNaN(args[0])) return message.channel.send(`**Please enter a valid number ${emotes.error}**`);
|
||||
|
||||
client.player.setVolume(message.guild.id, parseInt(args.join(" ")));
|
||||
|
||||
message.channel.send("**Volume set to** `" + args.join(" ") + "`" + `** ** ${emotes.success}`);
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.config = {
|
||||
name: "set-volume",
|
||||
aliases: []
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
const Discord = require("discord.js")
|
||||
const fs = require("fs")
|
||||
const emotes = require ("../config/emojis.json")
|
||||
const emotes = require ("../config/emojis.json");
|
||||
|
||||
module.exports.run = async (client, message, args) => {
|
||||
module.exports.run = async (client, message) => {
|
||||
|
||||
if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`)
|
||||
if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`);
|
||||
|
||||
if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`**No music playing on this server ${emotes.error}**`)
|
||||
if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`**No music playing on this server ${emotes.error}**`);
|
||||
|
||||
let song = await client.player.skip(message.guild.id);
|
||||
const song = await client.player.skip(message.guild.id);
|
||||
|
||||
message.channel.send(`**Song ${song.name} skipped ${emotes.success}**`);
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.config = {
|
||||
name: "skip",
|
||||
aliases: []
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
const Discord = require("discord.js")
|
||||
const fs = require("fs")
|
||||
const emotes = require ("../config/emojis.json")
|
||||
const emotes = require ("../config/emojis.json");
|
||||
|
||||
module.exports.run = async (client, message, args) => {
|
||||
module.exports.run = async (client, message) => {
|
||||
|
||||
if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`)
|
||||
if(!message.member.voice.channel) return message.channel.send(`**You're not in a voice channel ${emotes.error}**`);
|
||||
|
||||
if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`**No music playing on this server ${emotes.error}**`)
|
||||
if(!client.player.isPlaying(message.guild.id)) return message.channel.send(`**No music playing on this server ${emotes.error}**`);
|
||||
|
||||
client.player.stop(message.guild.id);
|
||||
|
||||
message.channel.send(`**Music stopped ${emotes.success}**`);
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.config = {
|
||||
name: "stop",
|
||||
aliases: []
|
||||
}
|
||||
};
|
||||
|
||||
47
index.js
47
index.js
@@ -1,11 +1,9 @@
|
||||
const Discord = require("discord.js")
|
||||
const fs = require("fs")
|
||||
const client = new Discord.Client()
|
||||
const Discord = require("discord.js");
|
||||
const fs = require("fs");
|
||||
const client = new Discord.Client();
|
||||
|
||||
const settings = require ("./config/bot.json") // The bot connects using the configuration file
|
||||
|
||||
const emotes = require ("./config/emojis.json") //The bot finds emojis
|
||||
|
||||
const { Player } = require("discord-player"); // Create a new Player (Youtube API key is your Youtube Data v3 key)
|
||||
|
||||
const player = new Player(client, settings.youtube_api); // To easily access the player
|
||||
@@ -20,43 +18,42 @@ client.on("ready", () => {
|
||||
|
||||
client.login(settings.token_bot); //The bot connects thanks to the token
|
||||
|
||||
client.on('message', async message => {
|
||||
client.on('message', async (message) => {
|
||||
|
||||
let prefix = settings.prefix
|
||||
|
||||
let messageArray = message.content.split(" ")
|
||||
let cmd = messageArray[0].toLowerCase();
|
||||
let args = messageArray.slice(1);
|
||||
const prefix = settings.prefix;
|
||||
|
||||
const messageArray = message.content.split(" ");
|
||||
const cmd = messageArray[0].toLowerCase();
|
||||
const args = messageArray.slice(1);
|
||||
|
||||
if(!message.content.startsWith(prefix)) return;
|
||||
let commandfile = client.commands.get(cmd.slice(prefix.length)) || client.commands.get(client.aliases.get(cmd.slice(prefix.length)))
|
||||
const commandfile = client.commands.get(cmd.slice(prefix.length)) || client.commands.get(client.aliases.get(cmd.slice(prefix.length)))
|
||||
if(commandfile) commandfile.run(client,message,args)
|
||||
|
||||
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
client.commands = new Discord.Collection();
|
||||
client.aliases = new Discord.Collection();
|
||||
|
||||
fs.readdir("./commands/", (err, files) => {
|
||||
|
||||
let jsfile = files.filter(f => f.split(".").pop() === "js")
|
||||
const jsfiles = files.filter(f => f.split(".").pop() === "js")
|
||||
|
||||
if(jsfile.length <= 0) {
|
||||
return console.log("Couldn't Find Commands !");
|
||||
if(jsfiles.length <= 0) {
|
||||
return console.log("Couldn't find any commands!");
|
||||
}
|
||||
|
||||
jsfile.forEach((f, i) => {
|
||||
jsfiles.forEach((file) => {
|
||||
|
||||
console.log(`Run command ${f}`);
|
||||
console.log(`Loading command ${file}`);
|
||||
|
||||
let pull = require(`./commands/${f}`);
|
||||
const command = require(`./commands/${file}`);
|
||||
|
||||
client.commands.set(pull.config.name, pull);
|
||||
pull.config.aliases.forEach(alias => {
|
||||
client.aliases.set(alias, pull.config.name)
|
||||
client.commands.set(command.config.name, command);
|
||||
command.config.aliases.forEach(alias => {
|
||||
client.aliases.set(alias, command.config.name);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
})});
|
||||
|
||||
Reference in New Issue
Block a user