示例#1
0
 async def sql_request(self, ctx, *, request):
     cur = data.cursor()
     try:
         cur.execute(str(request))
         await ctx.send(cur.fetchall() or 0)
         data.commit()
     except Exception as error:
         await ctx.send(error)
示例#2
0
 async def channelunslowdown(self, ctx, member: discord.TextChannel = None):
     if member == None:
         member = ctx.message.channel
     if await db_load_req(
             f"SELECT COUNT(*) as count FROM mutechannel WHERE id = {member.id} AND guild_id = {ctx.guild.id}") == 1:
         cur = data.cursor()
         cur.execute(f"DELETE FROM mutechannel WHERE id = {member.id} AND guild_id = {ctx.guild.id}")
         data.commit()
         await ctx.message.add_reaction(agree_emoji())
         embed = discord.Embed(title=f"Медленный режим в {member} отключён", color=discord.Colour.blurple())
         await ctx.send(embed=embed)
     else:
         await ctx.message.add_reaction(disagree_emoji())
         embed = discord.Embed(title=f"{disagree_emoji()} Ошибка",
                               description="Невозможно отключить медленный режим у канла, ведь он уже отключён.",
                               color=discord.Colour.red())
         await ctx.send(embed=embed)
示例#3
0
 async def unslowdown(self, ctx, member: discord.Member):
     if await db_load_req(
             f"SELECT COUNT(*) as count FROM mutemembers WHERE id = {member.id} AND guild_id = {ctx.guild.id}"
     ) == 1:
         cur = data.cursor()
         cur.execute(
             f"DELETE FROM mutemembers WHERE id = {member.id} AND guild_id = {ctx.guild.id}"
         )
         data.commit()
         await ctx.message.add_reaction(agree_emoji())
         embed = discord.Embed(title=f"Медленный режим у {member} отключён",
                               color=discord.Colour.blurple())
         await ctx.send(embed=embed)
         await usd_log(ctx, member, ctx.author)
     else:
         await ctx.message.add_reaction(disagree_emoji())
         embed = discord.Embed(
             title=f"{disagree_emoji()} Ошибка",
             description=
             "Невозможно отключить медленный режим у пользователя, ведь он уже отключён.",
             color=discord.Colour.red())
         await ctx.send(embed=embed)
示例#4
0
    async def on_guild_join(self, guild):
        try:
            embed = discord.Embed(title=f"Вошёл в  {guild.name} ({guild.id})", colour=discord.Colour.blurple())
            embed.set_author(name=guild.name, icon_url=guild.icon_url)
            await self.bot.get_channel(810967184397434921).send(embed=embed)
        except Exception as error:
            await self.bot.get_channel(810967184397434921).send(f'Logger error: {error}')
        count = await db_load_req(f"SELECT COUNT(*) as count FROM guilds WHERE id = {guild.id}")
        if count == 0:
            if str(guild.region) == "russia":
                language = "ru"
            else:
                language = "en"
            guildvalues = (guild.id, str(guild.name), 2, time.time(), bool(1), 0, 0, language)
            cur = data.cursor()
            cur.execute("INSERT INTO guilds VALUES(?, ?, ?, ?, ?, ?, ?, ?);", guildvalues)
            data.commit()
        elif count == 1:
            pass

        else:
            await developer().send(f'DataBaseError {guild.name} {guild.id} {datetime.now()}')
示例#5
0
 async def channelslowdown(self, ctx, member: discord.TextChannel, interval, unmute_in='0'):
     if await db_load_req(
             f"SELECT COUNT(*) as count FROM mutechannel WHERE id = {member.id} AND guild_id = {ctx.guild.id}") == 0:
         membervalues = (member.id, str(member), False, datetime.now(), int(interval), int(unmute_in), ctx.guild.id,
                         str(ctx.guild.id) + str(member.id))
         cur = data.cursor()
         cur.execute("INSERT INTO mutechannel VALUES(?, ?, ?, ?, ?, ?, ?, ?);", membervalues)
         data.commit()
         if unmute_in == '0':
             unmute_in = 'Permanent'
         Bot = ctx.guild.get_member(750415350348382249)
         if Bot.guild_permissions.manage_messages and Bot.guild_permissions.manage_roles:
             await ctx.message.add_reaction(agree_emoji())
             embed = discord.Embed(title=f"Медленный режим в {member} включён", color=discord.Colour.blurple(),
                                   description=f'Интервал: `{interval}` секунд \nМедленный режим отключется через: `{unmute_in}` минут')
             await ctx.send(embed=embed)
         else:
             await ctx.message.add_reaction(warning_emoji())
             embed = discord.Embed(
                 title=f"Медленный режим у {member} включён, но некотороые необходимые права отсутствуют",
                 color=discord.Colour.blurple(),
                 description=f'Интервал: `{interval}` секунд \nМедленный режим отключется через: `{unmute_in}` минут \nОтсутствуент право "Управлять сообщениями". Медленный режим не будет работать корректно')
             await ctx.send(embed=embed)
     else:
         await ctx.message.add_reaction(disagree_emoji())
         embed = discord.Embed(title=f"{disagree_emoji()} Ошибка",
                               description="Невозможно включить медленный режим каналу дважды.",
                               color=discord.Colour.red())
         await ctx.send(embed=embed)
     await asyncio.sleep(int(unmute_in) * 60)
     if await db_load_req(
             f"SELECT COUNT(*) as count FROM mutechannel WHERE id = {member.id} AND guild_id = {ctx.guild.id}") == 1 and unmute_in != 'Permanent':
         cur = data.cursor()
         cur.execute(f"DELETE FROM mutechannel WHERE id = {member.id} AND guild_id = {ctx.guild.id}")
         data.commit()
         await ctx.message.add_reaction(agree_emoji())
         embed = discord.Embed(title=f"Медленный режим у {member} отключён", color=discord.Colour.blurple())
         await ctx.send(embed=embed)
