-
-
The parent SpikeyBot instance. Defaults to required cache value for
autocompletion, updates to current reference at init.
Type:
- Inherited From:
-
- Source:
-
-
client :Discord~Client
-
The current bot client. Defaults to require cache value for editor
autocompletion, updates to current reference at init.
Type:
- Inherited From:
-
- Source:
-
-
-
The command object for registering command listeners. Defaults to require
cache value for editor autocompletion, updates to current reference at
init.
Type:
- Inherited From:
-
- Source:
-
-
<constant> commit :string
-
The commit at HEAD at the time this module was loaded. Essentially the
version of this submodule.
Type:
- Inherited From:
-
- Source:
-
-
-
The common object. Defaults to require cache value for editor
autocompletion, updates to current reference at init.
Type:
- Inherited From:
-
- Source:
-
-
Discord :Discord
-
The current Discord object instance of the bot. Defaults to require cache
value for editor autocompletion, updates to current reference at init.
Type:
- Inherited From:
-
- Source:
-
-
helpMessage :undefined|string|Discord~EmbedBuilder
-
The help message to show the user in the main help message.
Type:
-
undefined
|
string
|
Discord~EmbedBuilder
- Inherited From:
-
- Overrides:
- Source:
-
-
<protected, readonly> initialized :boolean
-
Has this subModule been initialized yet (Has begin() been called).
Type:
- Inherited From:
-
- Source:
-
-
<constant> loadTime :number
-
The time at which this module was loaded for use in checking if the
module needs to be reloaded because the file has been modified since
loading.
Type:
- Inherited From:
-
- Source:
-
-
<abstract, protected> myName :string
-
The name of this submodule. Used for differentiating in the log. Should
be defined before begin().
Type:
- Inherited From:
-
- Overrides:
- Source:
-
-
<abstract> postPrefix :string
-
The postfix for the global prefix for this subModule. Must be defined
before begin(), otherwise it is ignored.
Type:
- Inherited From:
-
- Source:
-
-
<private, inner, constant> broadcasts :object.<Music~Broadcast>
-
All current audio broadcasts to voice channels. Stores all relavent data.
Stored by guild id.
Type:
- Source:
-
-
<private, inner, constant> follows :object.<string>
-
The current user IDs of the users to follow into new voice channels. This
is mapped by guild id.
Type:
- Source:
-
-
<private, inner, constant> geniusClient :string
-
The Genuius client token we use to fetch information from their api.
Type:
- Source:
-
-
<private, inner, constant> geniusRequest :object
-
The request headers to send to genius.
Type:
- Default Value:
-
- {"hostname":"api.genius.com","path":"/search/","headers":"","method":"GET"}
- Source:
-
-
<private, inner, constant> helpObject
-
The object that stores all data to be formatted into the help message.
- Source:
-
-
<private, inner, constant> primaryStreamOptions :Discord~StreamOptions
-
Options to pass into the primary stream dispatcher (The one in charge of
volume control).
[StreamOptions](
https://discord.js.org/#/docs/main/master/typedef/StreamOptions).
Type:
- Default Value:
-
- {"passes":1,"fec":true,"bitrate":"auto","volume":0.5,"plp":0,"highWaterMark":5}
- Source:
-
-
<private, inner, constant> secondaryStreamOptions :Discord~StreamOptions
-
Options to pass into the secondary stream dispatcher (for Discord).
Type:
- Default Value:
-
- {"passes":1,"fec":true,"bitrate":"auto","volume":0.5,"plp":0.05,"highWaterMark":1000}
- Source:
-
-
<private, inner, constant> special :object.<object.<{cmd: string, url: ?string, file: string}>>
-
Special cases of requests to handle seperately.
Type:
-
object.<object.<{cmd: string, url: ?string, file: string}>>
- Source:
-
-
<private, inner, constant> ytdlOpts :Array.<string>
-
Options passed to youtube-dl for fetching videos.
Type:
- Default Value:
-
- ["-f","bestaudio/worst","--no-playlist","--default-search=auto"]
- Source:
-
-
<static> streamToOgg(input, file)
-
Coverts an incoming Opus stream to a ogg format and writes it to file.
Parameters:
Name |
Type |
Description |
input |
ReadableStream
|
The opus stream from Discord. |
file |
WritableStream
|
The file stream we are writing to. |
- Source:
-
-
begin(Discord, client, command, common, bot)
-
Initialize this submodule.
Parameters:
Name |
Type |
Description |
Discord |
Discord
|
The Discord object for the API library. |
client |
Discord~Client
|
The client that represents this bot. |
command |
Command
|
The command instance in which to
register command listeners. |
common |
Common
|
Class storing common functions. |
bot |
SpikeyBot
|
The parent SpikeyBot instance. |
- Inherited From:
-
- Source:
-
-
clearQueue(msg)
-
Empty a guild's current music queue.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The context for looking up the guild queue to
modify. |
- Source:
-
-
<protected> debug(msg)
-
Log using common.logDebug, but automatically set name.
Parameters:
Name |
Type |
Description |
msg |
string
|
The message to log. |
- Inherited From:
-
- Source:
-
-
end()
-
Trigger subModule to shutdown and get ready for process terminating.
- Inherited From:
-
- Source:
-
-
<protected> error(msg)
-
Log using common.error, but automatically set name.
Parameters:
Name |
Type |
Description |
msg |
string
|
The message to log. |
- Inherited From:
-
- Source:
-
-
getDuration(msg)
-
Get the song's length of the song playing in the given context.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The context to use to fetch the info. |
- Source:
-
Returns:
Time in seconds, or null if nothing is playing.
-
Type
-
number
-
getProgress(msg)
-
Get the current progress into the song in the given context.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The context to use to fetch the info. |
- Source:
-
Returns:
Time in seconds, or null if nothing is playing.
-
Type
-
number
-
<protected> initialize()
-
The function called at the end of begin() for further initialization
specific to the subModule. Must be defined before begin() is called.
- Inherited From:
-
- Overrides:
- Source:
-
-
isSubjugated(msg)
-
Check if music is being subjugated by another script.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The context to lookup the information. |
- Source:
-
Returns:
Null if nothing is playing, true if subjugated, false
if not subjugated.
-
Type
-
boolean
-
<protected> log(msg)
-
Log using common.log, but automatically set name.
Parameters:
Name |
Type |
Description |
msg |
string
|
The message to log. |
- Inherited From:
-
- Source:
-
-
pause(msg)
-
Attempt to pause the current broadcast in a guild.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The context to lookup guild info. |
- Source:
-
Returns:
True if success, false if failed.
-
Type
-
boolean
-
playSong(msg, song [, seek] [, subjugate])
-
Start playing or enqueue the requested song.
Parameters:
Name |
Type |
Argument |
Description |
msg |
Discord~Message
|
|
The message that triggered command, used for
context. |
song |
string
|
|
The song search criteria. |
seek |
number
|
<optional>
|
The time in seconds to seek to. |
subjugate |
boolean
|
<optional>
<nullable>
|
Force all control be via external sources
using public function calls. All queue control commands are disabled. Also
suppresses most information messages that would otherwise be sent to the
user. Null means leave as current value. |
- Source:
-
-
release(msg)
-
Release subjugation. Does not modify any current queue or playing
information.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The context to lookup the information. |
- Source:
-
-
<abstract> reloadable()
-
Check if this module is in a state that is ready to be
reloaded. If false is returned, this module should not be unloaded and
doing such may risk putting the module into an uncontrollable state. This
is different from unloadable, which checks if this module can be stopped
completely, this checks if the module can be stopped and restarted.
- Inherited From:
-
- Source:
-
- See:
-
Returns:
True if can be reloaded, false if cannot.
-
Type
-
boolean
-
resume(msg)
-
Attempt to resume the current broadcast in a guild.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The context to lookup guild info. |
- Source:
-
Returns:
True if success, false if failed.
-
Type
-
boolean
-
save( [opt])
-
Saves all data to files necessary for saving current state.
Parameters:
Name |
Type |
Argument |
Default |
Description |
opt |
string
|
<optional>
|
'sync'
|
Can be 'async', otherwise defaults to
synchronous. |
- Inherited From:
-
- Overrides:
- Source:
-
-
<protected> shutdown()
-
Shutdown and disable this submodule. Removes all event listeners.
- Inherited From:
-
- Overrides:
- Source:
-
-
skipSong(msg)
-
Skip the current song with the given context.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The context storing guild information for
looking up. |
- Source:
-
-
subjugate(msg)
-
Begin subjugation. Does not modify any current queue or playing
information.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The context to lookup the information. |
- Source:
-
-
unloadable()
-
Check if this module is in a state that is ready to be
unloaded. If false is returned, this module should not be unloaded and
doing such may risk putting the module into an uncontrollable state.
- Inherited From:
-
- Overrides:
- Source:
-
- See:
-
Returns:
True if can be unloaded, false if cannot.
-
Type
-
boolean
-
<protected> warn(msg)
-
Log using common.logWarning, but automatically set name.
Parameters:
Name |
Type |
Description |
msg |
string
|
The message to log. |
- Inherited From:
-
- Source:
-
-
<private, inner> changeVolume(broadcast, percentage)
-
Change the volume of the current broadcast.
Parameters:
Name |
Type |
Description |
broadcast |
Music~Broadcast
|
The objected storing the current
broadcast information. |
percentage |
number
|
The volume percentage to set to. 0.5 is half, 2
is double. |
- Source:
-
Returns:
True if success, false if something went wrong.
-
Type
-
boolean
-
<private, inner> commandClearQueue(msg)
-
Removes all songs from the current queue except for the currently playing
song.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that triggered the command. |
- Source:
-
Listens to Events:
- Command#event:clear
- Command#event:empty
-
<private, inner> commandFollow(msg)
-
Follow a user as they change voice channels.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that triggered command. |
- Source:
-
Listens to Events:
-
<private, inner> commandJoin(msg)
-
Join a voice channel that the user is in.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that triggered command. |
- Source:
-
Listens to Events:
-
<private, inner> commandLeave(msg)
-
Cause the bot to leave the voice channel and stop playing music.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that triggered the command. |
- Source:
-
Listens to Events:
- Command#event:leave
- Command#event:stop
- Command#event:stfu
-
<private, inner> commandLyrics(msg)
-
Search for a song's lyrics via Genius.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that triggered the command. |
- Source:
-
Listens to Events:
-
<private, inner> commandPause(msg)
-
Pause the currently playing music broadcast.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that triggered command. |
- Source:
-
Listens to Events:
-
<private, inner> commandPlay(msg)
-
Search for a song to play based off user request.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that triggered command. |
- Source:
-
Listens to Events:
-
<private, inner> commandQueue(msg)
-
Show the user what is in the queue.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that triggered the command. |
- Source:
-
Listens to Events:
- Command#event:q
- Command#event:queue
- Command#event:playing
-
<private, inner> commandRecord(msg)
-
Join a voice channel and record the specified users audio to a file on this
server.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that triggered the command. |
- Source:
-
Listens to Events:
-
<private, inner> commandRemove(msg)
-
Remove a song from the queue.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that triggered the command. |
- Source:
-
Listens to Events:
- Command#event:remove
- Command#event:dequeue
-
<private, inner> commandResume(msg)
-
Resume the currently paused music broadcast.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that triggered command. |
- Source:
-
Listens to Events:
-
<private, inner> commandSkip(msg)
-
Skip the currently playing song and continue to the next in the queue.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that triggered the command. |
- Source:
-
Listens to Events:
-
<private, inner> commandStats(msg)
-
Show statistics about current music broadcasts.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that triggered command. |
- Source:
-
Listens to Events:
-
<private, inner> commandVolume(msg)
-
Change the volume of the current music stream.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that triggered command. |
- Source:
-
Listens to Events:
- Command#event:volume
- Command#event:vol
- Command#event:v
-
<private, inner> endSong(broadcast)
-
Triggered when a song has finished playing.
Parameters:
Name |
Type |
Description |
broadcast |
Music~Broadcast
|
The object storing all relevant
information. |
- Source:
-
-
<private, inner> enqueueSong(broadcast, song, msg [, info] [, seek])
-
Add a song to the given broadcast's queue and start playing it not already.
Parameters:
Name |
Type |
Argument |
Default |
Description |
broadcast |
Music~Broadcast
|
|
|
The broadcast storage container. |
song |
string
|
|
|
The song that was requested. |
msg |
Discord~Message
|
|
|
The message that requested the song. |
info |
object
|
<optional>
|
|
The info from ytdl about the song. |
seek |
number
|
<optional>
|
0
|
The number of seconds into a song to start
playing. |
- Source:
-
Fires:
-
<private, inner> fetchLyricsPage(msg, url, title, thumb)
-
Request the webpage that has the song lyrics on them from Genius.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that triggered the command. |
url |
string
|
The url of the page to request. |
title |
string
|
The song title for showing the user later. |
thumb |
string
|
The url of the album art thumbnail to show the user
later. |
- Source:
-
-
-
Formats a given date into a datestring.
Parameters:
Name |
Type |
Description |
date |
Date
|
number
|
string
|
The date that Date() can accept. |
- Source:
-
Returns:
The formatted datetime.
-
Type
-
string
-
-
Format the given number of seconds into the playtime format.
Parameters:
Name |
Type |
Description |
seconds |
number
|
The duration in seconds. |
- Source:
-
Returns:
The formatted string in minutes and seconds.
-
Type
-
string
-
-
Format the info response from ytdl into a human readable format.
Parameters:
Name |
Type |
Argument |
Default |
Description |
info |
object
|
|
|
The info received from ytdl about the song. |
dispatcher |
Discord~StreamDispatcher
|
<optional>
|
|
The broadcast dispatcher
that is currently broadcasting audio. If defined, this will be used to
determine remaining play time. |
seek |
number
|
<optional>
|
0
|
The offset to add to totalStreamTime to correct
for starting playback somewhere other than the beginning. |
- Source:
-
Returns:
The formatted song info.
-
Type
-
Discord~EmbedBuilder
-
-
Add commas between digits on large numbers.
Parameters:
Name |
Type |
Description |
num |
number
|
string
|
The number to format. |
- Source:
-
Returns:
The formatted number.
-
Type
-
string
-
<private, inner> getRemainingSeconds(info, dispatcher)
-
Get the remaining playtime in the given song info and broadcast.
Parameters:
Name |
Type |
Description |
info |
object
|
The song info received from ytdl. |
dispatcher |
Discord~StreamDispatcher
|
The dispatcher playing the
song currently. |
- Source:
-
Returns:
Number of seconds remaining in the song playtime.
-
Type
-
number
-
<private, inner> getVolume(broadcast)
-
Get the volume of the current broadcast.
Parameters:
Name |
Type |
Description |
broadcast |
Music~Broadcast
|
The objected storing the current
broadcast information. |
- Source:
-
Returns:
The logarithmic volume percentage. 0.5 is half, 2 is
double. Null if error.
-
Type
-
number
-
<private, inner> handleVoiceStateUpdate(oldState, newState)
-
Leave a voice channel if all other users have left. Should also cause music
and recordings to stop.
Parameters:
Name |
Type |
Description |
oldState |
Discord~VoiceState
|
State before status update. |
newState |
Discord~VoiceState
|
State after status update. |
- Source:
-
Listens to Events:
- Discord~Client#event:voiceStateUpdate
-
<private, inner> makeBroadcast(broadcast)
-
Create a voice channel broadcast based off of the media source, and start
playing the audio.
Parameters:
Name |
Type |
Description |
broadcast |
Music~Broadcast
|
The object storing all relevant
information. |
- Source:
-
-
<private, inner> mention(msg)
-
Creates formatted string for mentioning the author of msg.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
Message to format a mention for the author of. |
- Source:
-
Returns:
Formatted mention string.
-
Type
-
string
-
<private, inner> monthToShort(month)
-
Convert the month number to a 3 letter string of the month's name.
Parameters:
Name |
Type |
Description |
month |
number
|
The month number (1-12). |
- Source:
-
Returns:
The 3 character string.
-
Type
-
string
-
<private, inner> pauseBroadcast(broadcast)
-
Cause the given broadcast to be paused.
Parameters:
Name |
Type |
Description |
broadcast |
Music~Broadcast
|
The object storing all relevant
information. |
- Source:
-
Returns:
If the music was actully paused. False if the music is
already paused or nothing is playing.
-
Type
-
boolean
-
<private, inner> reply(msg, text, post)
-
Replies to the author and channel of msg with the given message.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
Message to reply to. |
text |
string
|
The main body of the message. |
post |
string
|
The footer of the message. |
- Deprecated:
-
- Use Common.reply instead.
- Source:
-
Returns:
Promise of Discord~Message that we attempted to send.
-
Type
-
Promise
-
<private, inner> reqLyricsURL(msg, id)
-
Request the song information from Genius from previous search to find the
page where the lyrics are.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that triggered the command. |
id |
string
|
The id of the first song in the search results. |
- Source:
-
-
<private, inner> resumeBroadcast(broadcast)
-
Cause the given broadcast to be resumed.
Parameters:
Name |
Type |
Description |
broadcast |
Music~Broadcast
|
The object storing all relevant
information. |
- Source:
-
Returns:
If the music was actully resumed. False if the music is
already playing or nothing is playing or the bot is alone in a channel.
-
Type
-
boolean
-
<private, inner> skipSong(broadcast)
-
Skip the current song, then attempt to play the next.
Parameters:
Name |
Type |
Description |
broadcast |
Music~Broadcast
|
The object storing all relevant
information. |
- Source:
-
-
<private, inner> startPlaying(broadcast)
-
Start playing the first item in the queue of the broadcast.
Parameters:
Name |
Type |
Description |
broadcast |
Music~Broadcast
|
The container storing all information
about the song. |
- Source:
-
-
<private, inner> startStream(input, done, progress)
-
Starts the streams as a thread and reports done with the streams.
Parameters:
Name |
Type |
Description |
input |
object
|
Input vars. |
done |
function
|
Done callback. |
progress |
function
|
Progress callback. |
- Source:
-
-
<private, inner> stripLyrics(msg, content, title, url, thumb)
-
Crawl the received webpage for the data we need, then format the data and
show it to the user.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that triggered the command. |
content |
string
|
The entire page received. |
title |
string
|
The song title for showing the user. |
url |
string
|
The url of where we fetched the lyrics to show the
user. |
thumb |
string
|
The url of the album art thumbnail to show the user
later. |
- Source:
-