这就是我所拥有的:
@client.command(pass_context=True)
@client.event
async def on_member_join(ctx, member):
print(f'{member} has joined a server.')
await ctx.send(f"Hello {member}!")
await ctx.member.send(f"Welcome to the server!")
我需要机器人在加入时发送包含规则和命令列表的私人消息。
请帮忙!
我不知道发生了什么,从一天到第二天,机器人不再向新会员发送欢迎消息。但我终于能够解决它。 我只需添加这两行代码即可。
intents = discord.Intents()
intents.members = True
阅读
import discord
from discord.ext import commands
#try add this
intents=discord.Intents.all()
#if the above don't work, try with this
#intents = discord.Intents()
#intents.members = True
TOKEN = 'your token'
bot=commands.Bot(command_prefix='!',intents=intents)
#Events
@bot.event
async def on_member_join(member):
await member.send('Private message')
@bot.event
async def on_ready():
print('My bot is ready')
bot.run(TOKEN)
@bot.event
async def on_member_join(menbro:discord.Member):
canal = bot.get_channel
await canal.send(f"{menbro.display_name} Entrou no servidor!")
VScode 中的“on_member_join”是深黄色,我不知道该怎么办?