Discord 机器人上的多个服务器

问题描述 投票:0回答:1

总之,我正在创建一个 Discord 机器人,我希望它可用于多个服务器。

现在,它仍然是相同的机器人,但每个服务器都可以选择他们想要的功能和/或命令集,即游戏服务器可能需要命令来帮助某些游戏,而编码服务器很可能不需要.

除此之外,我如何记录服务器何时使用某个命令并将信息存储在数据库中,这是否与常规过程相同,或者由于多个服务器实例而有所不同?

使用discord.py

我假设这个过程与定期设置机器人非常相似,但我正在寻找一些好的技巧以及不该做的事情和要做的事情。

python discord discord.py
1个回答
-1
投票

每当使用命令时,您都可以使用

on_command
事件来记录。

@bot.event
async def on_command(ctx: commands.Context):
    # here you can record the command usage in a database or log file
    # i'll just print the information on the terminal
    command = ctx.prefix + ctx.command.qualified_name
    print(f"- User {ctx.author} used {command} in {ctx.guild}.")
© www.soinside.com 2019 - 2024. All rights reserved.