From 82e4dca3e56681115aa72176a5b69e6342f886b0 Mon Sep 17 00:00:00 2001 From: Elysia <71698422+aiko-chan-ai@users.noreply.github.com> Date: Sun, 14 Jan 2024 16:14:06 +0700 Subject: [PATCH] chore: example AddBot --- .eslintrc.json | 3 ++- examples/AddBot.js | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 examples/AddBot.js diff --git a/.eslintrc.json b/.eslintrc.json index 9702974..67f0607 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -14,7 +14,8 @@ "node": true }, "ignorePatterns": [ - "**/src/util/Voice.js" + "**/src/util/Voice.js", + "**/examples/**" ], "rules": { "import/order": [ diff --git a/examples/AddBot.js b/examples/AddBot.js new file mode 100644 index 00000000..1d144e2 --- /dev/null +++ b/examples/AddBot.js @@ -0,0 +1,32 @@ +'use strict'; + +const Captcha = require('2captcha'); +const Discord = require('../src/index'); + +const solver = new Captcha.Solver('<2captcha key>'); + +const client = new Discord.Client({ + captchaSolver: function (captcha, UA) { + return solver + .hcaptcha(captcha.captcha_sitekey, 'discord.com', { + invisible: 1, + userAgent: UA, + data: captcha.captcha_rqdata, + }) + .then(res => res.data); + }, +}); + +client.on('ready', async () => { + console.log('Ready!', client.user.tag); + await client.authorizeURL( + `https://discord.com/api/oauth2/authorize?client_id=289066747443675143&permissions=414501424448&scope=bot%20applications.commands`, + { + guild_id: 'guild id', + permissions: '8', // Admin + authorize: true, + }, + ); +}); + +client.login('token');