A simple Discord bot
- The prefix before each command can be changed in
.env(default is/) /manto list available commands. Also takes commands as arguments (f.e/man jdr)/ahInvokes the spirit of Denis Brogniart/awsand/async-awsSends gifs of dogs that know that they're doing/clfuPost snippets from commandlinefu.com. See man for args. Pass--publicas second arg to make the bot answer on current channel./fearFear the bot/gandalfPost a gif + text and play Gandalf sound/gifPost a gif depending on the argument (querying 3rd party API)/jdrCommands useful for roleplay/judgementCome in channel to play a sound (Currently set to Judgement Knights Of Thunder)/omaewaPost a picture + mention/rollTakesXdYargument, where X is the number of dices & Y the number of faces for dices. Ex:/roll 3d100/rShortcut for rolling 1D100/sayImplements phraze module/stopStop the sound played with/judgement/waifuPosts an anime girl
Allows arbitrary code execution, so it's only accessible to powerusers.
by providing their user.id in POWERUSERS environment variable, in csv format like so:
POWERUSERS=333331313111111111111331,13090932222222222222222If you don't know your user.id, calling eval or sh will log it in console.
/evalGood ol' eval accessible from Discord. Can optionally be passed a js blockcode for more readability./shRun bash commands thanks to child_process.exec & returns stdout in Discord/lispRun some lisp thanks to lips. Also accepts lisp blockcode./heapdumpTakes an argument. ! Need to runnode --expose-gc index.jsinstead of your usualnode index.jsto be able to "manually" proc the GC.
- A shell (terminal)
- FFMPEG (must be on your system. Type
ffmpegorffmpeg -versionin terminal to check) - Node.js >= 13 (
node -vto check)
First time (in terminal): git clone https://github.com/TheRealBarenziah/jdr9000.git && cd ./jdr9000
- Rename
.env.templateinto.env - Change TOKEN field with your own API key (ex:
TOKEN=yournewapikey) - First time launch:
npm i && node index.js(npm iwill install local dependencies) - Stop bot:
Ctrl+C - Launch in development mode (
node --expose-gc index.js) or in production mode (NODE_ENV=production node index.js)
- In the root directory, use
docker image build -t jdr9000:v2 -f docker/jdrDockerfile .to build the image. - Use
docker container run -tid -e TOKEN=YourToken -e PREFIX=YourPrefix --name jdr-v2 --restart=always jdr9000:v2 node --expose-gc index.jsto launch the container from the image.
- You will find the deployement manifest here
kube/deploy_jdrbot.yaml - Use
kubectl apply -f kube/deploy_jdrbot.yamlfrom the root directory of this repo to deploy the manifest on the kubernetes cluster described in your kubeconfig. - As you can see, this deployement is using a secret object containing your access Token
- Create the secret using this command
kubectl create secret generic discord-api-token --from-literal TOKEN="YourToken" - In the manifest, feel free to change, remove or add env vars and values.
- You also can modify to your needs the args for the
nodecommand. - This deployement do not use hosted docker images, you have to build it with the dockerfile as seen previously.
- Obviously, you will use the same name in the manifest as the name you used to build the image.
Create a Discord server and invite your bot there (Discord dev website > Oauth section. Then tick "bot" and select appropriate permissions to get the invite link) see the documentation
- check for bot id before letting him try to connect to vocal channel
Thanks Michiel Mulders for his article + repo that helped me get started in no time.
