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


Python Client.delete_channel方法代码示例

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


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

示例1: on_command

# 需要导入模块: from discord import Client [as 别名]
# 或者: from discord.Client import delete_channel [as 别名]
def on_command(client: discord.Client, message: discord.Message, args: list):
    global deck

    if args[0] == "!deck":
        deck = Deck()
        yield from client.send_message(message.channel, "Created new deck.")
    elif args[0] == "!shuffle":
        deck.shuffle()
        yield from client.send_message(message.channel, "Shuffled deck.")
    elif args[0] == "!pick":
        amount = 1

        if len(args) > 1:
            try:
                amount = int(args[1])
            except ValueError:
                amount = 1

        cards = deck.pick(amount=amount)

        m = "Cards picked: ```\n"

        for card in cards:
            m += "- " + card.text() + "\n"

        m += "```\nCards in deck: " + str(len(deck.cards))

        yield from client.send_message(message.channel, m)

    elif args[0] == "!uno":
        if not uno.get(message.server):
            uno[message.server] = {}

        uno[message.server]["players"] = [message.author]

        # Add all mentioned users to our list of participants
        if len(message.mentions) > 0:
            for member in message.mentions:
                if member not in uno[message.server]["players"]:
                    uno[message.server]["players"].append(member)
        else:
            yield from client.send_message(message.channel, "You need to add at least one player.")
            return

        uno[message.server]["channel"] = yield from client.create_channel(message.server, "uno")

        # Assign permissions for uno channel
        permission = discord.Permissions.none()
        permission.send_messages = True

        # Set up all personal deck channels (private message)
        for member in uno[message.server]["players"]:
            yield from client.send_message(member, "Welcome to your deck, {}!".format(member.mention))

        yield from client.edit_channel_permissions(uno[message.server]["channel"], message.server.default_role,
                                                   deny=permission)

        # Give players permission to write in the #uno channel
        for member in uno[message.server]["players"]:
            yield from client.edit_channel_permissions(uno[message.server]["channel"], member, allow=permission)

    elif args[0] == "!unostop":
        if uno.get(message.server, {}).get("channel"):
            yield from client.delete_channel(uno[message.server]["channel"])
开发者ID:EdwardBetts,项目名称:PCBOT,代码行数:66,代码来源:uno.py


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