【问题标题】:How to send a DM to new members of a discord server using a discord bot (python 3)如何使用不和谐机器人(python 3)向不和谐服务器的新成员发送 DM
【发布时间】:2020-10-19 22:05:50
【问题描述】:

我尝试了几种方法,所有这些方法都不会导致任何错误消息(或者如果他们这样做了,它们很容易修复),但他们仍然没有发送 DM。

我最有信心的方式是:

@client.event
async def on_member_join(member):
    await member.create_dm()
    await member.dm_channel.send(
        f'Hi {member.name}, welcome to my Discord server!'
    )

这可能存在多个问题,但目前我被困在第二行;如果用户加入我的服务器,它实际上并没有激活(我通过直接在它后面推一个打印命令并在我加入服务器时观察输出来测试它)。任何想法,将不胜感激。 :)

哦,是的,我尝试了另一种可行的方法,但我无法到达:how to make discord bot send a new user DM?

【问题讨论】:

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


    【解决方案1】:

    试试这个:

    @client.event
    async def on_member_join(member):
        await member.send('Hi {member.name}, welcome to my Discord server!')
    

    所有这一切都会发送给加入的成员。

    【讨论】:

    • 第二行还是不行。 “async def on_member_join(member):” 仍然没有做任何事情。它只是跳过整个事件,当人们加入时没有捕捉到
    【解决方案2】:

    我已经设法让它工作了,但我仍然不确定什么不起作用,我最好的猜测是我的代码中的其他地方没有正常工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-07-21
      • 2022-10-13
      • 1970-01-01
      • 2021-04-03
      • 2018-03-20
      • 2021-10-30
      • 2021-05-27
      相关资源
      最近更新 更多