base.py 文件源码

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

项目:Asurix-bot 作者: Beafantles 项目源码 文件源码
def set_avatar(self, avatar_link : str):
        """Sets bot's avatar
        Parameters:
            avatar_link: The link of the the picture which will become the new bot's avatar

        Example: [p]set_avatar http://i.imgur.com/bjmbH1e.png"""
        r = requests.get(avatar_link)
        if r.status_code == 200:
            try:
                await self.bot.edit_profile(avatar=r.content)
                await self.bot.say("Done!")
            except discord.HTTPException:
                await self.bot.say("HTTP Exception")
            except discord.InvalidArgument:
                await self.bot.say("Wrong image format")
            except requests.exceptions.MissingSchema:
                await self.bot.say("Invalid URL")
        else:
            await self.bot.say("Error " + str(r.status_code) + ": The link must be incorrect, " \
            + "make sure the link finishes with `.png`, `.jpg`, `.jpeg`, etc")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号