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