-
Notifications
You must be signed in to change notification settings - Fork 0
/
twitter.js
39 lines (36 loc) · 1.22 KB
/
twitter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
module.exports = (client) => {
const Twit = require('twit');
const config = require("./config.json");
var twitterAccs = [ '2836755090', "1400067733"];
var T = new Twit({
consumer_key: config.consumer_key,
consumer_secret: config.consumer_secret,
access_token: config.access_token,
access_token_secret: config.access_token_secret,
timeout_ms: 60*1000,
strictSSL: true,
});
client.once('ready', () => {
var stream = T.stream('statuses/filter', { follow: twitterAccs });
stream.on('tweet', function (tweet) {
console.log(tweet);
var url = "https://twitter.com/" + tweet.user.screen_name + "/status/" + tweet.id_str;
if (tweet.user.id_str == '2836755090'){
try {
client.channels.cache.get("772097042453364787").send(url)
} catch (error) {
console.error(error);
}
}
if (tweet.user.id_str == '1400067733'){
try {
client.channels.cache.get("772097042453364787").send({
content: url
})
} catch (error) {
console.error(error);
}
}
});
});
}