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#randomor#randor#?
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:
- Owner
- Last sale
- Listed for
- Best offer
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_TOKENOPENSEA_API_TOKEN
CHAIN- Value from OpenSea Supported Chains. Defaults to
ethereum.
- Value from OpenSea Supported Chains. Defaults to
TOKEN_NAMETOKEN_ADDRESSMIN_TOKEN_IDMAX_TOKEN_ID
RANDOM_INTERVALS- A comma-separated list of
channelId=intervalInMinutese.g.662377002338091020=5,924064011820077076=10to send random items to channels in intervals.
- A comma-separated list of
CUSTOM_DESCRIPTION- A custom description for the embed. The string
{id}is replaced with the token ID. -LOG_LEVEL - Minimum log level to output:
debug,info,warn, orerror. Defaults toinfo. Usedebugto include detailed request diagnostics.
- A custom description for the embed. The string
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 v22 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:
