Below is a basic overview of the project structure:
├── examples
│ ├── app.js
│ ├── button.js
│ ├── command.js
│ ├── modal.js
│ ├── selectMenu.js
├── utils -> utility app functions
│ ├── initializeDB.js -> database connection
│ ├── makeWallet.js -> wallet auto generation
│ ├── ufw.js -> allowIP and deleteIP for firewall
├── .env.sample -> sample .env file
├── app.js -> main entrypoint for app
├── commands.js -> slash command payloads + helpers
├── package.json
├── README.md
└── .gitignore
└── utils.js -> utility general functions
Before you start, you'll need to install NodeJS and create a Discord app with the proper permissions:
applications.commands
bot
(with Send Messages enabled)
Configuring the app is covered in detail in the getting started guide.
First clone the project:
git clone https://github.com/hiroyukikumazawa/seigmaai-discordbot-backend
Then navigate to its directory and install dependencies:
cd seigmaai-discordbot-backend
npm install
Fetch the credentials from your app's settings and add them to a .env
file (see .env.sample
for an example). You'll need your app ID (APP_ID
), bot token (DISCORD_TOKEN
), and public key (PUBLIC_KEY
).
Fetching credentials is covered in detail in the getting started guide.
🔑 Environment variables can be added to the
.env
file in Glitch or when developing locally, and in the Secrets tab in Replit (the lock icon on the left).
The commands for the example app are set up in commands.js
. All of the commands in the ALL_COMMANDS
array at the bottom of commands.js
will be installed when you run the register
command configured in package.json
:
npm run register
After your credentials are added, go ahead and run the app:
npm run dev
⚙️ A package like
nodemon
, which watches for local changes and restarts your app, may be helpful while locally developing.
If you aren't following the getting started guide, you can move the contents of examples/app.js
(the finished app.js
file) to the top-level app.js
.
The project needs a public endpoint where Discord can send requests. To develop and test locally, you can use something like ngrok
to tunnel HTTP traffic.
Install ngrok if you haven't already, then start listening on port 2024
:
ngrok http 2024
You should see your connection open:
Tunnel Status online
Version 2.0/2.0
Web Interface http://127.0.0.1:4040
Forwarding http://1234-someurl.ngrok.io -> localhost:2024
Forwarding https://1234-someurl.ngrok.io -> localhost:2024
Connections ttl opn rt1 rt5 p50 p90
0 0 0.00 0.00 0.00 0.00
Copy the forwarding address that starts with https
, in this case https://1234-someurl.ngrok.io
, then go to your app's settings.
On the General Information tab, there will be an Interactions Endpoint URL. Paste your ngrok address there, and append /interactions
to it (https://1234-someurl.ngrok.io/interactions
in the example).
Click Save Changes, and your app should be ready to run 🚀
this is from your discord bot app.
this is from your discord bot app.
this is from your discord bot app.
this is your mongodb server uri. so you need to install mongodb.
this is from your discord server. you can get role id from 'server settings/Roles' of your discord server.
# RPCURL=https://sei-rpc.polkachu.com/
this is mainnet url of SEI network. if you are trying to use this bot in mainnet, you should remove comment of this line and add comment in front of next line.
this is testnet url of SEI network. so you can test with this url.
this is your SEIGMA token denom.
this is your SEIGMA token decimal. but i set this with 6, it's just only for test.
this is the SEI amount user have to pay to use your server. maybe this is 50000000, but i set this with 2000000. it's just only for test.
this is the SEIGMA amount user have to pay to use your server. maybe this is 45000000, but i set this with 1800000. it's just only for test.
this is the wallet address where all payments will be stored.
this is your timezone. this is a factor that affects the subscription function, so it must be selected accurately.
this is your server api port.