Skip to content

Commit 700f593

Browse files
committed
Formatting update
1 parent 6ca173d commit 700f593

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@ If you come across some issues feel free to post them in the issues.
44

55
### General Setup
66
To be written.
7+
### Node must be version 12!
8+
Ubuntu node install:
9+
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
10+
sudo apt-get install -y nodejs
711

812
## COMMAND DOCUMENTATION:
913
### NOTE:
1014
Anything after ! is a command name and the prefix ! is needed to run the command,
1115
the items in <> are the function arguments and anything with OPTIONAL is as it sounds.
16+
1217
```
1318
!play <SONG-NAME>
1419
```

commands/ytdltie.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
const ytdl = require('ytdl-core');
2+
const ytSearch = require('yt-search');
13
/*
2-
Start of an object wrapper for the ytdl class
3-
and a queue system for a nodeJS music bot.
4+
Start of an object wrapper for the ytdl class and a queue system for a nodeJS music bot.
5+
This is a core file for the bot but also acts as an interface to the ytdl code and simplifies it in
6+
the main index page.
47
*/
58

6-
const ytdl = require('ytdl-core');
7-
const ytSearch = require('yt-search');
89

910
/*ffmpeg_options = { // Keep bot from dying if it cuts out, could pass this in play, hard coded for now.
1011
'options': '-vn',
@@ -144,6 +145,8 @@ module.exports = class ytdltie {
144145
return;
145146
}
146147
const stream = ytdl(song.url, {filter: 'audioonly',options: '-vn', before_options: "-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5", highWaterMark: 1<<25, maxReconnect: 10});
148+
// highWaterMark is in bytes, 32MB to load up front(Excessive but effective?), maxReconnect tells it to try 10 times on failure. before_options also tell it to try and reconnect.
149+
// Each song gets its own new Stream, so in theory 10 should be enough unless the song is super long.
147150
song_queue.connection.play(stream, {seek: 0, volume: 0.5})
148151
.on('finish', () => {
149152
song_queue.songs.shift();
@@ -152,5 +155,4 @@ module.exports = class ytdltie {
152155
await song_queue.text_channel.send(`Now playing **${song.title}**`); // Customizable
153156
}
154157

155-
}
156-
158+
}

index.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
1-
/*
2-
packages:
3-
discord.js
4-
@discordjs/opus
5-
ffmpeg-static
6-
yt-search
7-
ytdl-core
8-
9-
Ubuntu node install:
10-
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
11-
sudo apt-get install -y nodejs
12-
*/
131
const ytdltie = require('./commands/ytdltie.js');
142
const Discord = require('discord.js');
153
const {
164
prefix,
175
token,
186
} = require('./config.json');
7+
/*
8+
Main file for running the bot, contains the command handler, ytdltie object (MusicHandler) and error handling.
9+
*/
1910
const client = new Discord.Client();
2011
const MusicHandler = new ytdltie(Discord,client);
2112
client.login(token);

0 commit comments

Comments
 (0)