-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetMessages.js
56 lines (51 loc) · 1.63 KB
/
getMessages.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
const systemglobal = require('./config.json');
const eris = require('eris');
const colors = require('colors');
const discordClient = new eris.CommandClient(systemglobal.DiscordToken, {
compress: true,
restMode: true,
}, {
name: "Gotcha",
description: "Message Monitoring System",
owner: "Yukimi Kazari",
restMode: true,
});
let init = 0;
let selfstatic = {};
discordClient.on("ready", () => {
console.log("Connected successfully to Discord!");
discordClient.getSelf()
.then(function(data) {
selfstatic = data
console.log(`Using Account: ${selfstatic.username} (${selfstatic.id})`)
})
.catch((er) => {
console.error("Error getting self identification, this is a major issue".bgRed)
console.error(er)
});
discordClient.getMessages(process.argv[2], 100)
.then((messages) => {
messages.forEach((message) => {
console.log(`${message.id} "${message.content}"`)
if (message.attachments && message.attachments.length > 0) {
message.attachments.forEach((attachment) => {
console.log(`Attachment: ${attachment.url}`)
})
}
})
})
.then(() => {
console.log('Finished processing channel!')
process.exit(0)
})
.catch((err) => {
console.error(err);
process.exit(1);
})
});
discordClient.on("error", (err) => {
console.error("Shard Error, Rebooting...")
console.error(err)
discordClient.connect()
});
discordClient.connect();