#🔒 need help with this specific code for my discord bot

17 messages · Page 1 of 1 (latest)

lusty temple
#

ive tried everything to fix this part of the code but i just cant fix the problem

        member = guild.get_member(entry["user_id"])
        # THIS IS THE PROBLEM LINE
        name = member.mention if member else f"<@{entry['user_id']}>"
        
        status = f"{entry['status']} âš¡" if entry.get("fastpass") else entry["status"]
        
        embed.add_field(
            # THE MENTION IS PLACED IN THE 'NAME' FIELD BELOW
            name=f"#{i} - {name}", 
            value=f"**Status:** {status}\n**Order:** {entry.get('order', 'N/A')}",
            inline=False
        )```
golden heronBOT
#

Hey @lusty temple!

Please edit your message to use a code block

Add a py after the three backticks.

```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
golden heronBOT
#

@lusty temple

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

lusty temple
#

i want it show a mention like @lusty temple but instead it just does <@

crystal lava
#

Otherwise mentions are structured as f"<@{member.user_id}>"

lusty temple
#

i actually just fixed it

crystal lava
#

Yeah I don't think you're getting a reliable response when you use get_member (could be a permissions issue that you have to tweak a setting in the discord dev page for), so I'd lean towards the formatting I mentioned above for the mention, but it won't work as embed title

lusty temple
crystal lava
lusty temple
#

this is what worked for me

#

name = f"<@{entry['user_id']}>"

crystal lava
#

Yeah, looks about the same as what I ended up suggesting anyways. See if you can print out the member.display_name in the same embed as well. I think your bot needs some permissions it doesn't currently have configured either.

golden heronBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.