Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

198
Views
¿Cómo puedo encontrar diferentes partes de la misma entrada de mongodb en discord.py?

Actualmente estoy trabajando en un sistema que elimina un canal cuando el usuario se va. Este sistema funciona, cuando un usuario lo solicita, se usa un comando para crear el canal y la identificación del miembro y la identificación del canal se almacenan en mongodb, como se muestra en la imagen a continuación:

Colección MongoDB

Mi código actual para esto es:

 @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

Sin embargo, no estoy seguro de cómo puedo encontrar el channel_id que está con el member_id del usuario que se fue.

Cualquier ayuda sería apreciada gracias!

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

.find_one() devuelve un diccionario que representa el documento. Entonces, puedes hacer

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

para obtener el channel_id .

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!