Пример #1
0
    async def bunnysetup(self, ctx, *, id_post):
        id_post = id_post + '-'
        id_build = ''
        user_ids = []
        dates = []
        i = 0

        for char in id_post:
            if char == '\n' or char == ',':
                if i % 2 == 0:
                    user_ids.append(id_build)
                else:
                    dates.append(id_build)
                id_build = ''
                i = i + 1
            else:
                id_build = id_build + char
        
        i = 0
        while i < len(user_ids) and i < len(dates): #Doesn't update the DB, only adds to it
            path = settings.DB_PATH + user_ids[i] + '.json'
            db = TinyDB(path)
            member = Query()
            table = db.table('information')
            table.upsert({'last_seen' : dates[i]}, member.last_seen != None)
            i = i + 1
            formatting.fancify(path)
Пример #2
0
    async def color(self, ctx, hex_color):
        db = TinyDB(settings.DB_PATH + str(ctx.author.id) + '.json')
        table = db.table('boost')
        member = Query()

        if hex_color[0] == '#':
            hex_color = hex_color[1:]
        hexadecimal = int(hex_color.lower(), 16)

        try:
            role_id = table.get(member.role_id != None)['role_id']
        except TypeError:
            category = ctx.guild.get_role(settings.BOOSTER_CATEGORY)
            role = await ctx.guild.create_role(
                name=str(ctx.author.id),
                mentionable=True,
                color=discord.Color(hexadecimal),
                reason=f'{ctx.author.name} booster role create')
            role_id = role.id
            await ctx.author.add_roles(role)
            await asyncio.sleep(1)
            await role.edit(position=category.position - 1)

            path = settings.DB_PATH + str(ctx.author.id) + '.json'
            db = TinyDB(path)
            member = Query()
            table = db.table('boost')

            table.upsert(
                {'role_id': role.id}, member.role_id !=
                None)  #If conditional is True: update. If False: insert.
            formatting.fancify(path)

        role = ctx.guild.get_role(role_id)

        try:
            await role.edit(color=discord.Color(hexadecimal))
        except AttributeError:
            category = ctx.guild.get_role(settings.BOOSTER_CATEGORY)
            role = await ctx.guild.create_role(
                name=str(ctx.author.id),
                mentionable=True,
                color=discord.Color(hexadecimal),
                reason=f'{ctx.author.name} booster role create')
            await ctx.author.add_roles(role)
            await asyncio.sleep(1)
            await role.edit(position=category.position - 1)

            path = settings.DB_PATH + str(ctx.author.id) + '.json'
            db = TinyDB(path)
            member = Query()
            table = db.table('boost')

            table.upsert(
                {'role_id': role.id}, member.role_id !=
                None)  #If conditional is True: update. If False: insert.
            formatting.fancify(path)
        await ctx.send(content=f'{role.mention}\nHere\'s your new custom role!'
                       )
Пример #3
0
def activity_push(m, d):
    #entered activity_push
    d = str(datetime.now().date())
    for i in m:
        path = settings.DB_PATH + str(i) + '.json'
        db = TinyDB(path)
        member = Query()
        table = db.table('information')
        table.upsert({'last_seen': d}, member.last_seen !=
                     None)  #If conditional is True: update. If False: insert.
        formatting.fancify(path)
Пример #4
0
    async def unboost_upd(self, before, after):
        await Events.global_assignment(self)
        if self.booster_role in after.roles and self.booster_role not in before.roles and self.verified_role in after.roles:
            path = settings.DB_PATH + str(after.id) + '.json'
            db = TinyDB(path)
            table = db.table('boost')
            member = Query()
            role_id = table.get(member.role_id != None)['role_id']

            table.remove(member.role_id != None)
            table.remove(member.emote_id != None)
            formatting.fancify(path)

            role = self.guild.get_role(role_id)
            await role.delete(reason=f'{before.name} is not longer boosting')
Пример #5
0
    async def log_block(self, member):
        channel = self.bot.get_channel(settings.TURNOVER_CHANNEL_ID)

        await channel.send(
            f':blue_heart: **__Joined:__** {member.mention} aka *{member.name}#{member.discriminator}* __\'{member.id}\'__ '
        )

        #handle the unfortunate double-joiner single-user event
        path = settings.DB_PATH + str(member.id) + '.json'
        db = TinyDB(path)
        member = Query()
        table = db.table('information')
        table.upsert({'last_seen': str(datetime.now().date())},
                     member.last_seen != None)
        formatting.fancify(path)
Пример #6
0
    async def emote(self, ctx, emote):
        try:
            emote = formatting.get_from_in(self.bot, ctx, "emo", emote)
        except TypeError:
            await ctx.send(content='Please select an emote from this server')
            return
        path = settings.DB_PATH + str(ctx.author.id) + '.json'
        db = TinyDB(path)
        table = db.table('boost')
        member = Query()

        try:
            emote_id = table.get(member.emote_id != None)['emote_id']
        except TypeError:
            #make the emote portion in the DB
            db = TinyDB(path)
            member = Query()
            table = db.table('boost')

            try:
                table.upsert({'emote_id': emote.id}, member.emote_id != None)
            except AttributeError:
                await ctx.send(
                    content='Please select an emote from this server')
                return

            formatting.fancify(path)

            emote_id = table.get(member.emote_id != None)['emote_id']

        try:
            if emote_id != emote.id:
                table.upsert({'emote_id': emote.id}, member.emote_id != None)
        except AttributeError:
            await ctx.send(content='Please select an emote from this server')
            return

        await ctx.send(content=f'{emote}\nHere\'s your new auto-react emote!')
Пример #7
0
    async def name(self, ctx, *, name):
        path = settings.DB_PATH + str(ctx.author.id) + '.json'
        db = TinyDB(path)
        table = db.table('boost')
        member = Query()
        try:
            role_id = table.get(member.role_id != None)['role_id']
        except TypeError:
            category = ctx.guild.get_role(settings.BOOSTER_CATEGORY)
            role = await ctx.guild.create_role(
                name=str(ctx.author.id),
                mentionable=True,
                reason=f'{ctx.author.name} booster role create')
            role_id = role.id
            await ctx.author.add_roles(role)
            await asyncio.sleep(1)
            await role.edit(position=category.position - 1)

            db = TinyDB(path)
            member = Query()
            table = db.table('boost')

            table.upsert(
                {'role_id': role.id}, member.role_id !=
                None)  #If conditional is True: update. If False: insert.
            formatting.fancify(path)

        role = ctx.guild.get_role(role_id)
        name = name.replace('\n', " ")
        namet = name.strip().lower()

        for role_temp in ctx.guild.roles:
            if role_temp.name.strip().lower(
            ) == namet or namet in settings.NAME_BLACKLIST:
                await ctx.send(
                    'A role with that name already exists. Please choose another.'
                )
                return

        try:
            await role.edit(name=name)
        except AttributeError:
            category = ctx.guild.get_role(settings.BOOSTER_CATEGORY)
            role = await ctx.guild.create_role(
                name=name,
                mentionable=True,
                reason=f'{ctx.author.name} booster role create')
            await ctx.author.add_roles(role)
            await asyncio.sleep(1)
            await role.edit(position=category.position - 1)

            db = TinyDB(path)
            member = Query()
            table = db.table('boost')

            table.upsert(
                {'role_id': role.id}, member.role_id !=
                None)  #If conditional is True: update. If False: insert.
            formatting.fancify(path)

        await ctx.send(content=f'{role.mention}\nHere\'s your new custom role!'
                       )