-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
60 lines (45 loc) · 1.66 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
import Discord from 'discord.js-selfbot';
import fs from 'node:fs';
const config = JSON.parse(fs.readFileSync('config.json'));
const client = new Discord.Client();
let gdmOne, gdmTwo;
client.once('ready', async () => {
console.log('[E-GDM] Loaded');
gdmOne = await client.channels.fetch(config.groupIDs[0]);
gdmTwo = await client.channels.fetch(config.groupIDs[1]);
await gdmOne.send('[E-GDM] Loaded') && await gdmTwo.send('[E-GDM] Loaded');
});
client.on('message', async (message) => {
if (message.content.startsWith('[E-GDM]')) {
return;
}
if (message.channel.id == config.groupIDs[0]) {
const forwardedMessage = await gdmTwo.send(`[E-GDM] ${message.author.username}: ${message.content}`);
if (message.attachments.size > 0) {
message.attachments.forEach(attachment => {
forwardedMessage.channel.send(attachment.url);
});
}
}
if (message.channel.id == config.groupIDs[1]) {
const forwardedMessage = await gdmOne.send(`[E-GDM] ${message.author.username}: ${message.content}`);
if (message.attachments.size > 0) {
message.attachments.forEach(attachment => {
forwardedMessage.channel.send(attachment.url);
});
}
}
});
async function stop() {
console.log('[E-GDM] Stopped');
await gdmOne.send('[E-GDM] stopping') && await gdmTwo.send('[E-GDM] stopping');
}
client.login(config.token);
process.on('SIGINT', async () => {
await stop();
process.exit();
});
process.on('SIGTERM', async () => {
await stop();
process.exit();
});