简体   繁体   English

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

[英]Make a Discord bot DM a specific person

I am making a piece of code to annoy my friend but I cannot seem to find a way to DM him specifically.我正在编写一段代码来惹恼我的朋友,但我似乎无法找到专门与他联系的方法。 What am I doing wrong here?我在这里做错了什么?

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

Solution Found!找到解决方案!

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

Replace self.client with whatever your bot is called, as not everyone's will be named client .self.client替换为您的机器人,因为不是每个人都会被命名为client Also removed self.还删除了self. if not inside of a cog, obviously.如果不是在齿轮内,显然。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM