简体   繁体   中英

Discord Bot framework crashes on startup (Python)

been trying to follow a tutorial on a discord bot and every where I've seen the starting framework looks like this:

from imports import *

#link to manage bot

#establishes client for bot
client = commands.Bot(command_prefix = '.')

#create first event, readies the bot for use

@client.event
async def on_ready():
    print("Bot ready to go")

#run bot from token, DO NOT SHARE TOKEN
client.run(token)
    

But when I run it, it immediately crashes. The token is in and correct, I did pip install discord.py, and have import discord and
from discord.ext import commands both in as well. The bot is all in my server on Discord It just won't appear online. Please help!

Please follow these steps and report if you get any crashes or errors.

  • If you haven't already, install C++ build tools, as they are required for discord.py.
  • Run py -3 -m pip install -U discord.py in command prompt (Note this is for windows, if you are using a different OS then you can check the correct install command here )
  • import discord in command prompt just to check it's installed correctly.
  • Make sure you've invited your bot to your server.

After you've done those two steps, run this piece of code that I've written, and don't mix up your client secret and your bot token (I've seen it happen a lot).

import discord
from discord.ext import commands

client = commands.Bot(command_prefix='.')
token = "ENTER-TOKEN-HERE"

@client.event
async def on_ready():
    print("Bot ready to go")


client.run(token)

所以我能够在尝试运行程序时进行屏幕记录,显然有一个ClientConnectorCertificateError所以我找到了一个下载证书的地方: https : ClientConnectorCertificateError (在左栏中下载)和然后将其添加到 chrome 中

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM