forked from tadeokondrak/AvoidBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
44 lines (35 loc) · 1.09 KB
/
main.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
40
41
42
43
44
'use strict';
/**
* main.js -- Program entry point.
*/
const DiscordJS = require('discord.js');
const Snoowrap = require('snoowrap');
const Snoostorm = require('snoostorm');
const config = require('./config.json');
const avoid5discord = require('./lib/avoid5-discord.js');
const avoid5reddit = require('./lib/avoid5-reddit.js');
const Discord = new DiscordJS.Client();
const Reddit = new Snoowrap(config.reddit.credentials);
const RedditStream = new Snoostorm(Reddit);
global.config = config;
Discord.login(config.discord.token);
Discord.on('ready', () => {
console.log('Bot started.');
});
Discord.on('message', avoid5discord.handleMessage);
var commentStream = RedditStream.CommentStream({
'subreddit': config.reddit.subreddit,
'results': 10,
'pollTime': 5000
});
var submissionStream = RedditStream.SubmissionStream({
'subreddit': config.reddit.subreddit,
'results': 10,
'pollTime': 5000
});
commentStream.on('comment', function (post) {
avoid5reddit.handlePost(post, 'comment');
});
submissionStream.on('submission', function (post) {
avoid5reddit.handlePost(post, 'submission');
});