[英]Discord.py welcomer doesn't work and I don't receive any errors. How to solve it?
我不明白為什么我的代碼不起作用......我的意思是,當成員加入服務器時,BOT 沒有做任何事情,我也沒有收到來自終端的任何錯誤。 請幫助我,我很絕望。
import asyncio
import discord
from discord import client, message
from discord.ext import commands
from discord.utils import get
client = commands.Bot(command_prefix="!")
@client.event
async def on_ready():
print(f"{client.user} is now online! ID: {client.user.id}")
activity = discord.Game(name="!help")
await client.change_presence(status=discord.Status.idle, activity=activity)
@client.event
async def on_member_join(ctx, member):
await ctx.send(f'Welcome {member.mention}')
#I made it as simple as possible, but it still doesn't work.
client.run(token="tokentokentokentokentokentoken")
on_member_join
只需要 1 個參數。
此外,您需要啟用Members Intent
才能使其正常工作。
import discord
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix="!", intents=intents)
然后在您的機器人儀表板上啟用它。 有關如何在文檔中執行此操作的更多信息。
discord.on_member_join(member)
文檔只接受一個參數成員。
執行以下代碼
@client.event
async def on_member_join( member):
await member.send(f'Welcome {member.mention}')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.