コード例 #1
0
ファイル: admin.py プロジェクト: LeicaSimile/PROJECT-Ashe
    async def notify_inactive_members(self, context, members=None):
        message = Settings.inactive_message(context.guild.id)
        if not message:
            await utils.say(context.channel, content="There is no inactivity message for this server.")
            return CommandStatus.FAILED

        if not members:
            members = await get_inactive_members(context)
        members = [i.user for i in members]
        
        await self.notify_members(context, members, message, use_case="inactivity")
        return CommandStatus.COMPLETED
コード例 #2
0
ファイル: admin.py プロジェクト: LeicaSimile/PROJECT-Ashe
    async def inactivelist(self, context):
        cmd_settings = Settings.command_settings(context.command.name, context.guild.id)
        if not cmd_settings.get("enabled"):
            return

        inactive_members = await get_inactive_members(context)
        inactive_list = []
        for i in inactive_members:
            last_notified = i.last_notified.strftime(" (%b %d, %Y %Z)") if i.last_notified else ""
            entry = f"{'**EXEMPT** ' if i.is_exempt else ''}{i.user.mention} [{i.user.display_name}]{last_notified}"
            inactive_list.append(entry)

        days_threshold = Settings.inactive_threshold(context.guild.id)
        embeds = utils.split_embeds(
            title=f"Inactive Members ({days_threshold}+ days since last message)",
            description="\n".join(inactive_list)
        )

        for i, embed in enumerate(embeds):
            if i < len(embeds) - 1:
                await utils.say(context.channel, embed=embed)
            else:
                # Final message
                inactivity_message = Settings.inactive_message(context.guild.id)
                if inactivity_message:
                    embed.set_footer(text="React 📧 below to notify them")
                report = await utils.say(context.channel, content=f"{context.author.mention}", embed=embed)
        
                if inactivity_message:
                    await report.add_reaction("📧")
                    def check(reaction, user):
                        return reaction.message.id == report.id and user.id == context.message.author.id \
                        and str(reaction.emoji) == "📧"

                    try:
                        await self.bot.wait_for("reaction_add", timeout=600, check=check)
                    except asyncio.TimeoutError:
                        embed.set_footer(text=discord.Embed.Empty)
                        await report.edit(embed=embed)
                        await report.clear_reactions()
                    else:
                        await self.notify_inactive_members(context, inactive_members)
        
        return CommandStatus.COMPLETED