本文整理汇总了Python中discord.Client.edit_channel_permissions方法的典型用法代码示例。如果您正苦于以下问题:Python Client.edit_channel_permissions方法的具体用法?Python Client.edit_channel_permissions怎么用?Python Client.edit_channel_permissions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类discord.Client
的用法示例。
在下文中一共展示了Client.edit_channel_permissions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_command
# 需要导入模块: from discord import Client [as 别名]
# 或者: from discord.Client import edit_channel_permissions [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"])