- Retrieve a funny Quote of the Day from the Quotes REST service, as well as speak it using Discord's Text-to-Speech feature.
- Search Google and post the first result.
- Retrieve xkcd webcomics.
- Instant Rick Roll.
- Automatically join Snail Races if your server has the Snail Racing bot.
- Perform math calculations.
- Stream YouTube into voice channels.
- Reload the configuration store without restarting the bot.
- Automatically enters Safe Mode if the reloaded configuration is invalid.
- Logging output to file.
- Remotely do a partial dump of the log file.
- Remotely reset or shutdown the bot.
- Obligatory 2001 reference.
- Obligatory Linux joke.
- Feature not on the list? Request it with a GitHub issue!
You can join my Discord server which has HAL9000 running already: https://discord.gg/QxgYfw8. And your own bots won't be allowed. Sorry.
- The practically magical library Discord.io by izy521, specifically the gateway v6 fork by Woor
- command-line-arguments by 75lb
- google-search by Aykut Yaman
- An aptly-named INI parser called ini written by isaacs
- node-fetch by Timothy Gu and David Frank, AKA bitinn
- sync-exec by gvarsanyi
- tiny-worker by Jason Mulligan
- The Winston logging library by serveral people
- xkcd-api by sidhantpanda
- Youtube MP3 Downloader by ytb2mp3
- youtube-search by maxgfeller
- An Asm.js module written by Dave Herman for quickly calculating the geometric mean of two values
- FFmpeg by The FFmpeg project
The bot is written for NodeJS, a JavaScript runtime based on Google's V8 engine used in Chrome, Opera, and Vivaldi. In order to use the bot, you must have NodeJS installed first. To install Node, please download the appropriate file for your system. On Windows, you need to add Node and NPM to your %PATH%
.
Next, you need to download the actual bot. You can download it as a zip file from GitHub, or you can use the command-line git
program:
$ git clone https://github.com/geoffreycs/hal9000-bot.git
You may also download the bundled version. It functions exactly the same as the master branch except it doesn't require external dependencies. More information and link to download available here.
Besides the bundled version, another version with a basic graphical user interface is available. From the perspective of Discord, it is exactly the same. The interface allows for reconfiguring, toggling safe mode, reconnecting, and shutting down the bot. It also has an imitation scrolling console that mimics the behavior of the Winston logger on the system console. The last thing it can do is that it uses push notifications to alert you to safe mode being entered, safe mode being exited, or a reconfiguration occuring. More information and instructions available here. An alternate build with a GUI is also available.
If you downloaded the zip file, unpack it. Either method, move into the directory where bot.js
and the other main files are located. If you are on Windows and doing this with File Explorer, hold down Shift
while right-clicking on a blank space, and choose "Open command window here." On Linux or another *nix system, your file manager may have an option to open in the terminal. If not, open the terminal manually and cd
into the directory.
If you are using the bundled version, you can skip to the next step. Once you are in the correct directory in a command line, install the dependencies with:
$ npm install
Now open up config.ini
with your favorite text editing software and set the correct options. See the Configuration File Usage section for how to properly configure your bot.
Once configuration is complete, it is now time to run your bot, granted that you've added it to at least one server.
node bot.js [[--config] <./path/to/config/file.ini>] [--songs <./path/to/songs/file.ini>
--config
- Allows user to specify an INI configuration file. Not required.
./path/to/config/file.ini
- Path to INI configuration file. May be passed with or without --config
flag. If not passed, configuration file defaults to ./config.ini
.
$ node bot.js --config alt.ini
$ node bot.js alt.ini
$ node bot.js
token =
- Here you need to specify your Discord account token. For information on how to get that token, see this page if you are using a normal account or this page if you want to use a bot account.
game =
- Set the title of the game you want the bot to appear to be "playing."
general[] =
- Set the ID of the #general text channel, or whichever channel you want the bot to announce its presence on. To get the IDs, in Discord, go to "User Settings" > "Appearance," scroll down, and turn on "Developer Mode." To get the ID of the intended channel, right-click its name in the left pane and choose "Copy ID." You may specify multiple channels like so:
general[] = 265002879549440001
general[] = 269958522907787267
owner =
- Your Discord userID. The bot will use this to identify who is its owner/admin. To get your ID, follow the steps above to turn on Developer Mode, and right-click your name in the right pane and choose "Copy ID."
your_account =
- What you want the bot to call you.
bot_name =
- What the bot should call itself.
default_voice =
- The ID of the default voice channel the bot will connect to for its audio functions. Only required if you intend to use those functions.
greet =
- Whether the bot should announce its presence on the server. Accepts yes
or no
.
voice_id[] =
- Specify an ID for an available voice channel the bot can connect to. Only required if you intent to use audio functionality.
voice_name[] =
User-friendly name for the voice channel specified. Only required if you intent to use audio functionality. Like the general[]
option, you can specify multiple ID/name pairs:
voice_id[] = 304070211139665920
voice_name[] = General
voice_id[] = 346392765640474624
voice_name[] = AFK
allowed_channels[] =
- Specify an ID of the text channel that the bot should accept commands from. All other channels will be silently ignored. Again, you can have multiple channels:
allowed_channels[] = 319233914864533516
allowed_channels[] = 320753155677749248
allowed_channels[] = 304070211139665920
prefix =
- Changes the default !
command marker. For instance, setting it to >
would mean that commands would start with >
instead of !
.
snail =
- Toggles Snail Racing integration. Requires the Snail Racing bot to be present.
youtube =
- Toggles YouTube audio streaming functionality. Requires YouTube Data APIv3 key.
googlesearch =
- Toggles Google Search functionality. Requires both a Google API key and a Google Custom Search Engine key.
quote =
- Toggles Quote-of-the-Day functionality.
tts =
- Toggles the tts
parameter availability for the !quote
command. Requires \tts
to be enabled by the server to have any effect.
voice =
- Toggles local audio streaming.
api_key =
- Google API key. Only required to use !search
command.
api_cx =
- Google Custom Search Engine key. Only required to use !search
command.
language =
- Language of search results. Example: lang_en
. Only required to use !search
command.
ffmpeg =
- Path to an FFMpeg binary. On most Linux distributions and on many *nix systems will be /usr/bin/ffmpeg
. Requires FFMpeg to be installed. Only required to use audio functionality.
youtube_key =
- YouTube Data API v3 key. Only required for YouTube audio streaming functionality.
loglevel =
- Defines how noisy the Winston logger should be during operation.
maxerrors =
- Specifies the maximum number of audio-related errors should be allowed within two minutes before safe mode is automatically entered.
audio_file[] =
- Path to audio file. Must be an audio-only file. Video files with audio tracks will not work. Relative paths are fine.
audio_name[] =
- User-friendly name of audio track.
The file/name pair can be repeated to have multiple tracks:
audio_file[] = numa.mp3
audio_name[] = Numa Numa Yei by O-Zone (Romanian)
audio_file[] = kirby.mp3
audio_name[] = Gourmet Race from Kirby SuperStar
!help
- Shows this help text.
!quote
- Displays funny quote-of-the-day from the Quotes REST API. Add the tts
paramter to use Discord's /tts
feature with it.
!search <query>
- Displays the first Google result for that query in the chat.
!xkcd [comic # or 'random' ]
- Fetch latest xkcd comic, specify number to show spcified comic, or specify random to get random comic.
!rick [parameter]
- Instant RickRoll. Available options include a YouTube link, text lyrics, or a GIF.
!s race
or !snail race
- Starts a normal Snail Race, but the bot also joins automatically. Requires the Snail Racing bot.
!roll [number of faces]
- Rolls a die, optionally with a specified number of faces. If no number of faces is given, then a standard six-faced die is rolled.
!gmean <value> <value>
- Calculates the geometric mean of the two given values.
!trig <angle in decimal degrees>
- Calculates the three main trig ratios for the given angle.
!hypot <leg> <leg>
- Calculates the hypotenuse of a right triangle given the two leg lengthes.
!leg <known leg> <hypotenuse>
- Calculates the missing leg of a right triangle given a known leg and the hypotenuse.
!open the pod bay doors
- Try it.
!moo
- Same as Debian Linux's apt-get moo
command.
!audio [selector]
- Plays specified audio to currently set voice channel. Use without selector to see available audio files.
!leave
- Stops playing audio and leaves the voice channel.
!switch_voice <selector>
- Change selected voice channel.
!list_voice
- Lists configured voice channels.
!set_voice <channel_id>
- Manually set voice channel ID.
!stream <YouTube video ID>
- Streams the audio of the video matching the provided ID.
!yt <keywords>
- Streams the audio of the first video result matching the specified keywords.
!reconfig
- Reload values from the configuration file.
!reset
- Forces disconnect and reconnect.
!debug
- Dumps the last 2000 characters of log file.
!execption
- For tesing purposes: Throws an exception.
!shutdown
- Posts a notice of going offline, dumps the last 1000 characters of the log, disconnects Discord socket, syncs filesystem, and exits NodeJS runtime.
!clear
- Deletes the log file.
!safemode
- Sets the variable to enter Safe Mode.
!videos
- Used to display most recent videos from several meme channels. (Was written for my personal server, but later discontinued.)