说
client = discord.Client()
你制作了一个Discord客户端,当然它是在线的(如果它甚至不是在线的,告诉我),你制作了一个Discord bot
bot = commands.Bot(command_prefix='!')
. discord bot不会运行,只有discord客户端会运行,因为您只使用
client.run(TOKEN)
. 因此,快速预览一下您的代码应该是什么,并希望能够工作:
import discord #import all the necessary modules
from discord import Game
from discord.ext import commands
bot = commands.Bot(command_prefix='!') #define command decorator
@bot.command(pass_context=True) #define the first command and set prefix to '!'
async def testt(ctx):
await ctx.send('Hello!!')
@bot.event #print that the bot is ready to make sure that it actually logged on
async def on_ready():
print('Logged in as:')
print(bot.user.name)
await bot.change_presence(game=Game(name="in rain ¬ !jhelp"))
bot.run(TOKEN) #run the client using using my bot's token