【发布时间】:2020-11-29 03:14:14
【问题描述】:
我正在使用discord.py 创建一个不和谐机器人,它的主要功能是在给出命令时输入一个故事。 只有两个命令:一个是帮助功能,另一个是开始故事。寻求帮助的命令是r!help,而开始故事的命令是r!start,但由于某种原因,bot 似乎没有识别出r!help 已由用户发送并且只响应@987654326 @. 下面是我的这些事件的代码。
import discord
client = discord.Client()
@client.event
async def on_message(message):
if message.content.startswith('r!help'):
channel = message.channel
await channel.send('Help')
# bring up help
@client.event
async def on_message(message):
if message.content.startswith('r!start'):
channel = message.channel
await channel.send('Starting Story...')
#start story
我的 IDE (pycharm) 没有向我显示任何错误,该机器人似乎在服务器上在线,并使用 starting story 回复 r!help。它只是不响应帮助命令。
我确实注意到,当 r!startevent 被注释掉时,帮助事件确实起作用了,所以我认为问题出在故事事件中。
@client.event
async def on_message(message):
if message.content.startswith('r!help'):
channel = message.channel
await channel.send('Help')
# bring up help
#@client.event
#async def on_message(message):
# if message.content.startswith('r!start'):
# channel = message.channel
# await channel.send('Starting Spam...')
#works when this section is not there
【问题讨论】:
标签: python discord discord.py discord.py-rewrite