CRLF to LF

This commit is contained in:
Crawl
2017-06-06 08:45:51 +02:00
parent 1ed6bbc4b4
commit 3f7049e1a0
3 changed files with 100 additions and 100 deletions

42
.gitignore vendored
View File

@@ -1,21 +1,21 @@
# Packages # Packages
node_modules/ node_modules/
yarn.lock yarn.lock
# Log files # Log files
logs/ logs/
*.log *.log
# Authentication # Authentication
test/auth.json test/auth.json
test/auth.js test/auth.js
docs/deploy/deploy_key docs/deploy/deploy_key
docs/deploy/deploy_key.pub docs/deploy/deploy_key.pub
deploy/deploy_key deploy/deploy_key
deploy/deploy_key.pub deploy/deploy_key.pub
# Miscellaneous # Miscellaneous
.tmp/ .tmp/
.vscode/ .vscode/
docs/docs.json docs/docs.json
webpack/ webpack/

View File

@@ -1 +1 @@
## [View the documentation here.](https://discord.js.org/#/docs) ## [View the documentation here.](https://discord.js.org/#/docs)

View File

@@ -1,78 +1,78 @@
/* eslint no-console: 0 */ /* eslint no-console: 0 */
'use strict'; 'use strict';
const Discord = require('../'); const Discord = require('../');
const ytdl = require('ytdl-core'); const ytdl = require('ytdl-core');
const client = new Discord.Client({ fetchAllMembers: false, apiRequestMethod: 'sequential' }); const client = new Discord.Client({ fetchAllMembers: false, apiRequestMethod: 'sequential' });
const auth = require('./auth.json'); const auth = require('./auth.json');
client.login(auth.token).then(() => console.log('logged')).catch(console.error); client.login(auth.token).then(() => console.log('logged')).catch(console.error);
const connections = new Map(); const connections = new Map();
let broadcast; let broadcast;
client.on('message', m => { client.on('message', m => {
if (!m.guild) return; if (!m.guild) return;
if (m.content.startsWith('/join')) { if (m.content.startsWith('/join')) {
const channel = m.guild.channels.get(m.content.split(' ')[1]) || m.member.voiceChannel; const channel = m.guild.channels.get(m.content.split(' ')[1]) || m.member.voiceChannel;
if (channel && channel.type === 'voice') { if (channel && channel.type === 'voice') {
channel.join().then(conn => { channel.join().then(conn => {
conn.player.on('error', (...e) => console.log('player', ...e)); conn.player.on('error', (...e) => console.log('player', ...e));
if (!connections.has(m.guild.id)) connections.set(m.guild.id, { conn, queue: [] }); if (!connections.has(m.guild.id)) connections.set(m.guild.id, { conn, queue: [] });
m.reply('ok!'); m.reply('ok!');
}); });
} else { } else {
m.reply('Specify a voice channel!'); m.reply('Specify a voice channel!');
} }
} else if (m.content.startsWith('/play')) { } else if (m.content.startsWith('/play')) {
if (connections.has(m.guild.id)) { if (connections.has(m.guild.id)) {
const connData = connections.get(m.guild.id); const connData = connections.get(m.guild.id);
const queue = connData.queue; const queue = connData.queue;
const url = m.content.split(' ').slice(1).join(' ') const url = m.content.split(' ').slice(1).join(' ')
.replace(/</g, '') .replace(/</g, '')
.replace(/>/g, ''); .replace(/>/g, '');
queue.push({ url, m }); queue.push({ url, m });
if (queue.length > 1) { if (queue.length > 1) {
m.reply(`OK, that's going to play after ${queue.length - 1} songs`); m.reply(`OK, that's going to play after ${queue.length - 1} songs`);
return; return;
} }
doQueue(connData); doQueue(connData);
} }
} else if (m.content.startsWith('/skip')) { } else if (m.content.startsWith('/skip')) {
if (connections.has(m.guild.id)) { if (connections.has(m.guild.id)) {
const connData = connections.get(m.guild.id); const connData = connections.get(m.guild.id);
if (connData.dispatcher) { if (connData.dispatcher) {
connData.dispatcher.end(); connData.dispatcher.end();
} }
} }
} else if (m.content.startsWith('#eval') && m.author.id === '66564597481480192') { } else if (m.content.startsWith('#eval') && m.author.id === '66564597481480192') {
try { try {
const com = eval(m.content.split(' ').slice(1).join(' ')); const com = eval(m.content.split(' ').slice(1).join(' '));
m.channel.sendMessage(`\`\`\`\n${com}\`\`\``); m.channel.sendMessage(`\`\`\`\n${com}\`\`\``);
} catch (e) { } catch (e) {
console.log(e); console.log(e);
m.channel.sendMessage(`\`\`\`\n${e}\`\`\``); m.channel.sendMessage(`\`\`\`\n${e}\`\`\``);
} }
} }
}); });
function doQueue(connData) { function doQueue(connData) {
const conn = connData.conn; const conn = connData.conn;
const queue = connData.queue; const queue = connData.queue;
const item = queue[0]; const item = queue[0];
if (!item) return; if (!item) return;
const stream = ytdl(item.url, { filter: 'audioonly' }, { passes: 3 }); const stream = ytdl(item.url, { filter: 'audioonly' }, { passes: 3 });
const dispatcher = conn.playStream(stream); const dispatcher = conn.playStream(stream);
stream.on('info', info => { stream.on('info', info => {
item.m.reply(`OK, playing **${info.title}**`); item.m.reply(`OK, playing **${info.title}**`);
}); });
dispatcher.on('end', () => { dispatcher.on('end', () => {
queue.shift(); queue.shift();
doQueue(connData); doQueue(connData);
}); });
dispatcher.on('error', (...e) => console.log('dispatcher', ...e)); dispatcher.on('error', (...e) => console.log('dispatcher', ...e));
connData.dispatcher = dispatcher; connData.dispatcher = dispatcher;
} }