async def _apply_ban(self, action: proto.Action) -> None: assert action.WhichOneof('details') == 'ban' guild = self.__get_guild(action) if guild is None: return assert action.HasField('user_id') user = fake.FakeSnowflake(id=action.user_id) if action.ban.type != proto.BanMember.UNBAN: await guild.ban(user, reason=_get_reason(action), delete_message_days=action.ban.delete_message_days) if action.ban.type != proto.BanMember.BAN: await guild.unban(user, reason=_get_reason(action))
async def __apply_pending_deescalation(self, session, deesc): guild = self.bot.get_guild(deesc.guild_id) if guild is not None: history = escalation_history.UwerEscalationHistory( user=fake.FakeSnowflake(deesc.user_id), guild=guild, session=session) await history.apply_diff(guild.me, 'Automatic Deescalation', deesc.amount, execute=False) session.delete(deesc) session.commit()
async def _apply_escalate(self, action: proto.Action) -> None: assert action.WhichOneof('details') == 'escalate' guild = self.__get_guild(action) if guild is None: return history = escalation_history.UserEscalationHistory( self.bot, fake.FakeSnowflake(id=action.user_id), guild) # TODO(james7132): Log this if action.escalate.amount == 0: return await history.apply_diff(guild.me, action.reason, action.escalate.amount, execute=action.escalate.amount > 0)
async def escalate_history(self, ctx, user: typing.Union[discord.Member, int]): """Deesclates a user and applies the appropriate moderation action. A history of escalation events can be seen with ~escalate history. See: ~help escalate history. Requires the escalation ladder to be configured properly. For more information: https://github.com/james7132/Hourai/wiki/Escalation-Ladder """ name = str(user) user = fake.FakeSnowflake(user) if isinstance(user, int) else user history = escalation_history.UserEscalationHistory( self.bot, user, ctx.guild) comps = [f"**Escalation History for {name}**"] comps.append(await self.__build_escalation_history_table(history)) await ctx.send(format.vertical_list(comps))
def _ban(member): if isinstance(member, int): member = fake.FakeSnowflake(id=member) return ctx.guild.ban(member, delete_message_days=0, reason=reason)
def _to_user(member): if isinstance(member, int): return fake.FakeSnowflake(id=member) return member