Trying to create a python Discord bot

Asked

Viewed 578 times

-1

Hello! I was programming a bot in python with the following command

 import discord
from discord.ext import commands

client = commands.Bot(command_prefix = '-')

@client.event
async def on_ready():
    print('Josefino está online!')

client.run('minha token')

instead of appearing "Josefino is online!" in Shell

This huge code appeared:

Traceback (most recent call last):
  File "C:/JosefinoBot(agora com py)/JosefinoBot.py", line 10, in <module>
    client.run('NzMyOTg4NTY0NzE5MTQwOTE3.XxDUqA.u6db3PwcDrp2-1UQK89-g9Ukw0E')
  File "C:\Users\Daniel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 640, in run
    return future.result()
  File "C:\Users\Daniel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 621, in runner
    await self.start(*args, **kwargs)
  File "C:\Users\Daniel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 584, in start
    await self.login(*args, bot=bot)
  File "C:\Users\Daniel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 442, in login
    await self.http.static_login(token.strip(), bot=bot)
  File "C:\Users\Daniel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\http.py", line 261, in static_login
    data = await self.request(Route('GET', '/users/@me'))
  File "C:\Users\Daniel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\http.py", line 165, in request
    async with self.__session.request(method, url, **kwargs) as r:
  File "C:\Users\Daniel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aiohttp\client.py", line 1012, in __aenter__
    self._resp = await self._coro
  File "C:\Users\Daniel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aiohttp\client.py", line 480, in _request
    conn = await self._connector.connect(
  File "C:\Users\Daniel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aiohttp\connector.py", line 523, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "C:\Users\Daniel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aiohttp\connector.py", line 858, in _create_connection
    _, proto = await self._create_direct_connection(
  File "C:\Users\Daniel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aiohttp\connector.py", line 1004, in _create_direct_connection
    raise last_exc
  File "C:\Users\Daniel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aiohttp\connector.py", line 980, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
  File "C:\Users\Daniel\AppData\Local\Programs\Python\Python38-32\lib\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: certificate has expired (_ssl.c:1123)')]

What do I do? I am a Newbie in programming!

I appreciate the help.

  • It seems to me that the program failed to connect with the Discord server, but I say this looking very close, in fact it may be something else. If you’ve never programmed before, learning to code by creating a bot can provide a bit of a hard learning curve. I recommend you learn the basics of programming before, and when you are already with a better notion, resume this project. There are several free materials for introduction to programming with Python on the internet of great quality, see the course of Professor Gustavo Guanabara on Youtube and the site Automate The Boring Stuff With Python.

1 answer

0

I had this same problem, the only way I could solve was by installing a certificate(?) on my computer.

You can download it here: https://crt.sh/? id=2835394

The download button is half hidden but is here: onde encontrar o link de download

Browser other questions tagged

You are not signed in. Login or sign up in order to post.