示例#1
0
    async def check_status(self, ctx, member, reason: str = None):
        user = self.bot.ww.dbh.get_alarmed_user_by_id(member.id)

        if user is None or member is None:
            raise Exception(
                f'error while trying to warn the user\nTry again using ID')

        try:
            if user["strikes"] == 1:
                await self.bot.log_channel.send(
                    f'```❗{member.display_name} HAS BEEN WARNED ONCE```')
                await self.unmute(ctx, member=member, no_action_message=True)
                await ctx.send(utils.actionmessage("warned"))
                await member.send(
                    f'This is the first time that you get warned, next time you\'ll be muted'
                ) if reason is None or len(reason) < 1 else await member.send(
                    "WARN:\n" + reason)
            if user["strikes"] == 2:
                await self.bot.log_channel.send(
                    f'```❗{member.display_name} HAS BEEN WARNED TWICE```')
                await ctx.send(utils.actionmessage("warned"))
                await asyncio.gather(
                    self.mute(ctx,
                              member=member,
                              time=str(5),
                              reason=reason or "warned 2 times",
                              no_action_message=True),
                    member.send(
                        f'This is the second time that you get warned, you\'ll be muted for 5 hours.\n'
                        f'next time you may be **banned!!** for ever. ')
                    if reason is None or len(reason) < 1 else
                    member.send("WARN:\n" + reason))
            if user["strikes"] == 3:
                await self.bot.log_channel.send(
                    f'```❗{member.display_name} HAS BEEN WARNED 3 TIMES```')
                await self.ban(ctx,
                               member=member.id,
                               reason=reason or "warned 3 times",
                               no_action_message=True)
                await ctx.send(utils.actionmessage("warned"))
                await member.send(
                    f'This is the third time that you get warned, you are banned from the server\n'
                    f'the mods will talk about that.'
                ) if reason is None or len(reason) < 1 else await member.send(
                    "WARN:\n" + reason)
        except discord.HTTPException:
            raise Exception(
                'Could not send dm to the user, but **warned** anyway kekw')
        except discord.Forbidden:
            raise Exception(
                f'I don\'t have permission to ban {member.nick if member.nick is not None else member.display_name}'
            )
        except Exception as e:
            raise Exception(
                f'error while trying to warn the user\n{str(e)}\nuser may have been wanred anyway please check'
            )
示例#2
0
    async def unmute(self,
                     ctx,
                     member: discord.Member,
                     *,
                     reason: str = None,
                     no_action_message: bool = False):
        if await permissions.check_priv(ctx, member):
            return

        muted_role = next(
            (g for g in ctx.guild.roles if g.name == "Black Room"), None)

        if not muted_role:
            return await ctx.send("Is there a  role  \'**Black Room**\'?")

        try:
            await member.remove_roles(muted_role,
                                      reason=utils.responsible(
                                          ctx.author, reason))
            if not no_action_message:
                await ctx.send(utils.actionmessage("unmuted"))
        except Exception as e:
            print(e)
            await ctx.send(
                f'I don\'t have permission to {ctx.command} {member.nick if member.nick is not None else member.display_name}'
            )
示例#3
0
    async def mute(self,
                   ctx,
                   member: discord.Member,
                   time: str = None,
                   *,
                   reason: str = None,
                   no_action_message: bool = False):
        if await permissions.check_priv(ctx, member):
            return

        muted_role = ctx.guild.get_role(691265959302004797)

        if not muted_role:
            return await ctx.send("Is there a role \'**Black Room**\'?")

        if time is not None and not time.isdigit():
            return await ctx.send(f"{time} is not a valid value")

        try:
            await member.add_roles(muted_role,
                                   reason=utils.responsible(
                                       ctx.author, reason))
            if not no_action_message:
                await ctx.send(utils.actionmessage("muted", time=time))
            if time is not None:
                await asyncio.sleep(int(time) * 3600)
                await member.remove_roles(muted_role, reason='time expired')
        except Exception as e:
            print(e)
            await ctx.send(
                f'I don\'t have permission to {ctx.command} {member.nick if member.nick is not None else member.display_name}'
            )
示例#4
0
 async def softban(self,
                   ctx,
                   member: MemberID,
                   *,
                   reason: str = None,
                   no_action_message: bool = False):
     try:
         await ctx.guild.ban(discord.Object(id=member),
                             reason=utils.responsible(ctx.author, reason))
         if not no_action_message:
             await ctx.send(utils.actionmessage("banned"))
         await ctx.guild.unban(discord.Object(id=member),
                               reason=utils.responsible(ctx.author, reason))
         if not no_action_message:
             await ctx.send(utils.actionmessage("unbanned"))
     except Exception as e:
         print(e)
         await ctx.send(
             f'I don\'t have permission to {ctx.command} {member}')
示例#5
0
 async def kick(self, ctx, member: discord.Member, *, reason: str = None):
     if await permissions.check_priv(ctx, member):
         return
     try:
         await member.kick(reason=utils.responsible(ctx.author, reason))
         await ctx.send(utils.actionmessage("kicked"))
     except Exception as e:
         print(e)
         await ctx.send(
             f'I don\'t have permission to {ctx.command} {member.nick if member.nick is not None else member.display_name}'
         )
示例#6
0
 async def _unwarn(self, ctx, *, member: discord.Member):
     if await permissions.check_priv(ctx, member):
         return
     try:
         strikes = self.bot.ww.dbh.get_alarmed_user_by_id(member.id)
         if strikes is None:
             return await ctx.send(
                 f"The memeber is warned 0 times, you can\'t {ctx.command.name} him"
             )
         else:
             self.bot.ww.dbh.unalarm_user_by_id(member.id)
             await ctx.send(utils.actionmessage("unwarned"))
     except Exception as e:
         print(e)
         await ctx.send(
             f'I don\'t have permission to {ctx.command} {member.nick if member.nick is not None else member.display_name}'
         )
示例#7
0
    async def ban(self,
                  ctx,
                  member: MemberID,
                  *,
                  reason: str = None,
                  no_action_message: bool = False):
        m = ctx.guild.get_member(member)
        if m is not None and await permissions.check_priv(ctx, m):
            return

        try:
            await ctx.guild.ban(discord.Object(id=member),
                                reason=utils.responsible(ctx.author, reason))
            if not no_action_message:
                await ctx.send(utils.actionmessage("banned"))
        except Exception as e:
            print(e)
            await ctx.send(
                f'I don\'t have permission to {ctx.command} {member}')