简体   繁体   中英

How to make a discord bot go online using discord.py?

I'm trying to make a discord bot. After several tries I still can't get it to go online.

So I'm using a mac and when I ran:

python3 -m pip install -U discord.py

I get a message that says "Requirement already satisfied".

My code:

import discord
from discord.ext import commands
client = commands.Bot(command_prefix = '.')

@client.event
async def on_ready():
  print ("Bot is ready.")
      
client.run('token')

What did I do wrong and how do I make my bot go online?

As nuclio said, I personally think that naming your file "discord.py" is really hard to use, which means it would require more than you think to make your bot run using that name. If you have regenerated your bot token, make sure to update your code with the latest token, if not, your bot will never be online. On my codes, I have an extra line in between the imports and prefix sections. You can give that a try, but I don't think it will make a difference. Reply back to me if you are still having trouble

Always please clarify your questions briefly ie what error you got, how you ran the code, etc.

Check Following Things Wherever You Run A Bot:

  1. You have the correct code, which means you don't find any errors ofc.
  2. You have entered the right Bot Token in your py file.
  3. Saving your bot file with name discord.py is not recommended.
  4. You are in same directory as of the example.py file, and used python3 example.py in terminal.

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