-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
66 lines (57 loc) · 2.33 KB
/
index.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const Eris = require('eris');
const CatLoggr = require('cat-loggr');
const fs = require('fs');
const path = require('path');
const config = require('./config');
const { MongoClient } = require('mongodb');
const loggr = new CatLoggr();
loggr.info('Connecting to Mongo...');
MongoClient.connect('mongodb://localhost', { useNewUrlParser: true }).then(conn => {
let db = conn.db('bloblogs');
loggr.info('Done.');
loggr.info('Getting the blobs...');
const blobs = fs.readdirSync('blobs');
loggr.info('Blobs got!');
const bot = new Eris.CommandClient(config.token, { maxShards: 'auto' }, { description: 'Your not-so-mundane logger bot!\nWebsite: https://bloblogs.club/', owner: 'ZeroIdea Development', prefix: ['blob ', 'b!', '@mention '] });
bot.on('ready', async () => {
loggr.info('Bot is ready!');
let blob64 = Buffer.from(fs.readFileSync(path.join('blobs', 'b1nzyblob2.png'))).toString('base64');
try {
await bot.editSelf({
avatar: 'data:image/png;base64,' + blob64
});
loggr.info('Avatar reset.');
} catch (e) {
loggr.error('Failed resetting avatar.', e);
}
await bot.editStatus({
type: 3,
name: 'logs | blob help | https://bloblogs.club | b1nzyblob2'
});
loggr.info('Status updated.');
});
require('./commands')(bot, loggr, db);
loggr.info('Commands loaded.');
require('./events')(bot, loggr, db);
loggr.info('Events loaded.');
require('./web/server')(bot, loggr, db);
loggr.info('Server loaded.')
loggr.init('Here we go!');
bot.connect();
setInterval(async () => {
try {
let blob = blobs[Math.floor(Math.random() * blobs.length)];
let blob64 = Buffer.from(fs.readFileSync(path.join('blobs', blob))).toString('base64');
await bot.editSelf({
avatar: 'data:image/png;base64,' + blob64
});
await bot.editStatus({
type: 3,
name: 'logs | blob help | https://bloblogs.club | ' + blob.substring(0, blob.length - 4)
});
loggr.info('Avatar changed. New avatar is ' + blob.substring(0, blob.length - 4));
} catch (e) {
loggr.error('Error while editing avatar! :(', e);
}
}, 30 * 1000 * 60);
});