diff --git a/.gitignore b/.gitignore index c6e423898..ffe623718 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1,21 @@ -# Packages -node_modules/ -yarn.lock - -# Log files -logs/ -*.log - -# Authentication -test/auth.json -test/auth.js -docs/deploy/deploy_key -docs/deploy/deploy_key.pub -deploy/deploy_key -deploy/deploy_key.pub - -# Miscellaneous -.tmp/ -.vscode/ -docs/docs.json -webpack/ +# Packages +node_modules/ +yarn.lock + +# Log files +logs/ +*.log + +# Authentication +test/auth.json +test/auth.js +docs/deploy/deploy_key +docs/deploy/deploy_key.pub +deploy/deploy_key +deploy/deploy_key.pub + +# Miscellaneous +.tmp/ +.vscode/ +docs/docs.json +webpack/ diff --git a/docs/README.md b/docs/README.md index d41af8eaf..b5ac7978f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1 +1 @@ -## [View the documentation here.](https://discord.js.org/#/docs) +## [View the documentation here.](https://discord.js.org/#/docs) diff --git a/test/voice.js b/test/voice.js index 396bcc490..65f4329e7 100644 --- a/test/voice.js +++ b/test/voice.js @@ -1,78 +1,78 @@ -/* eslint no-console: 0 */ -'use strict'; - -const Discord = require('../'); -const ytdl = require('ytdl-core'); - -const client = new Discord.Client({ fetchAllMembers: false, apiRequestMethod: 'sequential' }); - -const auth = require('./auth.json'); - -client.login(auth.token).then(() => console.log('logged')).catch(console.error); - -const connections = new Map(); - -let broadcast; - -client.on('message', m => { - if (!m.guild) return; - if (m.content.startsWith('/join')) { - const channel = m.guild.channels.get(m.content.split(' ')[1]) || m.member.voiceChannel; - if (channel && channel.type === 'voice') { - channel.join().then(conn => { - conn.player.on('error', (...e) => console.log('player', ...e)); - if (!connections.has(m.guild.id)) connections.set(m.guild.id, { conn, queue: [] }); - m.reply('ok!'); - }); - } else { - m.reply('Specify a voice channel!'); - } - } else if (m.content.startsWith('/play')) { - if (connections.has(m.guild.id)) { - const connData = connections.get(m.guild.id); - const queue = connData.queue; - const url = m.content.split(' ').slice(1).join(' ') - .replace(//g, ''); - queue.push({ url, m }); - if (queue.length > 1) { - m.reply(`OK, that's going to play after ${queue.length - 1} songs`); - return; - } - doQueue(connData); - } - } else if (m.content.startsWith('/skip')) { - if (connections.has(m.guild.id)) { - const connData = connections.get(m.guild.id); - if (connData.dispatcher) { - connData.dispatcher.end(); - } - } - } else if (m.content.startsWith('#eval') && m.author.id === '66564597481480192') { - try { - const com = eval(m.content.split(' ').slice(1).join(' ')); - m.channel.sendMessage(`\`\`\`\n${com}\`\`\``); - } catch (e) { - console.log(e); - m.channel.sendMessage(`\`\`\`\n${e}\`\`\``); - } - } -}); - -function doQueue(connData) { - const conn = connData.conn; - const queue = connData.queue; - const item = queue[0]; - if (!item) return; - const stream = ytdl(item.url, { filter: 'audioonly' }, { passes: 3 }); - const dispatcher = conn.playStream(stream); - stream.on('info', info => { - item.m.reply(`OK, playing **${info.title}**`); - }); - dispatcher.on('end', () => { - queue.shift(); - doQueue(connData); - }); - dispatcher.on('error', (...e) => console.log('dispatcher', ...e)); - connData.dispatcher = dispatcher; -} +/* eslint no-console: 0 */ +'use strict'; + +const Discord = require('../'); +const ytdl = require('ytdl-core'); + +const client = new Discord.Client({ fetchAllMembers: false, apiRequestMethod: 'sequential' }); + +const auth = require('./auth.json'); + +client.login(auth.token).then(() => console.log('logged')).catch(console.error); + +const connections = new Map(); + +let broadcast; + +client.on('message', m => { + if (!m.guild) return; + if (m.content.startsWith('/join')) { + const channel = m.guild.channels.get(m.content.split(' ')[1]) || m.member.voiceChannel; + if (channel && channel.type === 'voice') { + channel.join().then(conn => { + conn.player.on('error', (...e) => console.log('player', ...e)); + if (!connections.has(m.guild.id)) connections.set(m.guild.id, { conn, queue: [] }); + m.reply('ok!'); + }); + } else { + m.reply('Specify a voice channel!'); + } + } else if (m.content.startsWith('/play')) { + if (connections.has(m.guild.id)) { + const connData = connections.get(m.guild.id); + const queue = connData.queue; + const url = m.content.split(' ').slice(1).join(' ') + .replace(//g, ''); + queue.push({ url, m }); + if (queue.length > 1) { + m.reply(`OK, that's going to play after ${queue.length - 1} songs`); + return; + } + doQueue(connData); + } + } else if (m.content.startsWith('/skip')) { + if (connections.has(m.guild.id)) { + const connData = connections.get(m.guild.id); + if (connData.dispatcher) { + connData.dispatcher.end(); + } + } + } else if (m.content.startsWith('#eval') && m.author.id === '66564597481480192') { + try { + const com = eval(m.content.split(' ').slice(1).join(' ')); + m.channel.sendMessage(`\`\`\`\n${com}\`\`\``); + } catch (e) { + console.log(e); + m.channel.sendMessage(`\`\`\`\n${e}\`\`\``); + } + } +}); + +function doQueue(connData) { + const conn = connData.conn; + const queue = connData.queue; + const item = queue[0]; + if (!item) return; + const stream = ytdl(item.url, { filter: 'audioonly' }, { passes: 3 }); + const dispatcher = conn.playStream(stream); + stream.on('info', info => { + item.m.reply(`OK, playing **${info.title}**`); + }); + dispatcher.on('end', () => { + queue.shift(); + doQueue(connData); + }); + dispatcher.on('error', (...e) => console.log('dispatcher', ...e)); + connData.dispatcher = dispatcher; +}