【发布时间】:2020-01-20 23:13:21
【问题描述】:
如果不和谐频道中的用户发送:
v!test Hello
如何让控制台打印
User#1321: Hello
我不确定如何实现这一点,感谢任何帮助。
【问题讨论】:
标签: python discord discord.py
如果不和谐频道中的用户发送:
v!test Hello
如何让控制台打印
User#1321: Hello
我不确定如何实现这一点,感谢任何帮助。
【问题讨论】:
标签: python discord discord.py
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')
【讨论】: