Discord Bot on Python 3.8 - python

I want to write a Discord bot that answers ping with pong. But I always get a list of error messages that i don't understand.
My code:
import discord
client = discord.Client()
#client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
#client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$hello'):
await message.channel.send('Hello!')
client.run('Nzk4ODEyMDc5NTgxNTYwODgz.X_6duA.3tjXCaFqhSuj59rbpzB6EEl7C6s')
Result:
Traceback (most recent call last):
File "/Users/kyilmaz/Documents/Phyton/Discord/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 969, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore # noqa
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 1050, in create_connection
transport, protocol = await self._create_connection_transport(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 1080, in _create_connection_transport
await waiter
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/sslproto.py", line 529, in data_received
ssldata, appdata = self._sslpipe.feed_ssldata(data)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/sslproto.py", line 189, in feed_ssldata
self._sslobj.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 944, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/kyilmaz/Documents/Phyton/Discord/rpgbot.py", line 17, in <module>
client.run('Nzk4ODEyMDc5NTgxNTYwODgz.X_6duA.3tjXCaFqhSuj59rbpzB6EEl7C6s')
File "/Users/kyilmaz/Documents/Phyton/Discord/venv/lib/python3.8/site-packages/discord/client.py", line 718, in run
return future.result()
File "/Users/kyilmaz/Documents/Phyton/Discord/venv/lib/python3.8/site-packages/discord/client.py", line 697, in runner
await self.start(*args, **kwargs)
File "/Users/kyilmaz/Documents/Phyton/Discord/venv/lib/python3.8/site-packages/discord/client.py", line 660, in start
await self.login(*args, bot=bot)
File "/Users/kyilmaz/Documents/Phyton/Discord/venv/lib/python3.8/site-packages/discord/client.py", line 509, in login
await self.http.static_login(token.strip(), bot=bot)
File "/Users/kyilmaz/Documents/Phyton/Discord/venv/lib/python3.8/site-packages/discord/http.py", line 293, in static_login
data = await self.request(Route('GET', '/users/#me'))
File "/Users/kyilmaz/Documents/Phyton/Discord/venv/lib/python3.8/site-packages/discord/http.py", line 185, in request
async with self.__session.request(method, url, **kwargs) as r:
File "/Users/kyilmaz/Documents/Phyton/Discord/venv/lib/python3.8/site-packages/aiohttp/client.py", line 1117, in __aenter__
self._resp = await self._coro
File "/Users/kyilmaz/Documents/Phyton/Discord/venv/lib/python3.8/site-packages/aiohttp/client.py", line 520, in _request
conn = await self._connector.connect(
File "/Users/kyilmaz/Documents/Phyton/Discord/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 535, in connect
proto = await self._create_connection(req, traces, timeout)
File "/Users/kyilmaz/Documents/Phyton/Discord/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 892, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
File "/Users/kyilmaz/Documents/Phyton/Discord/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 1051, in _create_direct_connection
raise last_exc
File "/Users/kyilmaz/Documents/Phyton/Discord/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 1020, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
File "/Users/kyilmaz/Documents/Phyton/Discord/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 971, in _wrap_create_connection
raise ClientConnectorCertificateError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discord.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed:unable to get local issuer certificate (_ssl.c:1108)')]
I checked if my Discord Token was right (I regenerated because of security), and was all good.
Thanks for your help in advance!

if message.content.startswith('ping'):
await message.channel.send('pong')
Should be all you have to adjust.
If you need more assistance, you're welcome to DM me on discord.
GrilledCheeseSandies#3267

Related

Receiving a client error message while using the discord api

I am trying to create an admin bot using the discord API. This is the set I have as of yet,
ACCESS_TOKEN = ""
client = discord.Client()
#this identifies when the bot is online and ready to listen for messages
#client.event
async def on_read():
print('Bot is now online and active')
#client.event
async def on_message(message):
if message.author == client.user:
return
await message.channel.send('Hello')
client.run(ACCESS_TOKEN)
When I run it I get a string of errors which I am not sure as to what they mean.
ile "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/connector.py", line 969, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore # noqa
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 1080, in create_connection
transport, protocol = await self._create_connection_transport(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 1110, in _create_connection_transport
await waiter
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/sslproto.py", line 528, in data_received
ssldata, appdata = self._sslpipe.feed_ssldata(data)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/sslproto.py", line 188, in feed_ssldata
self._sslobj.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 974, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/vipashashah/TCMprojects/midterm APIs2.0/DiscordAPI", line 20, in <module>
client.run(' ')
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/client.py", line 723, in run
return future.result()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/client.py", line 702, in runner
await self.start(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/client.py", line 665, in start
await self.login(*args, bot=bot)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/client.py", line 511, in login
await self.http.static_login(token.strip(), bot=bot)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/http.py", line 300, in static_login
data = await self.request(Route('GET', '/users/#me'))
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/http.py", line 192, in request
async with self.__session.request(method, url, **kwargs) as r:
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/client.py", line 1117, in __aenter__
self._resp = await self._coro
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/client.py", line 520, in _request
conn = await self._connector.connect(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/connector.py", line 535, in connect
proto = await self._create_connection(req, traces, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/connector.py", line 892, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/connector.py", line 1051, in _create_direct_connection
raise last_exc
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/connector.py", line 1020, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/connector.py", line 971, in _wrap_create_connection
raise ClientConnectorCertificateError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discord.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')]
I removed my access token for security but everything else is the same. I installed the discord package so not sure what went wrong.
This seems to be a problem related to python 3.10 on MacOS.
Easy solution: go back to python 3.9
Look here for more details:
https://githubhot.com/repo/piekstra/tplink-cloud-api/issues/63

Python Discord example code isn't working

I am trying to use the example code provided on this page:
https://pypi.org/project/discord.py/
I have installed all the packages but I am getting a list of errors:
Traceback (most recent call last):
File "/Users/omrior/PycharmProjects/DiscordBot/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 969, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore # noqa
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 1050, in create_connection
transport, protocol = await self._create_connection_transport(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 1080, in _create_connection_transport
await waiter
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/sslproto.py", line 529, in data_received
ssldata, appdata = self._sslpipe.feed_ssldata(data)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/sslproto.py", line 189, in feed_ssldata
self._sslobj.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 944, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/omrior/PycharmProjects/DiscordBot/recBot.py", line 16, in <module>
client.run('ODEyNDg4NjcyMDEyMjcxNjg2.YDBfCg.MDhTkvacjfCSdETeGtW4weQir7U')
File "/Users/omrior/PycharmProjects/DiscordBot/venv/lib/python3.8/site-packages/discord/client.py", line 718, in run
return future.result()
File "/Users/omrior/PycharmProjects/DiscordBot/venv/lib/python3.8/site-packages/discord/client.py", line 697, in runner
await self.start(*args, **kwargs)
File "/Users/omrior/PycharmProjects/DiscordBot/venv/lib/python3.8/site-packages/discord/client.py", line 660, in start
await self.login(*args, bot=bot)
File "/Users/omrior/PycharmProjects/DiscordBot/venv/lib/python3.8/site-packages/discord/client.py", line 509, in login
await self.http.static_login(token.strip(), bot=bot)
File "/Users/omrior/PycharmProjects/DiscordBot/venv/lib/python3.8/site-packages/discord/http.py", line 293, in static_login
data = await self.request(Route('GET', '/users/#me'))
File "/Users/omrior/PycharmProjects/DiscordBot/venv/lib/python3.8/site-packages/discord/http.py", line 185, in request
async with self.__session.request(method, url, **kwargs) as r:
File "/Users/omrior/PycharmProjects/DiscordBot/venv/lib/python3.8/site-packages/aiohttp/client.py", line 1117, in __aenter__
self._resp = await self._coro
File "/Users/omrior/PycharmProjects/DiscordBot/venv/lib/python3.8/site-packages/aiohttp/client.py", line 520, in _request
conn = await self._connector.connect(
File "/Users/omrior/PycharmProjects/DiscordBot/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 535, in connect
proto = await self._create_connection(req, traces, timeout)
File "/Users/omrior/PycharmProjects/DiscordBot/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 892, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
File "/Users/omrior/PycharmProjects/DiscordBot/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 1051, in _create_direct_connection
raise last_exc
File "/Users/omrior/PycharmProjects/DiscordBot/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 1020, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
File "/Users/omrior/PycharmProjects/DiscordBot/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 971, in _wrap_create_connection
raise ClientConnectorCertificateError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discord.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)')]
I am using Pycharm IDE on MacOS.
I am not sure what is the problem and would appreciate any help.
Thank you very much.
This is a known issue for discord.py
Check the solution on the github issue: https://github.com/Rapptz/discord.py/issues/4159

Discord.py not working when doing client.run()

I've installed discord.py and I have verified that it is the newest version (1.6.0) however once I run the simple code of just running the bot, I get a long string of errors.
The code:
import discord
client = discord.Client()
client.run("***")
The errors:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aiohttp/connector.py", line 969, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore # noqa
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 1081, in create_connection
transport, protocol = await self._create_connection_transport(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 1111, in _create_connection_transport
await waiter
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/sslproto.py", line 528, in data_received
ssldata, appdata = self._sslpipe.feed_ssldata(data)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/sslproto.py", line 188, in feed_ssldata
self._sslobj.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 944, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/yasharnishaburi/Desktop/PokeBot/BaiduBot2.py", line 4, in <module>
client.run("***")
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/client.py", line 718, in run
return future.result()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/client.py", line 697, in runner
await self.start(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/client.py", line 660, in start
await self.login(*args, bot=bot)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/client.py", line 509, in login
await self.http.static_login(token.strip(), bot=bot)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/http.py", line 293, in static_login
data = await self.request(Route('GET', '/users/#me'))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/http.py", line 185, in request
async with self.__session.request(method, url, **kwargs) as r:
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aiohttp/client.py", line 1117, in __aenter__
self._resp = await self._coro
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aiohttp/client.py", line 520, in _request
conn = await self._connector.connect(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aiohttp/connector.py", line 535, in connect
proto = await self._create_connection(req, traces, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aiohttp/connector.py", line 892, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aiohttp/connector.py", line 1051, in _create_direct_connection
raise last_exc
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aiohttp/connector.py", line 1020, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aiohttp/connector.py", line 971, in _wrap_create_connection
raise ClientConnectorCertificateError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discord.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)')]
I've replaced the token in the code and error with stars for obvious reasons.
This is a known issue for discord.py and a solution has been posted on Github regarding this.
Github Issue Link: https://github.com/Rapptz/discord.py/issues/4159

Discord bot doesn´t connect

I have created this little sample code for a discord bot, but when I try to connect I get the following error.
import discord
import os
from discord.ext import commands
from dotenv import load_dotenv
import urllib.request
import json
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
bot = commands.Bot(command_prefix='¿') # prefix del bot
#bot.event
async def on_ready():
await bot.change_presence(activity=discord.Streaming(name="Tutorial", url="http://www.twitch.tv/palmart69"))
print('bot listo')
#bot.command(pass_context=True)
async def ping(ctx):
await ctx.send("Pong!")
#bot.command(name='suma')
async def sumar(ctx, num1, num2):
response = int(num1) + int(num2)
await ctx.send(response)
bot.run(TOKEN)
--------ERROR------------------
Traceback (most recent call last):
File "C:\Users\Alvaro\PycharmProjects\bot-pruebas\venv\lib\site-packages\aiohttp\connector.py", line 969, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore # noqa
File "C:\Users\Alvaro\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 1081, in create_connection
transport, protocol = await self._create_connection_transport(
File "C:\Users\Alvaro\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 1111, in _create_connection_transport
await waiter
File "C:\Users\Alvaro\AppData\Local\Programs\Python\Python39\lib\asyncio\sslproto.py", line 528, in data_received
ssldata, appdata = self._sslpipe.feed_ssldata(data)
File "C:\Users\Alvaro\AppData\Local\Programs\Python\Python39\lib\asyncio\sslproto.py", line 188, in feed_ssldata
self._sslobj.do_handshake()
File "C:\Users\Alvaro\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 944, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1123)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Alvaro\PycharmProjects\bot-pruebas\main.py", line 31, in <module>
bot.run(TOKEN)
File "C:\Users\Alvaro\PycharmProjects\bot-pruebas\venv\lib\site-packages\discord\client.py", line 718, in run
return future.result()
File "C:\Users\Alvaro\PycharmProjects\bot-pruebas\venv\lib\site-packages\discord\client.py", line 697, in runner
await self.start(*args, **kwargs)
File "C:\Users\Alvaro\PycharmProjects\bot-pruebas\venv\lib\site-packages\discord\client.py", line 660, in start
await self.login(*args, bot=bot)
File "C:\Users\Alvaro\PycharmProjects\bot-pruebas\venv\lib\site-packages\discord\client.py", line 509, in login
await self.http.static_login(token.strip(), bot=bot)
File "C:\Users\Alvaro\PycharmProjects\bot-pruebas\venv\lib\site-packages\discord\http.py", line 293, in static_login
data = await self.request(Route('GET', '/users/#me'))
File "C:\Users\Alvaro\PycharmProjects\bot-pruebas\venv\lib\site-packages\discord\http.py", line 185, in request
async with self.__session.request(method, url, **kwargs) as r:
File "C:\Users\Alvaro\PycharmProjects\bot-pruebas\venv\lib\site-packages\aiohttp\client.py", line 1117, in __aenter__
self._resp = await self._coro
File "C:\Users\Alvaro\PycharmProjects\bot-pruebas\venv\lib\site-packages\aiohttp\client.py", line 520, in _request
conn = await self._connector.connect(
File "C:\Users\Alvaro\PycharmProjects\bot-pruebas\venv\lib\site-packages\aiohttp\connector.py", line 535, in connect
proto = await self._create_connection(req, traces, timeout)
File "C:\Users\Alvaro\PycharmProjects\bot-pruebas\venv\lib\site-packages\aiohttp\connector.py", line 892, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
File "C:\Users\Alvaro\PycharmProjects\bot-pruebas\venv\lib\site-packages\aiohttp\connector.py", line 1051, in _create_direct_connection
raise last_exc
File "C:\Users\Alvaro\PycharmProjects\bot-pruebas\venv\lib\site-packages\aiohttp\connector.py", line 1020, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
File "C:\Users\Alvaro\PycharmProjects\bot-pruebas\venv\lib\site-packages\aiohttp\connector.py", line 971, in _wrap_create_connection
raise ClientConnectorCertificateError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discord.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1123)')]
Process finished with exit code 1
I have tried several things that I have seen on different posts (such as installing certificate). I´m new to this bot world so I would really appreciate a bit of help with this. Thanks before anything.
I´ve finally solved the problem with this(downloading a new certificate and installing it).

My discord bot have a error "Traceback (most recent call last):"

I have error with my discord bot
My discord bot error look like this: I run in iTerm2 and error looks like this
And picture is my code
[The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "bot.py", line 14, in <module>
client.run('BOT TOKEN')
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/client.py", line 640, in run
return future.result()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/client.py", line 621, in runner
await self.start(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/client.py", line 584, in start
await self.login(*args, bot=bot)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/client.py", line 442, in login
await self.http.static_login(token.strip(), bot=bot)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/http.py", line 261, in static_login
data = await self.request(Route('GET', '/users/#me'))
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/http.py", line 165, in request
async with self.__session.request(method, url, **kwargs) as r:
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/aiohttp/client.py", line 1012, in __aenter__
self._resp = await self._coro
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/aiohttp/client.py", line 480, in _request
conn = await self._connector.connect(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/aiohttp/connector.py", line 523, in connect
proto = await self._create_connection(req, traces, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/aiohttp/connector.py", line 858, in _create_connection
_, proto = await self._create_direct_connection(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/aiohttp/connector.py", line 1004, in _create_direct_connection
raise last_exc
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/aiohttp/connector.py", line 980, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/aiohttp/connector.py", line 938, in _wrap_create_connection
raise ClientConnectorCertificateError(
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discordapp.com:443 ssl:True \[SSLCertVerificationError: (1, '\[SSL: CERTIFICATE_VERIFY_FAILED\] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')\]][1]
Well first of all you just leaked your bot token, but don't worry discord should have generated a new token so go grab that. If that doesn't already fix it, you could show us the code. And next time remove your bot token before you post here.

Categories

Resources