Closed siendomiguel closed 3 years ago
Ready, I got the solution to the problem, I was applying the filter incorrectly, it is not necessary to create a function if it is only going to be used once, as is my case, example:
const twitterClient = new Twitter(twitterConf);
// Specify destination channel ID below
const dest = 'config.channelId';
// Create a stream to follow tweets
const stream = twitterClient.stream('statuses/filter', {
follow: 'config.userId', // user_id
});
stream.on('tweet', tweet => {
if(tweet.retweeted || tweet.retweeted_status || tweet.in_reply_to_status_id || tweet.in_reply_to_user_id || tweet.delete) {
// skip retweets and replies ------- new
return;
}
const twitterMessage = `NEWS!! @here **${tweet.user.name}** acaba de realizar un nuevo tweet :grin: \n\n https://twitter.com/${tweet.user.screen_name}/status/${tweet.id_str}`;
try {
let channel = client.channels.fetch(dest).then(channel => { channel.send(twitterMessage)
}).catch(err => {
console.log(err)
})
} catch (error) {
console.error(error);
}
});
I am trying to apply a filter, so that it only places the tweets of a user and not the retweets, but I still can't get it to work.
This would be the original code
apply a possible solution, but it still does not work