/beatbattlebot

Util bot for handling beat battle submissions, sessions, and maybe more

Primary LanguageJavaScriptOtherNOASSERTION

Beat Battle Bot - Discord.js Music Helper

About beatbattlebot

This is a discord bot for managing beat battles, or really any other community-oriented song contests. If you're a discord mod/admin and you're looking for an always-updated guide, you can check it out here

Features

  • Per-channel battles with submissions and submission deadlines
  • Voter registration and vote submission (optional, after a submission deadline)
  • Submission viewing for contestants, voting results for moderators
  • Gift exchange functionality as the result of a Sample Pack Secret Santa held in 2020
  • Novelty functions such as coin flipping and decision making

Running the bot

You can run the bot locally with npm i; npm run devbot and a Discord bot token, which can be acquired at this link. For those that want to set up a private instance, this bot is set up to be easy to run with systemd, check the service dir for some templates and a unit file.

To see a current list of available commands, run !help in a bot channel or as a DM to the bot

Development

Install Node.js 12+, fork this project, npm install, set up an app token (see 'Running the Bot'), add the token to a NEW file at .token.json in the project root, then invite the bot to a server for testing.

'npm start' will run the bot in the foreground, 'npm run devbot' will run a hot-reloading bot instance, and 'npm test' should run quietly with no issues if everything's set up correctly. 'npm run verbosetest' will show you the npm test output, which should look like Discord-formatted responses.

Note: battlecache.test.json may be helpful for testing, just cp it to battlecache.json, rename SERVER_CHANNEL1 and DIFFSERVER_CHANNEL to names appropriate for your server (e.g. "$servername_$botchannelname", this should change to ID though: #23)

Expectations and how it loads

The bot is set up to load a list of local libs, grab every exported function, and drop the functions + a bit of metadata into a global commander object. That said, this means it calls all functions exactly the same way - and if you need more parameters for some reason, perhaps we should chat. For your new commands to drop in and immediately work, they must have the following signature: f(input:String, message:discord.js#message, client:discord.js#client)

  • input will be everything after your commands name in the message to the bot (like '!commandname input is all this stuff'), the message will be the full message object per the Discord.js api, and the client is from Discord.js too.

Writing new commands

If you just want to just add a relevant command to a library, you only need step 4. But if you have commands to add that don't seem to fit with the theme of functions in a particular file, follow all of these steps to add a new library folder to the bot:

  1. Find an appropriate place to put your command - if one exists, skip to step 4, otherwise make a new directory
  2. Add your new directory to the MODULES array in bot.js
  3. Copy index.js from discordlib or gravemind into your new lib as a handy piece of boilerplate
  4. Write exported functions in your library (Note: The bot ignores the default export!)
  5. Update the index.js in your library so it loads a file you create in your new lib
  6. Run it! You've now added functionality to the bot!

Development triage:

ImportError: no module compiler.ast:

If you see the above issue during 'npm install', just run 'sudo apt install python-dev'

Other Issues

If you run into other problems, click the link at the top of this readme to report an issue and we can discuss the issue in the comments