-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from MrBoombastic/slave
v1.5.0
- Loading branch information
Showing
16 changed files
with
575 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
MODE=MEMBERS | ||
GUILD_ID= | ||
CHANNEL_ID= | ||
SPACING=" " | ||
TOKEN= | ||
DELAY=1000 | ||
DICTIONARY=" !\"#$%&'()*+,-./0123456789:;<=>?@[]^_`abcdefghijklmnopqrstuvwxyz{|}~" | ||
DATE_FORMAT="L LTS UTCZ" | ||
DATE_LOCALE=en |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "npm" | ||
target-branch: "niewolnik" | ||
target-branch: "slave" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const {welcome, exit, saveMembers} = require("../../utils"); | ||
const {perms, overlap, bruteforce} = require("../../steps"); | ||
|
||
module.exports = async (client) => { | ||
welcome(client); | ||
|
||
// Getting target | ||
const guild = await client.guilds.cache.get(process.env.GUILD_ID); | ||
if (!guild?.available) { | ||
console.error("ERROR: selected guild is not available!\nAvailable guilds:", client.guilds.cache.map(x => `${x.name} (${x.id})`).join(", ")); | ||
process.exit(1); | ||
} | ||
const channel = await guild.channels.cache.get(process.env.CHANNEL_ID); | ||
if (!channel) { | ||
console.warn("WARNING: selected channel is missing! 'Member list' method will be skipped\nAvailable channels: ", guild.channels.cache.filter(x => x.isText()).map(x => `${x.name} (${x.id})`).join(", ")); | ||
} | ||
|
||
console.log(`Target acquired: ${guild.name} (${channel?.name || "NO CHANNEL"})`); | ||
|
||
// Fetching! | ||
await perms(guild); // Method 1 - fetching with perms | ||
if (channel) await overlap(guild, client); // Method 2 - overlap member list fetching | ||
if (guild.members.cache.size < guild.memberCount) await bruteforce(guild); // Method 3 - brute-force fetching | ||
|
||
// Done! | ||
console.log(`Fetching done! Found ${guild.members.cache.size}/${guild.memberCount} => ${guild.members.cache.size / guild.memberCount * 100}% members.`); | ||
saveMembers(client, guild); | ||
exit(client); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const {downloadFile} = require("../../utils"); | ||
|
||
module.exports = async (client, message) => { | ||
if (message.guildId === process.env.GUILD_ID || process.env.GUILD_ID.toLowerCase() === "all") { | ||
let info = `[DELETED MESSAGE] Guild: ${message.guild.name} Channel: ${message.channel.name} Author: ${message.author?.tag} Bot: ${message.author?.bot}\nCONTENT: ${message.cleanContent}`; | ||
if (message.attachments.size > 0) { | ||
info += `\nMEDIA: ${message.attachments.map(x => x.proxyURL).join(", ")}`; | ||
message.attachments.forEach(x => { | ||
downloadFile(x.proxyURL); | ||
}); | ||
} | ||
client.logger.log(info); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const {downloadFile} = require("../../utils"); | ||
|
||
module.exports = async (client, oldMsg, newMsg) => { | ||
if (oldMsg.guildId === process.env.GUILD_ID || process.env.GUILD_ID.toLowerCase() === "all") { | ||
if (oldMsg.embeds.length === 0 && newMsg.embeds.length > 0) return; //ignoring generating thumbnails for images | ||
let info = `[EDITED MESSAGE] Guild: ${oldMsg.guild.name} Channel: ${oldMsg.channel.name} Author: ${oldMsg.author?.tag} Bot: ${oldMsg.author?.bot} | ||
OLD CONTENT: ${oldMsg.content} | ||
NEW CONTENT: ${newMsg.content}`; | ||
if (oldMsg.attachments.size !== newMsg.attachments.size) { | ||
info += `\nOLD MEDIA: ${oldMsg.attachments.map(x => x.url).join(", ")}`; | ||
info += `\nNEW MEDIA: ${newMsg.attachments.map(x => x.url).join(", ")}`; | ||
// Assuming that user can only remove media from existing message | ||
oldMsg.attachments.forEach(x => { | ||
downloadFile(x.proxyURL); | ||
}); | ||
} | ||
client.logger.log(info); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const log4js = require("log4js"); | ||
const {welcome} = require("../../utils"); | ||
module.exports = async (client) => { | ||
welcome(client); | ||
|
||
// Getting target | ||
const info = process.env.GUILD_ID.toLowerCase() === "all" ? "ALL GUILDS" : await client.guilds.cache.get(process.env.GUILD_ID).name; | ||
console.log(`Target acquired: ${info}`); | ||
|
||
// Set up message logging | ||
log4js.configure({ | ||
appenders: { | ||
watchdog: { | ||
type: "file", | ||
layout: {type: "pattern", pattern: "[%d] %m%n"}, | ||
filename: `logs/watchdog-${process.env.GUILD_ID}.log` | ||
} | ||
}, | ||
categories: {default: {appenders: ["watchdog"], level: "info"}}, | ||
}); | ||
|
||
client.logger = log4js.getLogger("watchdog"); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,45 @@ | ||
// Including libraries | ||
const fs = require("fs"); | ||
const {Client} = require("discord.js-selfbot-v13"); | ||
global.dayjs = require("dayjs"); | ||
dayjs.extend(require("dayjs/plugin/localizedFormat")); | ||
const {saveAndExit, checkConfig, art} = require("./utils.js"); | ||
const {bruteforce, perms, overlap} = require("./steps.js"); | ||
const {checkConfig, exit, saveMembers} = require("./utils.js"); | ||
require('dotenv').config(); | ||
|
||
|
||
// Setting up client | ||
const client = new Client({ | ||
checkUpdate: false, partials: ["GUILD_MEMBER"] | ||
checkUpdate: false, | ||
}); | ||
|
||
// Config and guild are stored here | ||
let config, guild; | ||
|
||
// Config file validation | ||
try { | ||
config = JSON.parse(fs.readFileSync("./config.json")); | ||
} catch (e) { | ||
console.error("ERROR: missing config file!"); | ||
process.exit(1); | ||
} | ||
const configStatus = checkConfig(config); | ||
if (!configStatus.ok) { | ||
console.error(`ERROR: missing '${configStatus.prop}' in config file!`); | ||
const configStatus = checkConfig(); | ||
if (!configStatus.success) { | ||
console.error(`ERROR: wrong config! Reason: ${configStatus.reason}`); | ||
process.exit(1); | ||
} | ||
|
||
// Preparing date formatting | ||
try { | ||
require(`dayjs/locale/${config.dateLocale}`); | ||
dayjs.locale(config.dateLocale); | ||
require(`dayjs/locale/${process.env.DATE_LOCALE}`); | ||
dayjs.locale(process.env.DATE_LOCALE); | ||
} catch (e) { | ||
console.warn(`WARNING: locale '${config.dateLocale}' not found. Using 'en' as fallback.`); | ||
console.warn(`WARNING: locale '${process.env.DATE_LOCALE}' not found. Using 'en' as fallback.`); | ||
dayjs.locale("en"); | ||
} | ||
|
||
// Just informational things | ||
client.on("rateLimit", async (data) => { | ||
console.log(data); | ||
}); | ||
|
||
// When bot is ready | ||
client.on("ready", async () => { | ||
console.log(art); | ||
console.log(`Logged in as ${client.user.tag} (${client.user?.emailAddress || "NO EMAIL"})`); | ||
|
||
// Getting target | ||
guild = await client.guilds.cache.get(config.guildID); | ||
if (!guild?.available) { | ||
console.error("ERROR: selected guild is not available!\nAvailable guilds:", client.guilds.cache.map(x => `${x.name} (${x.id})`).join(", ")); | ||
process.exit(1); | ||
} | ||
const channel = await guild.channels.cache.get(config.channelID); | ||
if (!channel) { | ||
console.warn("WARNING: selected channel is missing! 'Member list' method will be skipped\nAvailable channels: ", guild.channels.cache.map(x => `${x.name} (${x.id})`).join(", ")); | ||
} | ||
|
||
console.log(`Target acquired: ${guild.name} (${channel?.name || "NO CHANNEL"})`); | ||
|
||
// Fetching! | ||
await perms(guild); // Method 1 - fetching with perms | ||
if (channel) await overlap(guild, config, client); // Method 2 - overlap member list fetching | ||
if ((guild.members.cache.size < guild.memberCount) && (guild.members.cache.size !== guild.memberCount)) await bruteforce(guild, config); // Method 3 - brute-force fetching | ||
|
||
// Done! | ||
console.log(`Fetching done! Found ${guild.members.cache.size}/${guild.memberCount} => ${guild.members.cache.size / guild.memberCount * 100}% members.`); | ||
|
||
await saveAndExit(client, config, guild); | ||
}); | ||
const events = { | ||
watchdog: ["messageDelete", "messageUpdate", "ready"], | ||
members: ["ready"] | ||
}; | ||
for (const file of events[process.env.MODE.toLowerCase()]) { | ||
const event = require(`./events/${process.env.MODE.toLowerCase()}/${file}`); | ||
client.on(file, event.bind(null, client)); | ||
} | ||
|
||
process.on("SIGINT", async () => { | ||
console.log("\nStopped upon user's request!"); | ||
await saveAndExit(client, config, guild); | ||
console.log("\nStopping at user's request!"); | ||
if (process.env.MODE.toLowerCase() === "members") saveMembers(client, client.guilds.cache.get(process.env.GUILD_ID)); | ||
exit(client); | ||
}); | ||
|
||
client.login(config.token); | ||
client.login(process.env.TOKEN); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.