A discord.js bot that listens to messages in channels and replies with items from an nft collection.
A discord.js bot that listens to messages in channels and replies with items from an nft collection.
Originally developed for @dutchtide's ππππππππ₯ ε€ε£ πΉπ£πππ«π collection.
An OpenSea API key is needed - create one in your account.
To run multiple instances of this bot at once check out bot-runner. Also check out opensea-activity-bot.
Supported syntax:
#1234
#random
or #rand
or #?
Example reply:
Example console output:
------------------------------------------------------------
Logged in as Dutchtide Listen Bot#8486!
Listening for messagesβ¦
------------------------------------------------------------
Message from ryanio in #π΄πview-the-breezeππ΄:
> #random
Fetching #2248β¦
Replied with #2248
------------------------------------------------------------
Provided metadata fields:
You can add specific properties of the nft by formatting nft.traits
and adding to the fields
array.
Please define the following env variables for the repository to work as intended.
DISCORD_TOKEN
OPENSEA_API_TOKEN
CHAIN
ethereum
.TOKEN_NAME
TOKEN_ADDRESS
MIN_TOKEN_ID
MAX_TOKEN_ID
RANDOM_INTERVALS
channelId=intervalInMinutes
e.g. 662377002338091020=5,924064011820077076=10
to send random items to channels in intervals.CUSTOM_DESCRIPTION
{id}
is replaced with the token ID.To get your DISCORD_TOKEN
, create a Discord app. Create a bot with the permissions: Read Messages/View Channels
, Send Messages
, and Embed Links
. Then add your bot to your server. The bot will listen and reply to messages in all of the channels it has access to.
The DISCORD_TOKEN
looks like this: OTE5MzY5ODIyNzEyNzc5NzUz.YBuz2g.x1rGh4zx_XlSNj43oreukvlwsfw
If your discord bot is not able to post messages ensure it is added to the channels you've specified and it has the permissions to Read Messages/View Channels
, Send Messages
and Embed Links
, and that you have also enabled Message Content Intent
on your bot page.
yarn start
My preferred setup is a $5/month Basic Droplet with Ubuntu. Install Node v16 and yarn, clone this repo, cd into it, run yarn
, install pm2 with yarn global add pm2
, set env vars, run pm2 start yarn -- start
. Monitor with pm2 list
and pm2 logs
. Add log rotation module to keep default max 10mb of logs with pm2 install pm2-logrotate
. To respawn after reboot, set your env vars in /etc/profile
, then run pm2 startup
and pm2 save
.
You can support this repository (and get your first two months free) with the referral badge below:
A Procfile
is included for easy use.
Clone this repo, push it to heroku, set up the environment variables above, and spin up a worker with heroku ps:scale web=0 worker=1
Then watch the logs with heroku logs --tail