Skip to content

Commit

Permalink
link leaker shit
Browse files Browse the repository at this point in the history
  • Loading branch information
skysthelimitt committed Jan 13, 2024
1 parent 776b9b8 commit 6123ac2
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,6 @@ dist
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
.pnp.*

leakers.json
60 changes: 60 additions & 0 deletions commands/moderation/linkLeakerChecker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
const { EmbedBuilder, SlashCommandBuilder, PermissionsBitField } = require("discord.js");
const { logs_channel } = require("../../config.json");
const fs = require("fs");

module.exports = {
data: new SlashCommandBuilder().setName("linkleakerchecker").setDescription("Checks if a user is a known link leaker"),
async execute(interaction) {
try {
if (!interaction.channel.permissionsFor(interaction.user).has(PermissionsBitField.Flags.ManageRoles)) {
await interaction.reply({ content: "You do not have the correct permissions.", ephemeral: true });
return;
}
const client = interaction.client;
let members = await interaction.guild.members.fetch();
const { mtimeMs } = fs.statSync("leakers.json");
if (Date.now() - mtimeMs > 43200000) {
const url = "https://leakersapi.rare1k.dev/ids";

https.get(url, (res) => {
const path = "leakers.json";
const writeStream = fs.createWriteStream(path);

res.pipe(writeStream);

writeStream.on("finish", () => {
writeStream.close();
});
});
}
let leakers = fs.readFileSync("leakers.json", { encoding: "utf8", flag: "r" });
leakers = JSON.parse(leakers);
let foundLeakers = [];
for (let i = 0; i < leakers.length; i++) {
foundLeakers.push([leakers[i], false, false]);
}
members.forEach((member) => {
if (leakers.includes(member.user.id)) {
foundLeakers[leakers.indexOf(member.user.id)][1] = true;
if(!member.roles.cache.some(role => role.name === 'link leakers')) {
foundLeakers[leakers.indexOf(member.user.id)][2] = true;
const leak = interaction.guild.members.cache.get(member.user.id);
let leakerRole = interaction.guild.roles.cache.find((role) => role.name === "link leakers");
//leak.roles.add(leakerRole);
const logsChannel = interaction.client.channels.cache.get(logs_channel.toString());
logsChannel.send(`${member.user.tag} was detected as a link leaker.`);
}
}
});
let embedDesc = "Results:\nUser - Found - Role Added\n";
for(let i = 0; i < foundLeakers.length; i++) {
embedDesc += `<@${foundLeakers[i][0]}> - ${foundLeakers[i][1]} - ${foundLeakers[i][2]}\n`;
}
let leakEmbed = new EmbedBuilder().setTitle("Link Leakers").setDescription(embedDesc);
await interaction.reply({ embeds: [leakEmbed] });
} catch (error) {
console.error(error);
await interaction.reply({ content: "There was an error", ephemeral: true });
}
},
};
35 changes: 35 additions & 0 deletions events/guildMemberAdd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const { Events } = require("discord.js");
const https = require("https");
const fs = require("fs");
const { logs_channel } = require("../config.json");

module.exports = {
name: Events.GuildMemberAdd,
async execute(interaction) {
console.log(interaction.user.id + " joined the server.");
const { mtimeMs } = fs.statSync("leakers.json");
if (Date.now() - mtimeMs > 43200000) {
const url = "https://leakersapi.rare1k.dev/ids";

https.get(url, (res) => {
const path = "leakers.json";
const writeStream = fs.createWriteStream(path);

res.pipe(writeStream);

writeStream.on("finish", () => {
writeStream.close();
});
});
}
let leakers = fs.readFileSync("leakers.json", { encoding: "utf8", flag: "r" });
leakers = JSON.parse(leakers);
if (leakers.includes(interaction.user.id)) {
const leak = interaction.guild.members.cache.get(interaction.user.id);
let leakerRole = interaction.guild.roles.cache.find((role) => role.name === "link leakers");
leak.roles.add(leakerRole);
const logsChannel = interaction.client.channels.cache.get(logs_channel.toString());
await logsChannel.send(`Known link leaker ${interaction.user.tag} joined the server.`);
}
},
};
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const fs = require("node:fs");
const path = require("node:path");
const { Client, Collection, GatewayIntentBits, Events } = require("discord.js");
const { token, widgets, logs_channel, links, dispenser_logs } = require("./config.json");
const client = new Client({ intents: ["Guilds", "GuildMessages", "MessageContent"], allowedMentions: { everyone: [false], roles: [false] } });
const client = new Client({ intents: ["Guilds", "GuildMessages", "GuildMembers", "MessageContent"], allowedMentions: { everyone: [false], roles: [false] } });
const Sequelize = require("sequelize");
const level = new Sequelize("database", "user", "password", {
host: "localhost",
Expand Down

0 comments on commit 6123ac2

Please sign in to comment.