Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

202
Visualizações
How can I find different parts of the same mongodb entry in discord.py

I am currently working on a system that deletes a channel when the user leaves. This system works by, when a user asks for it, a command is used to create the channel and the member id and channel id are stored in mongodb, as shown in the picture below:

MongoDB Collection

My current code for this is:

  @commands.Cog.listener()
    async def on_member_remove(self, member):
        channelfind = cluster["Channels"]["info"]
        if member.guild.id == testid:
            joinedat = diskord.utils.utcnow() - member.joined_at
            time = humanize.precisedelta(joinedat, format="%0.0f")
            embed = diskord.Embed(title="\u200b", color=0xfc8eac)
            embed: Embed = diskord.Embed(
                description= f'**{member.mention} left the server**\n:timer: **Joined:**\n{time} ago',
                color=0xfc8eac
            )
            embed.set_author(name=member, icon_url=member.avatar.url)
            embed.set_thumbnail(url=member.avatar.url)
            embed.timestamp = datetime.datetime.utcnow()
            embed.set_footer(text=f'ID: {member.id} \u200b ')
            memberid = channelfind.find_one({"member_id": member.id})
            if memberid is not None:
                
                log = testlog
                await self.bot.get_channel(log).send(embed=embed)
            else:
                pass

However, I am not sure how I can find the channel_id that is with the member_id of the user who has left

Any help would be appreciated thank you!

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

.find_one() returns a dictionary representing the document. So, you can do

memberid = channelfind.find_one({"member_id": member.id})
print(memberid['channel_id'])

to get the channel_id.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda