问题描述
elif message.contains in ["-play",".play","!play"]:
print('music')
msg = 'hi.gif'
await message.channel.send(msg)
我正在使用以下命令对音乐命令做出反应-当用户写.play
等时,它起作用。但是,当用户写.play https://...
时,命令不响应。
我猜这是由于所包含的列表所致-有人知道即使仅提及单词我仍能得到反应吗?
谢谢!
解决方法
message.contains
是一个函数,您正在检查列表中是否存在该函数。而是-
elif message.content.startswith('.play') or message.content.startswith('!play') or message.content.startswith('-play'):
print('music')
msg = 'hi.gif'
await message.channel.send(msg)
实现命令的最佳方法是使用库随附的commands
扩展名。 See here