Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track specific users tweets Twitter-Discord-Bot #357

Open
c0d3high opened this issue Dec 2, 2021 · 0 comments
Open

Track specific users tweets Twitter-Discord-Bot #357

c0d3high opened this issue Dec 2, 2021 · 0 comments

Comments

@c0d3high
Copy link

c0d3high commented Dec 2, 2021

Hi,
I am trying to follow a specific twitter ID and track tweets containing certain keywords.

require('dotenv').config()
const Twit = require('twit')
const Discord = require('discord.js');
const client = new Discord.Client();


var T = new Twit({
  consumer_key:         process.env.TWITTER_CONSUMER_KEY,
  consumer_secret:      process.env.TWITTER_CONSUMER_SECRET,
  access_token:         process.env.TWITTER_ACCESS_TOKEN,
  access_token_secret:  process.env.TWITTER_ACCESS_TOKEN_SECRET,
  timeout_ms:           60*1000,  // optional HTTP request timeout to apply to all requests.
  strictSSL:            true,     // optional - requires SSL certificates to be valid.
})
client.login(process.env.DISCORD_TOKEN3);
client.once('ready', () => {
  var stream = T.stream('statuses/filter',  follow= [process.env.TWITTER_USER_ID] , track= ['hi'] ) 

  stream.on('tweet', function (tweet) {
  
    //...
    var url = "https://twitter.com/" + tweet.user.screen_name + "/status/" + tweet.id_str;
    try {
        let channel = client.channels.fetch(process.env.DISCORD_CHANNEL_ID).then(channel => {
          channel.send(url)
        }).catch(err => {
          console.log(err)
        })
    } catch (error) {
            console.error(error);
    }
  })
  })
@c0d3high c0d3high changed the title Track specific users tweets Track specific users tweets Twitter-Discord-Bot Dec 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant