Nouns Builder Bot
This repo contains all of the code needed to spin up a Twitter/Discord bot that tracks Nouns Builder events. Right now if you were to run the code as is your bot
would tweet about events that are happening across all Nouns Builder DAOs. To change this and instead only tweet about events from a specific DAO you want to track
you will need to change the env variable DAO_TOKEN_ADDRESS
from "all"
to the DAO's token address.
Twitter Bot
Step 1 ~ Setting up your bot
First you will need to create a twitter account. Once you have made your twitter account you will then head to settings and add a phone number. A phone number is needed to access twitter's developer features.
Then head to https://developer.twitter.com/ and set up your first project. Once you have a twitter project set up you will then want to start saving the bot's tokens to your .env file.
Step 2 ~ Changing the .ENV variables
These are the .env variables you will need:
TWITTER_API_KEY
TWITTER_API_KEY_SECRET
TWITTER_ACCESS_TOKEN
TWITTER_ACCESS_TOKEN_SECRET
RPC_URL
(you can get this from https://www.alchemy.com/)DAO_TOKEN_ADDRESS
(keep as "all" if you want to track all DAOs or change to a specfic DAO token address that you want to track)REDIS_URL
(ignore until you get to the deploying step)
Step 3 ~ Deploying your bot
There are many different services that you can use to deploy but we will focus on Railway.
- Head to https://railway.app/
- Go to your dashboard and click the
New Project
button - Select
Deploy From Repo
(make sure you have put your bot on github! private repos are okay too) - Select the repo with your bot
- Add your environment variables
- Now that your bot is being deployed next head to the
add plugin
button under Environment - Click add Redis
- Click on your redis plugin and go to the
connect
tab - Copy your
redis connection url
- Go to your variables and paste the
redis connection url
in yourREDIS_URL
env variable - Wait for the changes to update and redeploy
- Your bot should be working now!
Discord Bot
Step 1 ~ Creating a Discord Bot
- Make sure that you have a server setup that you want to add the bot to. If not, then create one first.
- Head to https://discord.com/developers/applications to create your bot
- Click the
New Application
button - Type in a name for your bot and click
create
- In the
General Information
tab add an app icon, name, and description for your bot - Head to the
bot
tab and clickadd bot
- Copy the token and save this to your env variable
DISCORD_BOT_TOKEN
- Head to the
OAuth2
tab and go to the sub tabURL Generator
- In
Scopes
selectbot
and in bot permissions selectsend messages
- Copy the generated URL and paste it into your browser
- Select the Discord server you want to add your bot into and invite it into your server
Discord Environment variables
DISCORD_BOT_TOKEN
this is your bot's tokenAPPLICATION_ID
this is the channel id you want your bot to post messages inGUILD_ID
this is the server id that you want your bot to post messages in
Running locally
- run
yarn
- launch a redis server in a seperate terminal by running
redis-server
- run
yarn ts-node src/index.ts
- your bot should be up and running now!