让Discord机器人DM成为一个特定的人



我正在编写一段代码来惹恼我的朋友,但我似乎找不到具体的方法来DM他。我在这里做错了什么?

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))

找到解决方案!

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

self.client替换为你的机器人程序的名称,因为并不是每个人的机器人程序都会被命名为client。显然,如果不在齿轮内部,也会移除self.

相关内容

最新更新