gresaggr
gresaggr

Reputation: 101

How to use discord python bot with proxy?

Need to use discord bot with proxy (https or socks). For example, proxy is: 192.168.1.1:3125 and proxy autorisation is: proxy_login:proxy_pass

I already try with this example: how to connect a discord bot through proxy but it can't.

client = discord.Client(proxy=USER_PROXY, proxy_auth=aiohttp.BasicAuth(USER_PROXY_LOGIN, USER_PROXY_PASS))

Upvotes: 2

Views: 6251

Answers (2)

Patrick Haugh
Patrick Haugh

Reputation: 61032

The below is for an old version of discord.py, for modern versions refer to Xiao Tan's answer


You need to create a aiohttp.ProxyConnector and pass that as the connector to your Client:

from aiohttp import ProxyConnector, BasicAuth

basic_auth = BasicAuth(USER_PROXY_LOGIN, USER_PROXY_PASS)
connector = ProxyConnector(USER_PROXY, proxy_auth=basic_auth)

cient = discord.Client(connector=connector)

As the question you linked notes, discord.py does not support HTTP proxies, only HTTPS proxies.

Upvotes: 4

Xiao Tan
Xiao Tan

Reputation: 442

For the newest version 1.7.3, There is a proxy parameter on Client class's constructor

all you need is:

client = discord.Client(proxy="http://localhost:7890")

https://discordpy.readthedocs.io/en/stable/api.html#client

Upvotes: 2

Related Questions