discord-twitter-bot
discord-twitter-bot copied to clipboard
A Discord bot that forwards Tweets into your Discord server.
Discord Twitter Bot
A Discord bot that forwards Tweets into your Discord server.
Take note that this bot uses the search API and not the streaming API. This means that the results are not exhaustive nor are they instantaneous. The trade-off is the ability to use powerful search operators to filter the results to your needs.
Twitter Developer Account Setup
Apply for a Twitter developer account in order to access their standard APIs. You will receive the necessary keys and secrets once your account is approved.
Take note of the keys and secrets provided. You will need these in the next section.
Setup
-
Follow the instructions in create-discord-bot.
Don't forget to give your bot the
Manage Webhookspermission! -
Open the
.envfile and add your Twitter keys and secrets:TWITTER_CONSUMER_KEY=PLACEHOLDER TWITTER_CONSUMER_SECRET=PLACEHOLDER TWITTER_ACCESS_TOKEN_KEY=PLACEHOLDER TWITTER_ACCESS_TOKEN_SECRET=PLACEHOLDER -
Download this bot and move the
src-discord-twitter-botfolder into the /src/bots folder from step 1.Run
npm i -s twitter-lite@^0.14.0to install this bot's dependencies. -
Open config.json to configure your own settings:
[ { "channelId": "649020657522180128", "delay": 3600000, "randomDelay": 300000, "embed": true, "spoiler": false, "parameters": { "q": "from:@NoContextWeeb exclude:replies exclude:retweets", "result_type": "recent", "count": 1 } } ]Add as many rules as you want to configure for other channels/servers.
channelIdis the text channel you want tweets to be forwarded to.delay(in milliseconds) is the interval the bot will run the Twitter search query to check for new results.delaydefaults to 15 minutes if not provided.- Take note of search's rate limit of
450 requests per 15 minuteswhen configuring your rules.
- Take note of search's rate limit of
randomDelay(in milliseconds) is the random interval added to thedelay.randomDelaydefaults to 0 minutes if not provided.embedis a boolean that determines whether the tweet's embed is sent (true) or not (false).spoileris a boolean that determines whether the tweet is spoiler tagged (true) or not (false).parametersare provided to the Twitter search endpoint. Reference can be found here: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/search/api-reference/get-search-tweets- The
q(query) parameter allows for powerful search operators. Reference can be found here: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/search/guides/standard-operators
- The
-
npm startto run the bot.
Visit for more help or information!
