Files
discord.js-selfbot/examples/Proxy.js

34 lines
856 B
JavaScript
Raw Normal View History

2024-01-15 17:53:39 +07:00
'use strict';
const Discord = require('../src/index');
const { ProxyAgent } = require('proxy-agent');
2024-07-22 21:29:16 +07:00
const proxy = new ProxyAgent({
getProxyForUrl: function () {
return '<any proxy>';
},
});
2024-01-15 17:53:39 +07:00
const client = new Discord.Client({
ws: {
agent: proxy, // WebSocket Proxy
2025-03-02 18:28:47 +07:00
// Do not use the `proxy` option if you don't need to use the WebSocket Proxy
2024-01-15 17:53:39 +07:00
},
http: {
// API Proxy
// Read more: https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md
// agent: ProxyAgentOptions
agent: 'my.proxy.server',
// or new URL('my.proxy.server')
// or { uri: 'my.proxy.server' }
2024-01-15 17:53:39 +07:00
},
});
// So if you only need to use the API Proxy (for the purpose of saving data), you don't need to install `proxy-agent`.
2024-01-15 17:53:39 +07:00
client.on('ready', async () => {
console.log('Ready!', client.user.tag);
});
client.login('token');