Beispiel #1
0
 async def mute(self, member):
     role = member.guild.get_role(Configuration.get_var(member.guild.id, "MUTE_ROLE"))
     if role is not None:
         try:
             await member.add_roles(role, reason="Raid alarm triggered")
         except discord.HTTPException:
             Logging.warn(f"failed to mute {member} ({member.id}!")
Beispiel #2
0
 async def sound_the(self, kind, guild):
     Logging.info(f"Anti-raid {kind} triggered for {guild.name} ({guild.id})!")
     channel = self.bot.get_channel(Configuration.get_var(guild.id, f"MOD_CHANNEL"))
     if channel is not None:
         await channel.send(Configuration.get_var(guild.id, f"RAID_{kind}_MESSAGE"))
     else:
         Logging.warn(f"Unable to sound the {kind} in {guild.name} ({guild.id})")
         await guild.owner.send(
             f"🚨 Anti-raid {kind} triggered for {guild.name} but the mod channel is misconfigured 🚨")
     if kind == "ALARM":
         for m in self.trackers[kind][guild.id]:
             await self.mute(m)
Beispiel #3
0
    async def _sound_the_alarm(self, guild):
        Logging.info(f"Sounding the alarm for {guild} ({guild.id})!")
        guild_id = guild.id

        # apply alarm, grab id later reference
        raid_id = self.last_raid = self.last_raid + 1
        with open("raids/counter", "w") as file:
            file.write(str(raid_id))
            now = datetime.utcfromtimestamp(time.time())
        self.under_raid[guild_id] = {
            "ID": raid_id,
            "GUILD": guild_id,
            "RAIDERS": {},
            "MESSAGE": None,
            "TODO": [],
            "LAST_JOIN": now,
            "DETECTED": str(now),
            "ENDED": "NOT YET"
        }

        channel = self.bot.get_channel(
            Configuration.get_var(guild_id, f"MOD_CHANNEL"))
        if channel is not None:
            await channel.send(
                Configuration.get_var(guild_id, f"RAID_ALARM_MESSAGE"))

        else:
            Logging.warn(
                f"Unable to sound the alarm in {guild.name} ({guild_id})")
            await guild.owner.send(
                f"🚨 Anti-raid alarm triggered for {guild.name} but the mod channel is misconfigured, please use ``!status`` somewhere in that server to get the raid status 🚨"
            )

        # deal with current raiders
        for raider in self.trackers[guild.id]:
            await self._handle_raider(raider)

        self.bot.loop.create_task(self._alarm_checker(guild))

        # server has the tools the need to deal with it, notify other servers
        for other_guild in self.bot.guilds:
            if other_guild is not guild:
                channel = self.bot.get_channel(
                    Configuration.get_var(other_guild.id, f"MOD_CHANNEL"))
                if channel is not None:
                    await channel.send(
                        f"⚠ Heads up: {guild} is being raided (raid ID: {raid_id}! They might try to raid this server as well. Spoiler alert: They'll fail"
                    )