使 Discord 机器人 DM 成为特定的人

时间:2021-01-06 00:44:55

标签: python discord discord.py

我正在编写一段代码来惹恼我的朋友,但我似乎无法找到专门向他发送消息的方法。我在这里做错了什么?

import random
from random import choice
@commands.command()
    async def annoy(self,ctx):
        friend_id=#id number 123243 etc
        responses=["a","b","C"]
        await ctx.send("He has been notified.")
        await friend_id.send(random.choice(responses))

1 个答案:

答案 0 :(得分:0)

找到解决方案!

friend_id=self.client.get_user(#Friend's ID)
await friend_id.send("Message")

self.client 替换为您的机器人的名称,因为并非每个人的机器人都将被命名为 client。 显然,如果不在齿轮内部,也删除了 self.