stars.py 文件源码

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

项目:epicord-bot 作者: Epicord 项目源码 文件源码
def star_update(self, ctx):
        """Updates the starboard's content to the latest format.

        If a message referred in the starboard was deleted then
        the message will be untouched.

        To prevent abuse, only the last 100 messages are updated.

        Warning: This operation takes a long time. As a consequence,
        only those with Administrator permission can use this command
        and it has a cooldown of one use per 5 minutes.
        """
        reconfigured_cache = {
            v[0]: (k, v[1]) for k, v in ctx.db.items()
        }

        async for msg in self.bot.logs_from(ctx.starboard, limit=100):
            try:
                original_id, starrers = reconfigured_cache[msg.id]
                original_channel = msg.channel_mentions[0]
            except Exception:
                continue

            original_message = await self.get_message(original_channel, original_id)
            if original_message is None:
                continue

            content, embed = self.emoji_message(original_message, len(starrers))
            try:
                await self.bot.edit_message(msg, content, embed=embed)
            except:
                pass # somehow this failed, so ignore it

        await self.bot.say('\N{BLACK UNIVERSAL RECYCLING SYMBOL}')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号