コード例 #1
0
ファイル: moderation.py プロジェクト: kutuzovrusss/GoodMute
    async def mutes(self, ctx, member: discord.Member, timenumber: int, typetime, *, reason):

        timed = 0

        if typetime == "s" or typetime == "sec" or typetime == "seconds":
            timed = timenumber
        elif typetime == "m" or typetime == "min" or typetime == "minutes":
            timed = timenumber * 60
        elif typetime == "h" or typetime == "hour" or typetime == "hours":
            timed = timenumber * 60 * 60
        elif typetime == "d" or typetime == "day" or typetime == "days":
            timed = timenumber * 60 * 60 * 24

        times = time.time()
        times += timed

        mute_role = discord.utils.get(ctx.message.guild.roles, name="RB_Muted")

        if not mute_role:
            mute_role = await ctx.guild.create_role(name="Muted")

        if mute_role in member.roles:
            await ctx.send(
                embed=discord.Embed(description=f'**:warning: Member {member.mention} already muted!**',))
        else:
            DB.Set().mute(member, times)

            await member.add_roles(mute_role,
                                   reason=f"Member {ctx.author.display_name} issued mute on {timenumber} {typetime} because of {reason}",
                                   atomic=True)
            await ctx.send(
                embed=discord.Embed(
                    description=f'**:shield: Mute to user {member.mention} successfully issued due to {reason}!**',))
コード例 #2
0
    async def on_voice_state_update(self, member, before, after):
        Get = DB.Get()
        Set = DB.Set()
        if after.channel:
            channel = Get.options("channels")[0]
            category = Get.options("category")[0]

            if int(after.channel.id) == int(channel):
                cat = discord.utils.get(member.guild.categories,
                                        id=int(category))
                channel2 = await member.guild.create_voice_channel(
                    name=f"{member.name}#{member.discriminator}", category=cat)
                await member.move_to(channel2)
                await channel2.set_permissions(member, manage_channels=True)
                Set.privateChannels(channel2, member)

            elif before.channel:
                if str(before.channel.id) in str(
                        Get.privateChannels(member)[0]):
                    try:
                        await before.channel.delete()
                    except Exception:
                        pass

        else:
            if before.channel:
                if str(before.channel.id) in str(
                        Get.privateChannels(member)[0]):
                    try:
                        await before.channel.delete()
                    except Exception:
                        pass
コード例 #3
0
    async def unwarn(self, ctx, ids: int):
        DB.Set().warns("remove", None, ids, None)
        unwarn_embed = discord.Embed(
            description=
            f"Варн, уникальный номер которого: `{ids}` был успешно снят!",
            color=config.COLOR_ERROR)

        unwarn_embed.set_footer(text=config.COPYRIGHT_TEXT,
                                icon_url=config.COPYRIGHT_ICON)
        await ctx.send(embed=unwarn_embed)
コード例 #4
0
    async def setreactions(self, ctx):
        await ctx.send("Введите ID каналов где бот будет ставить реакции для голосования (через пробелы) (у вас 60 секунд)")
        channels = await self.bot.wait_for('message', timeout=60.0, check=lambda
            message: message.author == ctx.author and message.channel == ctx.channel)

        data = [
            {"name": "channels", "update": f"reactions = '{channels.content}'", "insert": f'{channels.content}'}
        ]
        DB.Set().options(data)
        await ctx.send("Настройки успешно сохранены!")
コード例 #5
0
    async def setprivate(self, ctx):
        await ctx.send("Введите ID Категории для приватных каналов (у вас 60 секунд)")
        category = await self.bot.wait_for('message', timeout=60.0, check=lambda
            message: message.author == ctx.author and message.channel == ctx.channel)

        await ctx.send("Введите ID Канала для создания приватных каналов (у вас 60 секунд)")
        channel = await self.bot.wait_for('message', timeout=60.0, check=lambda
            message: message.author == ctx.author and message.channel == ctx.channel)

        data = [
            {"name": "channels", "update": f"private = '{channel.content}'", "insert": f'{channel.content}, null'},
            {"name": "category", "update": f"private = '{category.content}'", "insert": f'{category.content}'}
        ]
        DB.Set().options(data)
        await ctx.send("Настройки успешно сохранены!")
