Recently I saw another question that had a answer but it doesn't fully satisfy me. I would like to use the bot in the usage of /invite [invitelink]
Found this code that works using puppeteer but I would like it instead of setting the url by hand in code to use a var or something. I tried just changing the url to a var called url but that just gives a error
>(node:32664) UnhandledPromiseRejectionWarning: Error: Evaluation failed: ReferenceError: invite is not defined
at __puppeteer_evaluation_script__:3:62
at ExecutionContext._evaluateInternal (E:\Folders\DiscordBot\v2\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:218:19)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async ExecutionContext.evaluate (E:\Folders\DiscordBot\v2\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:107:16)
at async invite4 (E:\Folders\DiscordBot\v2\app.js:91:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:32664) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:32664) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
The code I use is:
const invite = async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://discord.com/');
await page.evaluate(async () => {
const x = new XMLHttpRequest();
x.open('POST', `https://discord.com/api/v6/invites/${invite}`);
x.setRequestHeader('Authorization', token);
x.send();
});
//Maybe good idea to close browser after executing
};
Got the code from here: How do I make a selfbot join a server?
Can anyone help me?