【发布时间】:2021-01-02 06:48:36
【问题描述】:
我刚开始学习如何在 discord.py 中编写自己的机器人。但是,我遵循了 Youtube 上的教程,使用了完全相同的代码,但它在我的服务器上不起作用。
import discord from discord.ext import commands
client = commands.Bot(command_prefix = '.')
@client.command(pass_context = True)
async def test(ctx):
await ctx.send('Pong!')
@client.event
async def on_ready():
print('Bot is ready')
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('hello'):
await message.channel.send('Hello there.')
@client.event
async def on_member_join(member):
print(f'{member}has joined the server!!')
@client.event
async def on_member_remove(member):
print(f'Seeya,{member}. Oh wait\n can we?')
client.run('NzU1MjI2Mzk1MjM5Nzc2Mjg2.XGGNZA.s2qLVQMONMLqs1f8Zky9wtM6ZDo')
【问题讨论】:
标签: bots discord.py