コード例 #6
0
ファイル: moderation.py プロジェクト: kutuzovrusss/GoodMute
    async def unmutes(self, ctx, member: discord.Member):

        mutes = DB.Get().mute(member)
        mute = mutes[1]

        mute_role = discord.utils.get(ctx.message.guild.roles, name="Mute")

        if mute != 0:
            DB.Set().mute(member, 0)

            await member.remove_roles(mute_role)
            await ctx.send(embed=discord.Embed(
                description=f'**:white_check_mark: Mute by {member.mention} Successfully removed!**',))
        else:
            await ctx.send(
                embed=discord.Embed(description=f'**:warning: member {member.mention} Not muted!**',))
コード例 #7
0
    async def unmute(self, ctx, member: discord.Member):

        mutes = DB.Get().mute(member)
        mute = mutes[1]

        mute_role = discord.utils.get(ctx.message.guild.roles, name="Mute")

        if mute != 0:
            DB.Set().mute(member, 0)

            await member.remove_roles(mute_role)
            await ctx.send(embed=discord.Embed(
                description=
                f'**:white_check_mark: Мьют у пользователя {member.mention} Успешно снят! **',
                color=config.COLOR_GOOD))
        else:
            await ctx.send(embed=discord.Embed(
                description=
                f'**:warning: Пользователь {member.mention} Не замьючен!**',
                color=config.COLOR_GOOD))
コード例 #8
0
    async def mute(self, ctx, member: discord.Member, timenumber: int,
                   typetime, *, reason):

        timed = 0

        if typetime == "s" or typetime == "сек" or typetime == "секунд":
            timed = timenumber
        elif typetime == "m" or typetime == "мин" or typetime == "минут":
            timed = timenumber * 60
        elif typetime == "h" or typetime == "час" or typetime == "часов":
            timed = timenumber * 60 * 60
        elif typetime == "d" or typetime == "день" or typetime == "дней":
            timed = timenumber * 60 * 60 * 24

        times = time.time()
        times += timed

        mute_role = discord.utils.get(ctx.message.guild.roles, name="RB_Muted")

        if not mute_role:
            mute_role = await ctx.guild.create_role(name="Muted")

        if mute_role in member.roles:
            await ctx.send(embed=discord.Embed(
                description=
                f'**:warning: Пользователь {member.mention} уже замьючен!**',
                color=config.COLOR_ERROR))
        else:
            DB.Set().mute(member, times)

            await member.add_roles(
                mute_role,
                reason=
                f"Пользователь {ctx.author.display_name} выдал мьют на {timenumber} {typetime} по причине {reason}",
                atomic=True)
            await ctx.send(embed=discord.Embed(
                description=
                f'**:shield: Мьют пользователю {member.mention} успешно выдан по причине {reason}!**',
                color=config.COLOR_GOOD))
コード例 #9
0
    async def mute_loop(self):
        try:
            for mem in DB.Get().mute(None):
                mute = mem[1]
                guild = self.bot.get_guild(658658120309932062)
                if guild:
                    member = guild.get_member(int(mem[0]))
                    if member:
                        if float(mute) <= float(time.time()):
                            DB.Set().mute(member, 0)
                            mute_role = discord.utils.get(guild.roles,
                                                          name="Muted")
                            await member.remove_roles(
                                mute_role,
                                reason="Снят Мьют Временем",
                                atomic=True)

        except Exception as e:
            print(Fore.RED + "[ERROR] " + Style.RESET_ALL +
                  f"В цикле MUTE_LOOP произошла следующая ошибка:")
            print(Fore.RED + "[ERROR] " + Style.RESET_ALL + f"{e}")
            print(Fore.RED + "[ERROR] " + Style.RESET_ALL +
                  f"Цикл MUTE_LOOP продолжает свою работу!")
コード例 #10
0
    async def warn(self, ctx, member: discord.Member, *, arg):
        ids = DB.Set().warns("add", member, ctx.author, arg)

        await ctx.send(
            f"Предупреждение пользователю {member.display_name} с причиной {arg} успешно выдано! (ID предупреждения - `{ids}`)"
        )