當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。