How do I DM a user with ID gotten via embed footer?

dante_nl

I'm trying to get a user's ID via a message ID; the ID of the user I want to send a DM to is in the embed's footer. I'm using this code for it:

msg = await ctx.channel.fetch_message(id)
id2 = int(msg.embeds[0].footer.text)
print(type(id2))
await ctx.send(id2, hidden=True)
# Everything works fine ^
# Everything breaks below
user = client.get_user(id2)
print(type(user))
await ctx.send(user, hidden=True)
await user.send("IT WORKED!!!")

I added some debugging code and it appears to break when it tries to convert it to a user in user = client.get_user(id2). It converts it into nothing; I saw that with the type() function, and in the error:

An exception has occurred while executing command `answer`:
Traceback (most recent call last):
  File "/Users/dante_nl/Library/Python/3.8/lib/python/site-packages/discord_slash/client.py", line 1185, in invoke_command
    await func.invoke(ctx, **args)
  File "/Users/dante_nl/Library/Python/3.8/lib/python/site-packages/discord_slash/model.py", line 209, in invoke
    return await self.func(*args, **kwargs)
  File "/Users/dante_nl/Library/Mobile Documents/com~apple~CloudDocs/Ask/bot.py", line 105, in _answer
    await ctx.send(user, hidden=True)
  File "/Users/dante_nl/Library/Python/3.8/lib/python/site-packages/discord_slash/context.py", line 239, in send
    resp = await self._http.post_followup(base, self._token, files=files)
  File "/Users/dante_nl/Library/Python/3.8/lib/python/site-packages/discord/http.py", line 254, in request
    raise HTTPException(r, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message

I'm not sure why it does this, it got the ID from the embed's footer, converted it to a number, but it can't convert it to a user and send a DM to that user.

Thanks in advance!

Note: I'm using slash commands, not sure if that makes any difference.

CoolCoder

You can use:

await client.fetch_user(id2)

If this does not work, then maybe id2 is not a valid user id.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I dm a user only with the ID?

How do I make a command in discord.py that sends a dm to a user that i put thei user id?

discord.py :: How do I make on_message_delete ignore a certain user / role via an embed?

How can I Send DM to certain user with ID?

How can I DM the user an embed before he is kicked (discord.js)

How do I DM a user when a reaction is added to a message?

how can i pass the input gotten from user to the tool in langchain

How do I send a embed when a user joins the guild?

How do I mention a user with the blue highlight in Discord Embed?

I can't send a DM to a user using user ID

How can I get my bot to DM a specific user ID without a command given?

How do I send a DM to a user in discord.js v13

How do I fix this mess I've gotten myself into, nav bar

How do I return two values gotten from a loop done with PySNMP?

How do I convert a file path gotten from env::current_exe() to a string or str?

How do I update listview with button when list is gotten from a directorychooser?

how to send DM message to user with his ID Node js

Discord.JS embed: User avatar in footer

How do I change the hard code user id into the authenticated user?

How do i code so that my button after clicking will direct user to the footer in the same html?

How do I add user's avatar in embed title? discord.py

DM'ing a specific user ID

Is it possible to DM someone with their user ID?

How do I make the footer content all in the center of the footer?

How do I stream market data via SignalR that a user subscribes to

How do I reference a model via User model in Django?

How do I get groups for a user via libc::getgroups?

How do I switch OS user in Datagrip to Postgres via SSH?

How do I receive an incoming message for a user via Twilio Connect?