示例#6
0
 async def roleunslowdown(self,
                          ctx,
                          role: discord.Role,
                          subchannel: discord.TextChannel = None):
     if await db_load_req(
             f"SELECT COUNT(*) as count FROM muteroles WHERE id = {role.id} AND guild_id = {ctx.guild.id} AND channel_id = {subchannel.id if subchannel is not None else None}"
     ) == 1:
         cur = data.cursor()
         cur.execute(
             f"DELETE FROM muteroles WHERE id = {role.id} AND guild_id = {ctx.guild.id} AND channel_id = {subchannel.id if subchannel is not None else None}"
         )
         data.commit()
         await ctx.message.add_reaction(agree_emoji())
         embed = discord.Embed(title=f"Медленный режим у {role} отключён",
                               color=discord.Colour.blurple())
         await ctx.send(embed=embed)
     else:
         await ctx.message.add_reaction(disagree_emoji())
         embed = discord.Embed(
             title=f"{disagree_emoji()} Ошибка",
             description=
             "Невозможно отключить медленный режим у пользователя, ведь он уже отключён.",
             color=discord.Colour.red())
         await ctx.send(embed=embed)
示例#7
0
    async def setup(self, ctx):
        try:
            guild_language = await get_guild_language(ctx)
        except:
            guild_language = "en"
        embed = discord.Embed(title=f"{loading_emoji()} Инициализация",
                              description="Пожалуйста подождите...",
                              colour=discord.Colour.blurple())
        emb_message = await ctx.send(embed=embed)
        await asyncio.sleep(1)
        embed = discord.Embed(title="Инициализация завершена")
        count = await db_load_req(
            f"SELECT COUNT(*) as count FROM guilds WHERE id = {ctx.guild.id}")
        if count == 0:
            if str(ctx.guild.region) == "russia":
                language = "ru"
            else:
                language = "en"
            guildvalues = (ctx.guild.id, str(ctx.guild.name), 1, time.time(),
                           bool(1), 0, 0, language)
            cur = data.cursor()
            cur.execute("INSERT INTO guilds VALUES(?, ?, ?, ?, ?, ?, ?, ?);",
                        guildvalues)
            data.commit()
            embed.add_field(name=f"База данных: {agree_emoji()}",
                            value="Данные занесены в базу данных")
            if embed.colour != discord.Colour.orange(
            ) and embed.colour != discord.Colour.red():
                embed.colour = discord.Colour.green()
        elif count == 1:
            embed.add_field(name=f"База данных: {agree_emoji()}",
                            value="Всё в порядке")
            if embed.colour != discord.Colour.orange(
            ) and embed.colour != discord.Colour.red():
                embed.colour = discord.Colour.green()
        else:
            print('DataBaseError', ctx.guild.name, ctx.guild.id,
                  datetime.now())
            await developer().send(
                f'DataBaseError {ctx.guild.name} {ctx.guild.id} {datetime.now()}'
            )
            embed.add_field(name=f"База данных: {disagree_emoji()}",
                            value="Критическая ошибка")
            embed.colour = discord.Colour.red()
            await ctx.send(
                "Критическая ошибка базы данных, разработчик уже извещён о проблеме"
            )

        Bot = ctx.guild.get_member(750415350348382249)
        if Bot.guild_permissions.manage_messages and Bot.guild_permissions.manage_roles:
            embed.add_field(name=f"Права: {agree_emoji()}",
                            value="Всё в порядке")
            if embed.colour != discord.Colour.orange(
            ) and embed.colour != discord.Colour.red():
                embed.colour = discord.Colour.green()
        else:
            embed.add_field(name=f"Права: {warning_emoji()}",
                            value="Отсутствуют некоторые необходимые права")
            if embed.colour != discord.Colour.red():
                embed.colour = discord.Colour.orange()
            await ctx.send(
                "Проверте права бота, возможно у него отсутствуют права: Управление сообщениями, Управление ролями"
            )
        await emb_message.edit(embed=embed)