【发布时间】:2021-05-11 00:31:49
【问题描述】:
我正在尝试制作一个使用客户端事件(例如 on_member_join)和命令 (@bot.command()) 的 Discord Python Bot。 on_member_join 事件不适用于 @bot.event,但 on_ready 可以正常工作。
代码如下:
import discord
from discord.ext import commands
import os
bot = commands.Bot(command_prefix='$')
@bot.event
async def on_member_join(member):
public = 'welcome, {0.mention}:'.format(member)
await member.guild.system_channel.send(public)
@bot.command()
async def ping(ctx):
await ctx.send('pong :sunglasses:')
bot.run(TOKEN)
如果有人帮助我,我将不胜感激。
【问题讨论】:
-
你定义了意图吗?
标签: python python-3.x discord discord.py