moderate.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:pcbot 作者: pckv 项目源码 文件源码
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))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号