How to use discord python bot with proxy?

谁说胖子不能爱 提交于 2020-12-13 10:49:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!