Python Discord Bot 不会在成员加入时发送私人消息

时间:2021-03-08 18:14:10

标签: python python-3.x discord discord.py

好的,所以我希望我的机器人向加入我的 Discord 服务器的每个人发送一个 PM,在查看了 Stackoverflow 和文档后,我想不出这不能按预期工作的原因。没有错误行或类似内容。

import discord
import os
import requests
import json
import random
from discord.ext import commands
import ffmpeg

bot = commands.Bot(command_prefix='§')

@bot.event
async def on_ready():
    print('Logged in as')
    print(bot.user.name)
    print(bot.user.id)
    print('------')

@bot.event
async def on_member_join(ctx):
    member = ctx.author
    await member.send("Dies ist ein Test, begeben Sie sich in Deckung!")


bot.run(os.getenv("TOKEN"))

1 个答案:

答案 0 :(得分:2)

您需要 Member-Intent 才能触发。

函数参数也是 member,而不是 docs 中的 ctx

查看 documentation 以了解 Intent 的基本用法。