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.
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.
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.
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.
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();
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")
client.acceptInvite(invite_code)
here
const axios = require('axios').default
axios({
method: 'POST',
url: `https://discord.com/api/invite/${invite}`,//invite here
headers:
{
'Authorization': token //user token here
}
})