X
X
x4zx2021-11-28 17:01:54
Python
x4zx, 2021-11-28 17:01:54

How to solve list issue in mongodb?

Hello, I'm making a bot ticket. I ran into a problem that when I add a person to the blacklist (so that he cannot create a ticket) and this person clicks on the button to create a ticket, it is created. Although it shouldn't.

Here is the code:

Add a person to the blacklist

@bot.command()
    @commands.bot_has_permissions( manage_roles = True, manage_channels = True, send_messages = True, embed_links = True, read_message_history = True )
    @commands.has_permissions( administrator = True )
    async def addblacklist(ctx, member: discord.Member = None):

        support = ctx.guild.get_role(collticku.find_one({'_id': ctx.guild.id})['support_id'])

        if support in ctx.author.roles:
            if member is None:
                emb1 = discord.Embed(
                    description = 'Укажите участника, для занесения в черный список.',
                    colour = 0x2F3136
                )
                await ctx.reply(embed = emb1, delete_after = 5)
            else:
                collticku.update_one({'_id': ctx.guild.id}, {'$inc': {'blackl': +1}, '$push': {'member': member.id}})
                emb2 = discord.Embed(
                    description = f'Вы успешно занесли ({member.mention}) в черный список.',
                    colour = 0x2F3136
                )
                await ctx.send(embed = emb2, delete_after = 5)
        else:
            emb3 = discord.Embed(
                description = 'Вы не являетесь службой поддержки и не можете заносить участников в черный список.',
                colour = 0x2F3136
            )
            await ctx.reply(embed = emb3, delete_after = 5)


Checking if a person is blacklisted
def blacklist(inter, guild):
       member = inter.author
       blackl = collticku.find_one({'_id': guild.id}['member'])
       return member.id in [blackl['member']]


Data image in the database - https://yapx.ru/v/PT0q3

Thanks in advance!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question