Exemplo n.º 1
0
    async def warn(self, ctx: commands.Context, member: DiscordUser, *, reason: Reason):
        """warn_help"""
        # don't allow warning GearBot, get some feedback about issues instead

        reason = Utils.enrich_reason(ctx, reason)
        if len(reason) > 1800:
            raise TranslatedBadArgument('reason_too_long', ctx)

        if member.id == self.bot.user.id:
            async def yes():
                channel = self.bot.get_channel(Configuration.get_master_var("inbox", 0))
                if channel is not None:
                    await channel.send(
                        f"[`{ctx.message.created_at.strftime('%c')}`] {ctx.message.author} (`{ctx.message.author.id}`) submitted feedback: {reason}")
                    await MessageUtils.send_to(ctx, 'YES', 'feedback_submitted')

            message = MessageUtils.assemble(ctx, "THINK", "warn_to_feedback")
            await Confirmation.confirm(ctx, message, on_yes=yes)
            return

        if member.discriminator == '0000':
            await MessageUtils.send_to(ctx, 'NO', 'cant_warn_system_user')
            return

        if member.bot:
            await MessageUtils.send_to(ctx, "THINK", "cant_warn_bot")
            return



        await Actions.act(ctx, "warning", member.id, self._warn, allow_bots=False, reason=reason, check_bot_ability=False, require_on_server=False)
Exemplo n.º 2
0
    async def warn(self, ctx: commands.Context, member: DiscordUser, *,
                   reason: Reason):
        """warn_help"""
        # don't allow warning GearBot, get some feedback about issues instead

        Utils.enrich_reason(ctx, reason)
        if len(reason) > 1800:
            raise TranslatedBadArgument('reason_too_long', ctx)

        if hasattr(member, 'system') and hasattr(member,
                                                 'system') and member.system:
            await MessageUtils.send_to(ctx, 'NO', 'cant_warn_system_user')
            return

        if member.bot:
            await MessageUtils.send_to(ctx, "THINK", "cant_warn_bot")
            return

        await Actions.act(ctx,
                          "warning",
                          member.id,
                          self._warn,
                          allow_bots=False,
                          reason=reason,
                          check_bot_ability=False,
                          require_on_server=False)
Exemplo n.º 3
0
    async def update(self, ctx: commands.Context, infraction: ServerInfraction, *, reason: Reason):
        """inf_update_help"""
        reason += ",".join(Utils.assemble_attachment(ctx.message.channel.id, attachment.id, attachment.filename) for attachment in ctx.message.attachments)
        if len(reason) > 1800:
            raise TranslatedBadArgument('reason_too_long', ctx)

        infraction.mod_id = ctx.author.id
        infraction.reason = reason
        await infraction.save()
        await MessageUtils.send_to(ctx, 'YES', 'inf_updated', id=infraction.id)
        InfractionUtils.clear_cache(ctx.guild.id)
        user = await Utils.get_user(infraction.user_id)
        GearbotLogging.log_key(ctx.guild.id, "inf_update_log", inf=infraction.id, user=Utils.clean_user(user), userid=user.id, mod=Utils.clean_user(ctx.author), modid=ctx.author.id, reason=reason)
Exemplo n.º 4
0
def enrich_reason(ctx, reason):
    if reason != "" and len(ctx.message.attachments) > 0:
        reason += " " + ",".join([
            assemble_attachment(ctx.message.channel.id, attachment.id,
                                attachment.filename)
            for attachment in ctx.message.attachments
        ])
    if reason == '':
        reason = Translator.translate('no_reason', ctx)
    if len(reason) > 1800:
        from Util.Converters import TranslatedBadArgument
        raise TranslatedBadArgument('reason_too_long', ctx)
    return reason
Exemplo n.º 5
0
    async def mwarn(self, ctx, targets: Greedy[PotentialID], *, reason: Reason):
        """mwarn_help"""

        reason += ",".join(Utils.assemble_attachment(ctx.message.channel.id, attachment.id, attachment.filename) for attachment in ctx.message.attachments)
        if len(reason) > 1800:
            raise TranslatedBadArgument('reason_too_long', ctx)

        async def yes():
            failures = await Actions.mass_action(ctx, "warning", targets, self._warn, max_targets=10, allow_bots=False,
                                                 message=False, reason=reason, dm_action=True, require_on_server=False)

            await MessageUtils.send_to(ctx, "YES", "mwarn_confirmation", count=len(targets) - len(failures))
            if len(failures) > 0:
                await Pages.create_new(self.bot, "mass_failures", ctx, action_type="warn",
                                       failures="----NEW PAGE----".join(Pages.paginate("\n".join(failures))))

        if len(targets) > 10:
            await MessageUtils.send_to(ctx, "NO", "mwarn_too_many_people")
            return
        if len(targets) > 0:
            await Confirmation.confirm(ctx, Translator.translate("mwarn_confirm", ctx), on_yes=yes)
        else:
            await Utils.empty_list(ctx, "warn")
Exemplo n.º 6
0
    async def mwarn(self, ctx, targets: Greedy[PotentialID], *,
                    reason: Reason):
        """mwarn_help"""

        reason += ",".join(
            Utils.assemble_attachment(ctx.message.channel.id, attachment.id,
                                      attachment.filename)
            for attachment in ctx.message.attachments)
        if len(reason) > 1800:
            raise TranslatedBadArgument('reason_too_long', ctx)

        message = None

        async def yes(interaction: Interaction):
            await interaction.response.edit_message(
                content=MessageUtils.assemble(ctx, "REFRESH", "processing"),
                view=None)
            failures = await Actions.mass_action(ctx,
                                                 "warning",
                                                 targets,
                                                 self._warn,
                                                 max_targets=10,
                                                 allow_bots=False,
                                                 message=False,
                                                 reason=reason,
                                                 dm_action=True)

            await interaction.edit_original_message(
                content=MessageUtils.assemble(ctx,
                                              "YES",
                                              "mwarn_confirmation",
                                              count=len(targets) -
                                              len(failures)))
            if len(failures) > 0:
                f = "\n".join(failures)
                pipe = self.bot.redis_pool.pipeline()
                k = f'mass_failures:{ctx.message.id}'
                pipe.set(k, f)
                pipe.expire(k, 7 * 24 * 60 * 60)
                await pipe.execute()
                pages = Pages.paginate(f, prefix='```\n', suffix='```')
                content, view, _ = SimplePager.get_parts(
                    pages, 0, ctx.guild.id,
                    f'mass_failures:{ctx.message.id}:warn')
                await ctx.send(
                    f"**{Translator.translate('mass_failures_warn', ctx, page_num=1, pages=len(pages))}**{content}",
                    view=view)

        async def no(interaction):
            await interaction.response.edit_message(
                content=MessageUtils.assemble(ctx, 'NO', 'command_canceled'),
                view=None)

        async def timeout():
            if message is not None:
                await message.edit(content=MessageUtils.assemble(
                    ctx, 'NO', 'command_canceled'),
                                   view=None)

        def check(interaction: Interaction):
            return ctx.author.id == interaction.user.id and interaction.message.id == message.id

        if len(targets) > 10:
            await MessageUtils.send_to(ctx,
                                       "NO",
                                       "mass_action_too_many_people",
                                       max=10)
            return
        if len(targets) > 0:
            message = await ctx.send(Translator.translate(
                "mwarn_confirm", ctx),
                                     view=Confirm(ctx.guild.id,
                                                  on_yes=yes,
                                                  on_no=no,
                                                  on_timeout=timeout,
                                                  check=check))
        else:
            await Utils.empty_list(ctx, "warn")