0

I want my selfbot to join servers by an invite by using a command such as /summon [invite].

I have tried to use the accept invite function but it didn't seem to be working.

client.accept_invite()

It doesn't return any errors or anything.

Liam
  • 27,717
  • 28
  • 128
  • 190
Surve
  • 79
  • 1
  • 1
  • 8

6 Answers6

7

A quick look in the Networking tab on the Discord app shows a request made when attempting to join a server. You can manually use this request to try and join a server.

You can have a python bot join a server by sending a POST request to https://discordapp.com/api/v6/invites/dank?inputValue=SERVER_JOIN_STR&with_counts=true.

You have to also set the authorization header to your token. an example would look like:

import requests
requests.post("https://discordapp.com/api/v6/invites/SERVER_JOIN_STR",headers={'authorization':'TOKEN'})

Remember to use ethically, and hope it helps.

coffee
  • 159
  • 1
  • 5
2

You can't, there is no method to accept any sort of invite under Client object.

And I would suppose this is by design, as the reason is stated in the comments of one of the answer here.

...Because this would allow bots to "randomly" join guilds. So long as the bot has access to an invite link it would be able to accept and get into any guild. Even with basic read message permissions this means that all conversation within that guild could now be logged unknowingly ...

TLDR; To prevent malicious usage of bots.

Example:
A bot-creator made 10 bots, used an accept_invite method to invite them into a victim server. Then coded them all to start spamming in every chat of the targeted server.

WQYeo
  • 3,973
  • 2
  • 17
  • 26
1

You have to make an XMLHttp request to discord, with the header authorization, as coffee mentioned. It would look something like this:

const x = new XMLHttpRequest();
x.open('POST', 'https://discordapp.com/api/v6/invites/invitecode');
x.setRequestHeader('Authorization', 'user-token');
x.send();

However, this does not work because of CORS, which prevents cross site scripting (XSS). Basically you have to execute this from the URL https://discordapp.com. The npm module Puppeteer excels at doing this.

Now, while using Puppeteer, your code would look like this:

const puppeteer = require('puppeteer');

const invite = async () => {
    const browser = await puppeteer.launch();
    const page = await browser.newPage();
    await page.goto('https://discordapp.com/');
    await page.evaluate(async () => {
        const x = new XMLHttpRequest();
        x.open('POST', 'https://discordapp.com/api/v6/invites/invitecode');
        x.setRequestHeader('Authorization', 'user-token');
        x.send();
    });
   //Maybe good idea to close browser after executing
};
invite();
ßrilliant
  • 144
  • 1
  • 11
  • Thanks for the updated javascript answer, for some reason i replied using python. My bad. – coffee Apr 13 '20 at 15:55
  • No problem. Do you still have this problem? Or did you move on after 8 months? xD – ßrilliant Apr 13 '20 at 18:56
  • I realized how dumb I was and could just use the native 'https' module built into Node.js and make a post request THAT way. However, Discord changed their hostname to discord.com, rendering some older selfbots useless. I gave up on making a selfbot though, as I was just risking on getting my account banned. I use Discord everyday and would not like to pay for a VPN just to use Discord. Though the idea seems cool and all, it is totally not worth it in the long run. – ßrilliant May 11 '20 at 11:34
1

Going along the XMLHttp thing, here is a function I made to call it externally (from any site) and what you'd do for auto joining a server.

function discordAPI(authToken,apiEndpoint,JSONparams,type="GET") {
var xhr=new XMLHttpRequest()
xhr.open(type,"https://discord.com/api/v8"+apiEndpoint,true)
xhr.setRequestHeader('Content-Type','application/json')
xhr.setRequestHeader('Authorization',authToken)
xhr.send(JSON.stringify(JSONparams))}

Using it to auto join: discordAPI("your token here","/invites/your invite code here","","POST")

0
client.acceptInvite(invite_code)
β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83
  • 8
    While this code may answer the question, providing additional context regarding why and/or how this code answers the question improves its long-term value. – β.εηοιτ.βε May 22 '20 at 18:53
-3

here

const axios = require('axios').default
        axios({
            method: 'POST',
            url: `https://discord.com/api/invite/${invite}`,//invite here 
            headers:  
            {
            'Authorization': token //user token here
            }
        })
  • 2
    Please give us some more explanation about your solution. Where does the code comes from? How it is possible to integrate your example snipped? Explain us what the code realy does. – Marcel Zebrowski Nov 16 '20 at 20:55