- JavaScript 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| .forgejo/workflows | ||
| .vscode | ||
| data | ||
| images | ||
| testing | ||
| .gitignore | ||
| config.json.template | ||
| debug.js | ||
| eval.md | ||
| funcs.js | ||
| genblacklist.js | ||
| goodrooms.json | ||
| index.js | ||
| LICENSE | ||
| package.json | ||
| PERMISSIONS.md | ||
| PRIVACY.md | ||
| README.md | ||
| TERMS.md | ||
| testmsg.json | ||
| TODO | ||
| wstest.js | ||
Warning
This is SUPER tossed together. Might bother cleaning it up later.
What is this?
This is meant to be a public Discord bot. It connects via XMPP to Weather.IM and allows server owners to subscribe a channel to any number of weather alerts.
For a full breakdown of Discord permissions required by the bot, see PERMISSIONS.md.
Pre-requisites
- Node.js
- NPM
- A Discord bot token
- A running Lavalink server (only required if
voice_enabledistrue- see Voice / Lavalink Setup below)
How do I use this?
- Clone the repo
- Install the requirements with
npm install - Copy
config.json.templatetoconfig.jsonand fill in the valuestokenis your Discord bot tokenclientIdis your Discord application/bot's ID (needed for voice/Lavalink)owneris your Discord user IDmainGuildis the ID of the guild you want to use as the main guild (This is used for making the support invite)inviteChannelis the ID of the channel you want to use for the support invite- NTFY config is optional, leave enabled false if you don't want to use it or don't know how.
lavalinkconfig is only used ifvoice_enabledistrue, see Voice / Lavalink Setup below.
- Run
node . - Profit?
Voice / Lavalink Setup
The bot uses Lavalink to join voice channels and stream audio (NWR streams, Broadcastify streams, and generic /play URLs). Lavalink is a standalone server that handles all the actual audio streaming/encoding, so the bot itself no longer needs any native audio dependencies (opus, sodium, ffmpeg, etc.) - it just tells Lavalink what to play.
1. Requirements
- Java 17 or newer (Java 21 recommended) - required to run the Lavalink server jar.
2. Download and configure Lavalink
-
Download the latest
Lavalink.jarfrom the Lavalink releases page. -
In the same folder as the jar, create an
application.ymlfile. A minimal config that supports HTTP/HTTPS radio streams (which is all this bot needs) looks like:server: port: 2333 address: 0.0.0.0 lavalink: server: password: "youshallnotpass" sources: http: true youtube: false soundcloud: false bandcamp: false twitch: false vimeo: false local: false logging: level: root: INFO lavalink: INFO- Change
passwordto something secret, it's used to authenticate the bot's connection to this Lavalink server. - The
httpsource is what allows Lavalink to play the raw stream URLs (NWR streams, Broadcastify,/play <url>) this bot uses. The other sources (YouTube, SoundCloud, etc.) aren't needed and can stay disabled.
- Change
-
Start the server:
java -jar Lavalink.jarYou should see a log line indicating the server started (e.g.
Lavalink is ready to accept connections.).You can also run Lavalink via Docker instead, see the official Lavalink getting-started guide for a
docker-compose.ymlexample.
3. Point the bot at your Lavalink server
In config.json, fill in the lavalink block to match whatever you configured in application.yml:
"lavalink": {
"id": "main",
"host": "localhost",
"port": 2333,
"password": "youshallnotpass",
"secure": false
}
host/portshould point to wherever the Lavalink server is running (if it's running on the same machine as the bot,localhostis fine).passwordmust match thelavalink.server.passwordvalue inapplication.yml.secureshould betrueif your Lavalink server is behind HTTPS/WSS (e.g. behind a reverse proxy with TLS).- Also make sure
config.discord.clientIdis set to your bot's application ID - it's required to establish the Lavalink session.
4. Enable voice commands
Set "voice_enabled": true in config.json and restart the bot. This registers the /play, /playbcfy, /nwrplay, /leave, /pause, and /volume slash commands, and connects to the configured Lavalink node on startup.
If the Lavalink node is unreachable, the bot will still run, but voice commands will fail until the node connects.
TODO
- Clean up the code
- Add more error handling
- Add more logging
- Add more features
- Add more documentation