所以我正在用python制作bot,但我不知道如何使其他用户可以编写-join,然后bot将触发该命令。我的代码当前在齿轮中,所以我使用@ commands.command而不是@ bot.command。这是我的代码:
class GamesCog(commands.Cog, name="Games"):
def __init__(self, bot):
self.bot = bot
@commands.command()
async def game(self, ctx):
await ctx.send("Find a second person to play dice or play against the bot. (-join/-bot)")
await ctx.send(file=discord.File('game.jpg'))
def check(msg):
return msg.author == ctx.author and msg.channel == ctx.channel and msg.content.lower() in ["-join", "-bot"]
msg = await self.bot.wait_for("message", check=check)
def setup(bot):
bot.add_cog(GamesCog(bot))
print('File games.py is ready')
我知道return msg.author
作者不应该在那儿,我只是不知道用什么来代替它。
您实际上对消息什么也不做,正在等待,然后什么也没有做
msg = await self.bot.wait_for("message", check=check)
if msg.content.lower() == "-join":
# Do something
elif msg.content.lower() == "-bot":
# Do something
def check(msg):
return msg.channel == ctx.channel and msg.content.lower() in ["-join", "-bot"]
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句