[英]How to get the sent message when a command is executed Discord.py
如果不和谐频道中的用户发送:
v!test Hello
我怎样才能让控制台打印
User#1321: Hello
我不确定如何实现这一点,任何帮助表示赞赏。
import discord # using discord.py
client = discord.Client() # creating a client instance
@client.event # decorator to register function in the client events
async def on_message(message): # this function gets called every time the client receives a message
split_message = message.content.split(' ') # split the message into parts
prefix = split_message[0]
if prefix != 'v!test': # if the prefix doesn't match, we stop
return
rest = ' '.join(split_message[0:]) # this is everything except your v!test prefix
print(f'{str(message.author)}: {rest}')
client.run('your_token')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.