Compare commits
2 Commits
e9c2b7ef4a
...
b726fa7fb9
Author | SHA1 | Date |
---|---|---|
Jill | b726fa7fb9 | |
Jill | 6e9f0a0b3a |
13
src/index.js
13
src/index.js
|
@ -116,6 +116,13 @@ async function play(song, id, connection, channel) {
|
|||
const stream = got(url, {isStream: true});
|
||||
const resource = Voice.createAudioResource(stream, { inputType: Voice.StreamType.Arbitrary });
|
||||
|
||||
stream.on('error', err => {
|
||||
console.log(err);
|
||||
channel.send(`failed to play track: \`\`\`${err}\`\`\``);
|
||||
advanceQueue(id, channel, subscription, connection);
|
||||
return;
|
||||
});
|
||||
|
||||
if (players[id]) {
|
||||
console.log('reusing player');
|
||||
player = players[id];
|
||||
|
@ -177,7 +184,7 @@ async function queueUp(url, id) {
|
|||
}
|
||||
|
||||
if (err) {
|
||||
return [null, `failed to retrieve youtube-dl info!: \`\`\`${err}\`\`\``];
|
||||
return [null, `failed to retrieve youtube-dl info!: \`\`\`${err.toString().slice(0, 1000)}\`\`\``];
|
||||
} else {
|
||||
if (info.length) {
|
||||
info.forEach(i => {
|
||||
|
@ -199,7 +206,7 @@ bot.on('messageCreate', async (msg) => {
|
|||
const params = content.replace(prefix, '').split(' ');
|
||||
const cmd = params[0];
|
||||
|
||||
if (!msg.guild || !content.startsWith(prefix)) return;
|
||||
if (!msg.guild || !content.startsWith(prefix) || !msg.channel) return;
|
||||
|
||||
if ((cmd === 'play' || cmd === 'p') && params[1]) {
|
||||
const connection = await checkVoiceChannel(msg);
|
||||
|
@ -253,7 +260,7 @@ bot.on('messageCreate', async (msg) => {
|
|||
if (q.length === 0) {
|
||||
msg.channel.send('no songs queued!');
|
||||
} else {
|
||||
msg.channel.send('```' + q.map((m, i) => `${i === 0 ? 'now playing:' : i + '.'} ${m.title} ${(m.duration !== 0) ? formatTime(m.duration) : ''}`).join('\n') + '```');
|
||||
msg.channel.send(`${q.length} tracks\ntotal queue length: ${formatTime(q.reduce((p, c) => (p || {duration: 0}).duration || 0 + c.duration || 0))}\n` + '```' + q.slice(0, 10).map((m, i) => `${i === 0 ? 'now playing:' : i + '.'} ${m.title} ${(m.duration !== 0) ? formatTime(m.duration) : ''}`).join('\n') + '```');
|
||||
}
|
||||
} else if (cmd === 'np' || cmd === 'nowplaying') {
|
||||
const song = (queue[msg.guild.id] || [])[0];
|
||||
|
|
Reference in New Issue