|
|
|
@ -5,14 +5,16 @@ const Discord = require("discord.js"),
|
|
|
|
|
cmd = require("./lib/cmd"),
|
|
|
|
|
client = new Discord.Client(),
|
|
|
|
|
args = require('args-parser')(process.argv),
|
|
|
|
|
authToken = args.token;
|
|
|
|
|
authToken = args.token,
|
|
|
|
|
prefix = args.prefix || '~',
|
|
|
|
|
gamepresence = args.game || 'NieR:Automata';
|
|
|
|
|
|
|
|
|
|
let savedplaylists = {};
|
|
|
|
|
|
|
|
|
|
function main() {
|
|
|
|
|
music.setLogger(logger);
|
|
|
|
|
cmd.setLogger(logger);
|
|
|
|
|
cmd.init();
|
|
|
|
|
cmd.init(prefix);
|
|
|
|
|
if (fs.existsSync('./data/savedplaylists.json')) {
|
|
|
|
|
savedplaylists = JSON.parse(fs.readFileSync('./data/savedplaylists.json'))
|
|
|
|
|
}
|
|
|
|
@ -30,7 +32,7 @@ function savePlaylist(url, name) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function registerCommands() {
|
|
|
|
|
cmd.createCommand('~', 'play', (msg, argv) => {
|
|
|
|
|
cmd.createCommand(prefix, 'play', (msg, argv) => {
|
|
|
|
|
let vc = msg.member.voiceChannel;
|
|
|
|
|
let url = argv['url'];
|
|
|
|
|
if (!url) return 'No url given.';
|
|
|
|
@ -47,7 +49,7 @@ function registerCommands() {
|
|
|
|
|
}
|
|
|
|
|
}, ['url'], "Adds the url to the YouTube video/playlist into the queue.");
|
|
|
|
|
|
|
|
|
|
cmd.createCommand('~', 'playnext', (msg, argv) => {
|
|
|
|
|
cmd.createCommand(prefix, 'playnext', (msg, argv) => {
|
|
|
|
|
let vc = msg.member.voiceChannel;
|
|
|
|
|
let url = argv['url'];
|
|
|
|
|
if (!url) return 'No url given.';
|
|
|
|
@ -64,11 +66,11 @@ function registerCommands() {
|
|
|
|
|
}
|
|
|
|
|
}, ['url'], "Plays the YouTube video after the currently playing song.");
|
|
|
|
|
|
|
|
|
|
cmd.createCommand('~', 'ping', () => {
|
|
|
|
|
cmd.createCommand(prefix, 'ping', () => {
|
|
|
|
|
return 'Pong!';
|
|
|
|
|
}, [], "Try it yourself.");
|
|
|
|
|
|
|
|
|
|
cmd.createCommand('~', 'join', (msg) => {
|
|
|
|
|
cmd.createCommand(prefix, 'join', (msg) => {
|
|
|
|
|
if (msg.member.voiceChannel) {
|
|
|
|
|
music.connect(msg.member.voiceChannel);
|
|
|
|
|
}
|
|
|
|
@ -77,33 +79,33 @@ function registerCommands() {
|
|
|
|
|
}
|
|
|
|
|
}, [], "Joins the VC you are in.");
|
|
|
|
|
|
|
|
|
|
cmd.createCommand('~', 'stop', (msg) => {
|
|
|
|
|
cmd.createCommand(prefix, 'stop', (msg) => {
|
|
|
|
|
let gid = msg.guild.id;
|
|
|
|
|
music.stop(gid);
|
|
|
|
|
}, [], "Stops playling music and leavs.");
|
|
|
|
|
|
|
|
|
|
cmd.createCommand('~', 'pause', (msg) => {
|
|
|
|
|
cmd.createCommand(prefix, 'pause', (msg) => {
|
|
|
|
|
let gid = msg.guild.id;
|
|
|
|
|
music.pause(gid);
|
|
|
|
|
}, [], "Pauses playing.");
|
|
|
|
|
|
|
|
|
|
cmd.createCommand('~', 'resume', (msg) => {
|
|
|
|
|
cmd.createCommand(prefix, 'resume', (msg) => {
|
|
|
|
|
let gid = msg.guild.id;
|
|
|
|
|
music.resume(gid);
|
|
|
|
|
}, [], "Resumes playing.");
|
|
|
|
|
|
|
|
|
|
cmd.createCommand('~', 'skip', (msg) => {
|
|
|
|
|
cmd.createCommand(prefix, 'skip', (msg) => {
|
|
|
|
|
let gid = msg.guild.id;
|
|
|
|
|
music.skip(gid);
|
|
|
|
|
}, [], "Skips the current song.");
|
|
|
|
|
|
|
|
|
|
cmd.createCommand('~', 'clear', (msg) => {
|
|
|
|
|
cmd.createCommand(prefix, 'clear', (msg) => {
|
|
|
|
|
let gid = msg.guild.id;
|
|
|
|
|
music.clearQueue(gid);
|
|
|
|
|
return "All songs have been deleted, commander :no_mouth: "
|
|
|
|
|
}, [],"Clears the playlist.");
|
|
|
|
|
|
|
|
|
|
cmd.createCommand('~', 'playlist', (msg) => {
|
|
|
|
|
cmd.createCommand(prefix, 'playlist', (msg) => {
|
|
|
|
|
let gid = msg.guild.id;
|
|
|
|
|
let songs = music.getQueue(gid);
|
|
|
|
|
logger.debug(`found ${songs.length} songs`);
|
|
|
|
@ -115,33 +117,33 @@ function registerCommands() {
|
|
|
|
|
return songlist;
|
|
|
|
|
}, [], "Shows the next ten songs.");
|
|
|
|
|
|
|
|
|
|
cmd.createCommand('~', 'shuffle', (msg) => {
|
|
|
|
|
cmd.createCommand(prefix, 'shuffle', (msg) => {
|
|
|
|
|
let gid = msg.guild.id;
|
|
|
|
|
music.shuffle(gid);
|
|
|
|
|
return "The queue has successfully been shuffled :slight_smile:"
|
|
|
|
|
}, [], "Shuffles the playlist.");
|
|
|
|
|
|
|
|
|
|
cmd.createCommand('~', 'current', (msg) => {
|
|
|
|
|
cmd.createCommand(prefix, 'current', (msg) => {
|
|
|
|
|
let gid = msg.guild.id;
|
|
|
|
|
let song = music.nowPlaying(gid);
|
|
|
|
|
return `Playing: ${song.title}\n ${song.url}`;
|
|
|
|
|
}, [], "Shows the currently playing song.");
|
|
|
|
|
|
|
|
|
|
cmd.createCommand('~', 'repeatafterme', (msg, argv) => {
|
|
|
|
|
cmd.createCommand(prefix, 'repeatafterme', (msg, argv) => {
|
|
|
|
|
return argv['word'];
|
|
|
|
|
}, ['word'], "Repeats a single word you say.");
|
|
|
|
|
|
|
|
|
|
cmd.createCommand('~', 'save', (msg, argv) => {
|
|
|
|
|
cmd.createCommand(prefix, 'save', (msg, argv) => {
|
|
|
|
|
savePlaylist(argv['url'], argv['name']);
|
|
|
|
|
return `Saved song/playlist as ${argv['name']}`
|
|
|
|
|
}, ['url', 'name'], "Saves the YouTube song/playlist with a specific name. ~play [name] to play the playlist");
|
|
|
|
|
}, ['url', 'name'], "Saves the YouTube song/playlist with a specific name");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// defining the client's handlers
|
|
|
|
|
|
|
|
|
|
client.on('ready', () => {
|
|
|
|
|
logger.info(`logged in as ${client.user.tag}!`);
|
|
|
|
|
client.user.setPresence({game: {name: "Trivernis' bot testing", type: "PLAYING"}, status: 'online'});
|
|
|
|
|
client.user.setPresence({game: {name: gamepresence, type: "PLAYING"}, status: 'online'});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
client.on('message', msg => {
|
|
|
|
|