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


Python Client.is_owner方法代码示例

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


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

示例1: cmd_help_noargs

# 需要导入模块: from discord import Client [as 别名]
# 或者: from discord.Client import is_owner [as 别名]
def cmd_help_noargs(client: discord.Client, message: discord.Message):
    m = "**Commands:**```"

    for plugin in client.plugins.values():
        if plugin.commands:
            m += "\n" + "\n".join(usage for cmd, usage in plugin.commands.items() if usage and
                                  (not getattr(get_command(plugin, cmd), "__owner__", False) or
                                  client.is_owner(message.author)))

    m += "```\nUse `!help <command>` for command specific help."
    yield from client.send_message(message.channel, m)
开发者ID:EdwardBetts,项目名称:PCBOT,代码行数:13,代码来源:builtin.py

示例2: on_message

# 需要导入模块: from discord import Client [as 别名]
# 或者: from discord.Client import is_owner [as 别名]
def on_message(client: discord.Client, message: discord.Message, args: list):
    if args[0] in lambdas.data and args[0] not in lambda_blacklist:
        def say(msg, c=message.channel):
            asyncio.async(client.send_message(c, msg))

        def arg(i, default=0):
            if len(args) > i:
                return args[i]
            else:
                return default

        try:
            exec(lambdas.data[args[0]], locals(), globals())
        except Exception as e:
            if client.is_owner(message.author):
                say("```" + format_exception(e) + "```")

        logging.info("@{0.author} -> {0.content}".format(message))
开发者ID:EdwardBetts,项目名称:PCBOT,代码行数:20,代码来源:builtin.py

示例3: decorator

# 需要导入模块: from discord import Client [as 别名]
# 或者: from discord.Client import is_owner [as 别名]
 def decorator(client: discord.Client, message: discord.Message, *args, **kwargs):
     if client.is_owner(message.author):
         yield from f(client, message, *args, **kwargs)
开发者ID:EdwardBetts,项目名称:PCBOT,代码行数:5,代码来源:utils.py

示例4: on_command

# 需要导入模块: from discord import Client [as 别名]
# 或者: from discord.Client import is_owner [as 别名]
def on_command(client: discord.Client, message: discord.Message, args: list):
    # Basic check
    if args[0] == "!ping":
        start = datetime.now()
        pong = yield from client.send_message(message.channel, "pong")
        end = datetime.now()
        response = (end - start).microseconds / 1000
        yield from client.edit_message(pong, "pong `{}ms`".format(response))

        logging.info("Response time: {}ms".format(response))

    # Roll from 1-100 or more
    elif args[0] == "!roll":
        if len(args) > 1:
            try:
                roll = random.randint(1, int(args[1]))
            except ValueError:
                roll = random.randint(1, 100)
        else:
            roll = random.randint(1, 100)

        yield from client.send_message(message.channel, "{0.mention} rolls {1}".format(message.author, roll))

    # Handle bot feature requests
    # (warning: this code is not representative of what I stand for in programming. I'm sorry.)
    elif args[0] == "!feature":
        m = "Please see `!help feature`."
        if len(args) > 2:
            plugin = args[1]
            if client.has_plugin(plugin):
                # Initialize the plugin for features
                if plugin not in feature_reqs.data:
                    feature_reqs.data[plugin] = []

                req_list = feature_reqs.data[plugin]

                # List feature request
                if args[2].startswith("#"):
                    feature_id = get_req_id(args[2])

                    if feature_id is not None:
                        if 0 <= feature_id < len(req_list):
                            m = "```diff\n" + format_req(plugin, feature_id) + "```"
                        else:
                            m = "There is no such feature. Try `!feature {} list`.".format(plugin)

                # List all feature requests or request with given ID.
                if args[2] == "list":
                    m = "```diff\n"
                    for req_id in range(len(req_list)):
                        m += format_req(plugin, req_id) + "\n"

                    m += "```"

                # Create a new feature
                elif args[2] == "new" or args[2] == "add" and len(args) > 3:
                    feature = " ".join(args[3:]).replace("\n", " ")

                    if feature not in req_list:
                        feature_reqs.data[plugin].append(feature)
                        feature_reqs.save()

                        m = "Feature saved as `{}` id **#{}**.".format(plugin, len(req_list))

                # Owner commands
                if client.is_owner(message.author):
                    # Mark a feature as complete
                    if args[2] == "mark" and len(args) > 3:
                        feature_id = get_req_id(args[3])

                        if feature_id is not None:
                            if 0 <= feature_id < len(req_list):
                                req = feature_reqs.data[plugin][feature_id]

                                if not req.endswith("+++"):
                                    feature_reqs.data[plugin][feature_id] += "+++"
                                    feature_reqs.save()

                                    m = "Marked feature with `{}` id **#{}**.".format(plugin, feature_id + 1)
                                else:
                                    feature_reqs.data[plugin][feature_id] = req[:-3]
                                    feature_reqs.save()

                                    m = "Unmarked feature with `{}` id **#{}**.".format(plugin, feature_id + 1)
                            else:
                                m = "There is no such feature. Try `!feature {} list`.".format(plugin)

                    # Remove a feature request
                    elif args[2] == "remove"and len(args) > 3:
                        feature_id = get_req_id(args[3])

                        if feature_id is not None:
                            if 0 <= feature_id < len(req_list):
                                feature_reqs.data[plugin].pop(feature_id)
                                feature_reqs.save()

                                m = "Removed feature with `{}` id **#{}**.".format(plugin, feature_id + 1)
                            else:
                                m = "There is no such feature. Try `!feature {} list`.".format(plugin)

#.........这里部分代码省略.........
开发者ID:EdwardBetts,项目名称:PCBOT,代码行数:103,代码来源:basic.py


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