A simple discord bot made with love, in javascript using Node.js.
This repository is mainly here to easily deploy Derpy on my server, but if someone can find any kind of use from it, go.
- Fetch the last PUBG match for a list of players
- Play youtube audio
- Fetch rss feeds (and send a message when a new entry is found)
- Fetch reddit 'hot', 'new', 'rising', 'controversial', 'top', 'gilded' listings (and send a message when a new entry is found)
- Respond to a member trigger message
- And some stupid/fun/whatever-you-name-it stuff
Before anything you will need:
- Node.js (Derpy was developed with version 14.17.4)
- MongoDB
- A web server to act as a proxy (NGINX/Apache)
- Python 2.7
- FFmpeg
- A discord token
- A PUBG api key
- A YouTube api key
On Linux it is pretty straightforward, this should get you there (on Debian 9)
sudo apt install build-essential mongodb nginx python2.7 ffmpegNote: On Debian 11 MongoDB is not available atm, here is a link to it's documentation.
For Node.js it is up to you, I personally create a new user for each app and use nvm.
On Windows you should install Node.js globally, and google how to install FFmpeg.
Follow the instruction on node-gyp page after "Depending on your operating system, you will need to install:".
Assuming you got Git installed:
mkdir derpy
cd derpy
git clone https://github.com/Shenton/derpy.git .
npm iAt this point you should take a look at the sample config file, rename/copy it to config.json and/or config-dev.json and edit it.
To get channels and members ID, activate the developer mode from the Discord application settings and use the context menu on them.
Go to Discord developer portal and create a new application, add a bot and add an oauth redirect to:
<your base url>/api/discord/callback
Get the bot application client id, it is located on the front page of your app. Edit and paste this URL in a browser:
https://discordapp.com/oauth2/authorize?&client_id=<your bot client id>&scope=bot&permissions=36829280
Then pick your guild.
Before running Derpy the front end must be build. If you run Derpy in develoment, the front end must be build before running in production.
npm run buildDerpy require a secure web server acting as a proxy. You can get a certificate using Let’s Encrypt.
Here is a virtual server configuration example for NGINX:
server {
listen 80;
listen [::]:80;
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /etc/letsencrypt/live/derpy.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/derpy.example.com/privkey.pem;
server_name derpy.example.com;
if ($ssl_protocol = "") {
return 301 https://$server_name$request_uri;
}
location / {
proxy_redirect off;
proxy_http_version 1.1;
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}You can activate the log rotation of pm2 by running:
npm run pm2logrotateStarting Derpy in production:
npm startStopping Derpy:
npm stopYou can start Derpy in development mode by running:
npm run devcd derpy
npm stop
git pull
npm i
npm run build
npm startDerpy is designed to serve one guild, and it will nether change. It contains private jokes, stupid things, etc.
I will not add new features if you ask me. The licence is MIT, fork it, copy it, take whatever you want from it, and create your own. But do take note that I am not a skilled developer and node/javascript is new to me.
MIT