aiko-chan-ai / discord.js-selfbot-v13

An unofficial discord.js fork for creating selfbots
https://discordjs-self-v13.netlify.app
GNU General Public License v3.0
834 stars 172 forks source link

Multi Selfbots #92

Closed aiko-chan-ai closed 2 years ago

aiko-chan-ai commented 2 years ago

Code example

// list selfbot token (fake) .-.
const tokenSelfbotArray = [
    'MTQzOTA3NzkzNjIwMjQ1MjQ=.fAdjVu.v6hI5uC1zh1U7DPE7Pqzu4DyiPy',
    'NzkyMDMyMjQ3NjI1NDA2NTY5.EpiCU6.Z5sSgT1z1YdfEwZYcNqDXZ1la89',
    'mfa.MTg3NzgxMTczMTYzNzg0ODA=6pn8FCAWoYeSbU9Zug580P6LDlaHFWc7Q6pn8FCAWoYeSbU9Zug580P6LDlaHFWc7Q',
];
// bot token (fake)
const botToken = 'NzM5MTU2MjYyNDAxMzE3NzQy.0sWcSx.0Bm8tlihXKPL5Bg8kFRDrtg7w5L';
let selfbotStarted = 0;
const DiscordBot = require('discord.js');
const DiscordSelfbot = require('discord.js-selfbot-v13');

const botClient = new DiscordBot.Client({
    intents: 32767,
});

botClient.selfBot = new DiscordBot.Collection(); // Collection<id, client>

async function selfbotLogin(client, token) {
    const selfbotClient = new DiscordSelfbot.Client();
    try {
        // add some event like
        selfBotClient
        .once('ready', () => {
            console.info('Login selfbot')
        })
        .on('messageCreate', () => {
            //
        });
        await selfbotClient.login(token);
        client.selfBot.set(selfbotClient.user.id, selfbotClient);
        selfbotStarted++;
        console.log(`${selfbotClient.user.tag} logged in [${selfbotStarted}/${tokenSelfbotArray.length}]`);
    } catch (e) {
        console.error(`Token ${token} is invalid`, e);
    }
}

botClient.once('ready', async () => {
    console.log('Bot is ready!');
    await Promise.all(
        tokenSelfbotArray.map(
            async (token) => await selfbotLogin(botClient, token),
        ),
    );
});

botClient.login(botToken);

Use 1 bot to manage all selfbots If you have any suggestions, discussions or questions, please comment here

gunawan817 commented 2 years ago

How to use messageCreate inside multiple selfbot

aiko-chan-ai commented 2 years ago

How to use messageCreate inside multiple selfbot select selfbot (id)

const selfbot_no_1 = client.selfBot.get('selfbotId')
selfbot_no_1.on("messageCreate", (msg) => {
if(msg.content == 'ping') msg.reply('pong')
})
AchmadJY commented 1 year ago

How to use messageCreate inside multiple selfbot select selfbot (id)

const selfbot_no_1 = client.selfBot.get('selfbotId')
selfbot_no_1.on("messageCreate", (msg) => {
if(msg.content == 'ping') msg.reply('pong')
})

how do you use select id not to cause continuous massages

cuongn265 commented 1 year ago

@aiko-chan-ai does it mean I cannot create self bot client multiple times? can I just put selfbot clients to an array and use as normal

aiko-chan-ai commented 1 year ago

can I just put selfbot clients to an array and use as normal

yep

cuongn265 commented 1 year ago

can I just put selfbot clients to an array and use as normal

yep

ty for the quick response, i'm on a nextjs server, I don't quite understand how login method works. So every API request to my nextjs server will have to login the selfbot again or something else?

aiko-chan-ai commented 1 year ago

ty for the quick response, i'm on a nextjs server, I don't quite understand how login method works. So every API request to my nextjs server will have to login the selfbot again or something else?

wdym?

cuongn265 commented 1 year ago

ty for the quick response, i'm on a nextjs server, I don't quite understand how login method works. So every API request to my nextjs server will have to login the selfbot again or something else?

wdym?

nvm I found that I can do something like this:

    const client = new Client({
      // See other options here
      // https://discordjs-self-v13.netlify.app/#/docs/docs/main/typedef/ClientOptions
      // All partials are loaded automatically
      captchaService: "2captcha",
      captchaKey: process.env.CAPTCHA_KEY,
    });
    client.token = authToken;
    return client;

to not use the ws gateway