问题
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))
回答1:
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.
来源:https://stackoverflow.com/questions/55355342/how-to-use-discord-python-bot-with-proxy