Is it possible to make a crawler with Twit and is it also possible to output the received data in a Discord channel? Currently I have made a script with both modules and it’s working fine. The console output works for Discord.js and Twit at the same time. I have entered the token for Discord and the several keys for the Twitter API. But my goal is a bit more complex. With twit I need to make a crawler that crawls tweets from twitter accounts in real-time and Discord.js is supposed to output this data in a Discord channel. Does anyone have any idea how to do this? I tried to experiment with the stream function of Twit but couldn’t figure out how it works exactly. It crawled random tweets from any time span. I’m not sure how to configure it. And even if I figured that out I still need to integrate it with Discord.js
Question posted in Twitter API
The official Twitter API documentation can be found here.
The official Twitter API documentation can be found here.
2
Answers
I would do it this way :
stream.on('tweet'
to a response of your discord bot.The simplest way is as follows:
Of course the following assumes that you have Discord and Twitter keys specified in proper environment variables.
NOTE: By default, stream will contains more than user’s own tweets: retweets, replies. You can easily filter them using the following function (not mine, source noted):
For testing purposes I used @Every3Minutes here, as it tweets every 3 minutes, which was nice for my testing.