def suspend(message: discord.Message, channel: discord.Channel=Annotate.Self):
""" Suspends a channel by removing send permission for the server's default role.
This function acts like a toggle. """
send = channel.overwrites_for(message.server.default_role).send_messages
print(send, False if send is None else not send)
overwrite = discord.PermissionOverwrite(send_messages=False if send is None else not send)
await client.edit_channel_permissions(channel, message.server.default_role, overwrite)
try:
if overwrite.send_messages:
await client.say(message, "{} is no longer suspended.".format(channel.mention))
else:
await client.say(message, "Suspended {}.".format(channel.mention))
except discord.Forbidden: # ...
await client.send_message(message.author, "You just removed my send permission in {}.".format(channel.mention))
评论列表
文章目录