custom包裹在Discord命令上 我创建了这样的自定义包装 DEF ADDLOGGER(FN): 从函数引入包装 @wraps(fn) 异步def add_logger(*args,** kwargs): 打印(f“ addlogger:即将运行{fn .__ na ...

问题描述 投票:0回答:1
它在此功能上很棒

@bot.event @addLogger async def on_ready(): logger.info(f'{bot.user.name} has connected to Discord!') try : synced = await bot.tree.sync() print(f"Synced {len(synced)} command") except Exception as e: print(e)

但不在
list_cogs

我已经试图返回
@addLogger
@bot.tree.command(name="list_cogs", description="list all cogs")
async def list_cogs(interaction):
    
        await interaction.response.send_message(f"{cogList}")
而不是

commands.check(add_logger)

add_logger

,但最终完全不工作
    

您需要在
@addLogger
线之后拥有
@bot.tree.command()

。因此,正确的代码将为
python discord discord.py
1个回答
0
投票
@bot.tree.command(name="list_cogs", description="list all cogs") @addLogger async def list_cogs(interaction): await interaction.response.send_message(f"{cogList}")

	
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.