[英]How do I send dms to a specific person.Discord.py
When my bot comes online I want it to dm me but it wont work.当我的机器人上线时,我希望它给我发消息,但它不起作用。 Heres the code.这是代码。
@client.event
async def on_ready():
user = client.get_user(id)
await user.send('bot online')
It says nonetype has no attribute send
它说nonetype has no attribute send
@client.event
async def on_ready():
channel = await member.create_dm()
await channel.send("Bot is Online")
You have to make a dm through a channel not through a user您必须通过渠道而不是通过用户进行 dm
You can use get_member
command to do this.您可以使用get_member
命令来执行此操作。 If you want the bot to DM you specifically, you need to know your user ID, then inser it to a variable.如果您希望机器人专门向您发送消息,您需要知道您的用户 ID,然后将其插入到变量中。 Here is how you can define a simple command to DM someone ( for example you ) on bot startup:以下是如何在机器人启动时定义一个简单的命令来 DM 某人(例如你):
@client.event
async def on_ready():
yourID = # Enter your ID here...
discordUser = client.get_user(yourID)
await discordUser.send('Bot online.')
Just in case you're not sure about how to get your ID, you can check out how to get an ID .万一您不确定如何获取 ID,您可以查看如何获取 ID 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.