【问题标题】:How to get commands usage in python如何在python中获取命令用法
【发布时间】:2018-12-12 15:18:19
【问题描述】:

如何从已安装的所有服务器机器人获取命令使用历史记录。我在谷歌搜索中找不到任何示例代码。

So for an example if we type !commands_stats

Bot reply's with {members.name} from {server.name} used !hello command.

它列出了所有服务器中使用的前 10 个或 xx 个以前的命令。

否则,如果任何成员在任何服务器中使用命令,它应该为所述服务器的指定频道 ID 发送确认消息。

So for an example if a member from any server type !hello in channel.
after bot reply to that message it should send a confirmation to listed Server ID and Channel ID like below.

Bot reply's with {members.name} from {server.name} used !hello command.

【问题讨论】:

    标签: python-3.x discord.py


    【解决方案1】:

    Message 类是按照documentation 执行此操作的一种方法

    client = Botcommand_prefix=("!")
    
    @client.command(pass_context = True)
    async def hello(ctx):
        await client.say("Hi") 
        print(f"{ctx.message.author.name} from {ctx.message.server} used !hello command")
    

    您可以使用这些参数将值添加到您拥有的所有命令的字典中

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-13
      • 1970-01-01
      • 2021-01-07
      • 1970-01-01
      • 2011-09-12
      • 2015-09-27
      • 2022-08-11
      • 1970-01-01
      相关资源
      最近更新 更多