emoji.py 文件源码

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

项目:PyMiki 作者: TheGrammarJew 项目源码 文件源码
def on_guild_emojis_update(self, guild, before, after):
        # we only care when an emoji is added
        lookup = { e.id for e in before }
        added = [e for e in after if e.id not in lookup and len(e.roles) == 0]
        if len(added) == 0:
            return

        log.info('Server %s has added %s emojis.', guild, len(added))
        if guild.id != BLOB_GUILD_ID:
            return # not the guild we care about

        # this is the backup channel
        channel = self.bot.get_channel(305841865293430795)
        if channel is None:
            return

        for emoji in added:
            async with self.bot.session.get(emoji.url) as resp:
                if resp.status != 200:
                    continue

                data = io.BytesIO(await resp.read())
                await channel.send(emoji.name, file=discord.File(data, f'{emoji.name}.png'))
                await asyncio.sleep(1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号