pokedex.py 文件源码

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

项目:pcbot 作者: pckv 项目源码 文件源码
def scalefactor(message: discord.Message, factor: float=default_scale_factor):
    """ Set the image scaling factor for your server. If no factor is given, the default is set. /
    **This command requires the `Manage Server` permission.**"""
    assert not factor == 0, "If you wish to disable images, remove the `Attach Files` permission from this bot."

    assert factor <= max_scale_factor, "The factor **{}** is too high **(max={})**.".format(factor, max_scale_factor)
    assert min_scale_factor <= factor, "The factor **{}** is too low **(min={})**.".format(factor, min_scale_factor)

    if message.server.id not in pokedex_config.data:
        pokedex_config.data[message.server.id] = {}

    # Handle specific scenarios
    if factor == default_scale_factor:
        if "scale-factor" in pokedex_config.data[message.server.id]:
            del pokedex_config.data[message.server.id]["scale-factor"]
            reply = "Pokédex image scale factor reset to default: **{factor}**."
        else:
            reply = "Pokédex image scale factor is **{factor}** (default)."
    else:
        pokedex_config.data[message.server.id]["scale-factor"] = factor
        reply = "Pokédex image scale factor set to **{factor}**."

    pokedex_config.save()
    await client.say(message, reply.format(factor=factor))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号