-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
102 lines (94 loc) · 4.45 KB
/
Copy pathapp.js
File metadata and controls
102 lines (94 loc) · 4.45 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
"use strict";
require("dotenv-flow").config();
const http = require(`https`);
const fs = require(`fs`);
const { Client } = require("discord.js-selfbot-v13");
const djs = require('discord.js');
const { guildID, deleteID, editID, attachmentsID, whitelistID } = require("./config.json");
const client = new Client({ checkUpdate: false });
const bot = new djs.Client({ intents: [djs.GatewayIntentBits.Guilds] });
let whitelist = [];
client.once("ready", () => {
console.log(`logged in as ${client.user.tag} in ${client.guilds.cache.size} server(s).`);
client.user.setPresence({ status: "invisible" });
// for attachments
if (!fs.existsSync("./temp")) fs.mkdirSync("./temp");
});
bot.once("ready", () => {
const logServer = bot.guilds.cache.get(guildID);
console.log(`logged in as ${bot.user.tag} in ${logServer.name}(${logServer.id}).`);
// set up log channels
const whitelistChannel = bot.guilds.cache.get(guildID).channels.cache.get(whitelistID);
whitelistChannel.messages.fetch({ limit: 100, cache: false }).then(messages => {
messages.forEach(message => { whitelist.push(message.content); });
});
});
client.on("messageCreate", message => {
if (!message.author) return;
if (message.author.bot) return;
// DOESN'T IGNORE MESSAGES THE USER OF THIS PROGRAM SENDS WITH THE FOLLOWING LINE COMMENTED OUT
// if (message.author.id === client.user.id) return;
// (also useful to comment out if you want to give the bot commands in another channel later)
if (message.guild) {
if (!whitelist.includes(message.guild.id)) return;
} else {
if (!whitelist.includes(message.channel.id)) return;
}
if (message.attachments.size === 0) return;
const log = bot.guilds.cache.get(guildID).channels.cache.get(attachmentsID);
const now = new Date().toLocaleString("en-US", {timeZone: "America/New_York"});
log.send(`Sent by ${message.author.tag}(${message.author.id}) in ${message.channel.name}(${message.channel.id}) at ${now} ET:`).then(() =>
message.attachments.forEach(attachment => {
if (attachment.size <= 25 * 1048576) {
const file = fs.createWriteStream("./temp/" + attachment.name);
const request = http.get(attachment.url, response => {
response.pipe(file);
file.on("finish", () => {
log.send(`${attachment.name} (${attachment.size / 1048576} MB)`).then(() =>
log.send({ files: [{
attachment: "./temp/" + attachment.name,
name: attachment.name
}]
}).then(() => {
fs.unlinkSync("./temp/" + attachment.name);
file.close();
}));
});
});
}
}));
});
client.on("messageDelete", message => {
if (!message.author) return;
if (message.author.bot) return;
// DOESN'T IGNORE MESSAGES THE USER OF THIS PROGRAM SENDS WITH THE FOLLOWING LINE COMMENTED OUT
// if (message.author.id === client.user.id) return;
if (message.guild) {
if (!whitelist.includes(message.guild.id)) return;
} else {
if (!whitelist.includes(message.channel.id)) return;
}
const log = bot.guilds.cache.get(guildID).channels.cache.get(deleteID);
const now = new Date().toLocaleString("en-US", {timeZone: "America/New_York"});
const createdAt = new Date(message.createdAt).toLocaleString("en-US", {timeZone: "America/New_York"});
log.send(`Deleted by ${message.author.tag}(${message.author.id}) in ${message.channel.name}(${message.channel.id}) at ${now} ET and originally sent at ${createdAt} ET:\n${message.content}`.substring(0, 2000));
});
client.on("messageUpdate", (oldMessage, newMessage) => {
if (!oldMessage.author) return;
if (oldMessage.author.bot) return;
// DOESN'T IGNORE MESSAGES THE USER OF THIS PROGRAM SENDS WITH THE FOLLOWING LINE COMMENTED OUT
// if (oldMessage.author.id === client.user.id) return;
if (oldMessage.guild) {
if (!whitelist.includes(oldMessage.guild.id)) return;
} else {
if (!whitelist.includes(oldMessage.channel.id)) return;
}
if (oldMessage.content === newMessage.content) return;
const log = bot.guilds.cache.get(guildID).channels.cache.get(editID);
const now = new Date().toLocaleString("en-US", {timeZone: "America/New_York"});
const createdAt = new Date(oldMessage.createdAt).toLocaleString("en-US", {timeZone: "America/New_York"});
log.send(`Edited by ${oldMessage.author.tag}(${oldMessage.author.id}) in ${oldMessage.channel.name}(${oldMessage.channel.id}) at ${now} ET and originally sent at ${createdAt} ET:\nOld Message:\n${oldMessage.content}`.substring(0, 2000)).then(() =>
log.send(`New Message:\n${newMessage.content}`.substring(0, 2000)));
});
client.login(process.env.CLIENT_TOKEN);
bot.login(process.env.BOT_TOKEN);