-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
776b9b8
commit 6123ac2
Showing
4 changed files
with
99 additions
and
2 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 |
---|---|---|
|
@@ -131,4 +131,6 @@ dist | |
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
.pnp.* | ||
|
||
leakers.json |
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,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 }); | ||
} | ||
}, | ||
}; |
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,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.`); | ||
} | ||
}, | ||
}; |
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