【发布时间】:2019-05-11 08:25:36
【问题描述】:
我需要制作一个机器人来侦听服务器中写入的消息,同时接受命令。
# Create the Discord client
client = discord.Client()
client = commands.Bot(command_prefix = '!')
client.remove_command('help')
@client.event
async def on_ready():
print('ready')
@client.event #ricerca messaggi
async def on_message(message):
# Ignore messages made by the bot
if(message.author == client.user):
return
a = ''
a += message.embeds[0]["description"]
if a == 'abcdef':
print(' aaaaa ')
@client.command()
async def hello():
await client.say('hello')
client.run('token')
我怎样才能让它工作? 我认为问题在于机器人在第一个事件中继续循环...... 我读过关于 sub_process 但我不明白如何使用它。
【问题讨论】:
-
机器人可以工作,但无法识别命令
-
是的,我错了...以前我使用了发送嵌入...无论如何,我怎样才能同时使用命令和事件?你能用我的代码举个例子吗?
标签: python-3.x bots discord discord.py