[英]How can i send a direct message to a user that executed a command to my discord bot?
So i want to make an minecraft account generator with a discord.py bot.所以我想用 discord.py 机器人制作一个我的世界帐户生成器。 I got almost everything to work but im struggling to make the bot direct message the person that wrote the command ("$minecraft nfa").
我几乎完成了所有工作,但我努力让机器人直接向编写命令的人发送消息(“$ minecraft nfa”)。
I want it so after the user inputs this command, he gets a direct message from my bot that sends him the account details.我想要它,所以在用户输入此命令后,他会从我的机器人那里收到一条直接消息,向他发送帐户详细信息。 Everything works except that part.
除了那部分,一切都有效。 Here is my code:
这是我的代码:
if message.content.startswith("$minecraft nfa"):
author = message.author
minecraft_nfa = open("minecraft_nfa.txt", "r")
minecraft_nfa = minecraft_nfa.readlines()
if message.author == client.user:
return
embed = Embed(
description=('I send you the account {0.name}, check your dms!'.format(author)),
color=0x5CDBF0,
)
embed.set_image(url="https://i.imgur.com/w5dtwgo.png")
embed.set_footer("Accounts provided by y#9999, bot made by rarytud#9999 and y#9999")
await message.channel.send(embed=embed)```
I get this Error:我得到这个错误:
Traceback (most recent call last):
File "C:\Users\luka\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 333, in _run_event
await coro(*args, **kwargs)
File "c:/Users/luka/OneDrive/Desktop/EVERYTHING/Private Sniper2/100 Param,/idk/random/PGSharp/Discord Gen Bot/main.py", line 92, in on_message
await client.send_message(member, random.choice(minecraft_nfa))
AttributeError: 'Client' object has no attribute 'send_message'"```
So i want to make an minecraft account generator with a discord.py bot.所以我想用 discord.py 机器人制作一个我的世界帐户生成器。 I got almost everything to work but im struggling to make the bot direct message the person that wrote the command ("$minecraft nfa").
我几乎完成了所有工作,但我努力让机器人直接向编写命令的人发送消息(“$ minecraft nfa”)。
I want it so after the user inputs this command, he gets a direct message from my bot that sends him the account details.我想要它,所以在用户输入此命令后,他会从我的机器人那里收到一条直接消息,向他发送帐户详细信息。 Everything works except that part.
除了那部分,一切都有效。 Here is my code:
这是我的代码:
if message.content.startswith("$minecraft nfa"):
author = message.author
minecraft_nfa = open("minecraft_nfa.txt", "r")
minecraft_nfa = minecraft_nfa.readlines()
if message.author == client.user:
return
embed = Embed(
description=('I send you the account {0.name}, check your dms!'.format(author)),
color=0x5CDBF0,
)
embed.set_image(url="https://i.imgur.com/w5dtwgo.png")
embed.set_footer("Accounts provided by y#9999, bot made by rarytud#9999 and y#9999")
await message.channel.send(embed=embed)```
I get this Error:我得到这个错误:
Traceback (most recent call last):
File "C:\Users\luka\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 333, in _run_event
await coro(*args, **kwargs)
File "c:/Users/luka/OneDrive/Desktop/EVERYTHING/Private Sniper2/100 Param,/idk/random/PGSharp/Discord Gen Bot/main.py", line 92, in on_message
await client.send_message(member, random.choice(minecraft_nfa))
AttributeError: 'Client' object has no attribute 'send_message'"```
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.