2
I am playing a little with the library Discord in python, but I got a problem.
When I want to get the name of the user who sent the message, and the id and I believe that everything that references the user data the format that comes back is as if using pr and not print.
That’s the code I got
import discord
from discord.ext import commands
intents = discord.Intents.default()
bot = commands.Bot(command_prefix='dia-', description=description, intents=intents)
@bot.event
async def on_ready():
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print('-*-*-*-*-*-*-*-*-*-')
@bot.command()
async def info(ctx, user = discord.Member):
await ctx.send(f'{user.mention}\'s id: `{user.id}`')
bot.run('token')
When I go to Discord and use the prefix "dia-" and put the command "info" (dia-info) this is the output I have in Discord
<property object at 0x000001C8E4F2ACC0>'s id: <property object at 0x000001C8E4F342C0>
I would like my name and id to appear in the Discord, but I have no idea how to proceed!
The method to be called is not
owner_id
? This is what it looks like to take a quick look at the documentation: https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#Discord.ext.Commands.Bot– Lucas
In this case will call the creator of the bot, what I want is what will get the id of the user who sent the message. I believe that although this was the case, the problem is not in the id itself, but in the form that it appears as "<Property Object at 0x000001C8E4F342C0>". But thanks for taking the time to even look at the doc bro!
– Elias Oliveira
is that "<Property Object at 0x000001C8E4F342C0>" is the location the object is in memory. This happens when the method
__repr__
is not set to the object. So I think you should look for the information you want in another object method. Pass a dir on the object and see if you have any method that might have the information you want.– Lucas