当前位置: 首页>>代码示例>>Python>>正文


Python Client.reload_plugin方法代码示例

本文整理汇总了Python中discord.Client.reload_plugin方法的典型用法代码示例。如果您正苦于以下问题:Python Client.reload_plugin方法的具体用法?Python Client.reload_plugin怎么用?Python Client.reload_plugin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在discord.Client的用法示例。


在下文中一共展示了Client.reload_plugin方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: cmd_plugin

# 需要导入模块: from discord import Client [as 别名]
# 或者: from discord.Client import reload_plugin [as 别名]
def cmd_plugin(client: discord.Client, message: discord.Message,
               option: str, plugin_name: str.lower="") -> cmd_plugin_noargs:
    """ Manage plugins. """
    if option == "reload":
        if plugin_name:
            if plugin_name in client.plugins:
                yield from client.save_plugin(plugin_name)
                client.reload_plugin(plugin_name)
                
                m = "Reloaded plugin `{}`.".format(plugin_name)
            else:
                m = "`{}` is not a plugin. See `!plugin`.".format(plugin_name)
        else:
            yield from client.save_plugins()

            for plugin in client.plugins.keys():
                client.reload_plugin(plugin)

            m = "All plugins reloaded."

    elif option == "load":
        if plugin_name:
            if plugin_name not in client.plugins:
                loaded = client.load_plugin(plugin_name)

                if loaded:
                    m = "Plugin `{}` loaded.".format(plugin_name)
                else:
                    m = "Plugin `{}` could not be loaded.".format(plugin_name)
            else:
                m = "Plugin `{}` is already loaded.".format(plugin_name)
        else:
            m = "You need to specify the name of the plugin to load."

    elif option == "unload":
        if plugin_name:
            if plugin_name in client.plugins:
                yield from client.save_plugin(plugin_name)
                client.unload_plugin(plugin_name)

                m = "Plugin `{}` unloaded.".format(plugin_name)
            else:
                m = "`{}` is not a plugin. See `!plugin`.".format(plugin_name)
        else:
            m = "You need to specify the name of the plugin to unload."
    else:
        m = "`{}` is not a valid option.".format(option)

    yield from client.send_message(message.channel, m)
开发者ID:EdwardBetts,项目名称:PCBOT,代码行数:51,代码来源:builtin.py


注:本文中的discord.Client.reload_plugin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。