Uses Twitter API to receive a stream of tweets from a filtered criteria and posts them to Discord as an embedded message.
Add YouTube API handling to get latest video posts
- Clone the repository
- Create a .env file in the root directory and add the following:
BEARER_TOKEN=
WEBHOOK_URL=
USERNAME=
- Download the Twitter API v2 Postman environment. Populate the environment variables with your
bearer_token
,access_token
,token_secret
. - Setup the Add Rules for the FilteredStream
https://api.twitter.com/2/tweets/search/stream/rules
{
"add": [
{
"value": "from:USERNAME",
"tag": ""
}
]
}
REPLACE USERNAME WITH YOUR TWITTER USERNAME
You will have to create a Twitter Developer Account and create an application on your account.
Once you have an application copy the BEARER_TOKEN
and paste it in the .env file.
On your Discord server. Click the settings icon next to a text channel you want to add the webhook to, click integrations
, webhooks
, new webhooks. Then copy the webhook url and paste it in the .env file
Add your twitter username to the .env file (Case sensitive).
Luckily Discord automatically formats Tweets as embedded messages in a nice and fancy layout so all we need to do is get the url of the tweet we want to post.
https://twitter.com/<username>/status/<tweetId>
username
: is provided in .env
tweetId
: is returned through the filteredstream
Compile the typescript by running tsc
Then start it up with npm run start
Test it out on your twitter!