Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Get image url from message in discord.py

i’m trying to get the url of image when i do the command +coin but I d’ont know if I do it right.
if someone can help me i’ll very appreciate it.

@Bot.command()
async def coin():
  print(message.attachments[0].url)
  await ctx.send("work")

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Your close for that to work you first need to get the ctx
in your function like this then you need to get the URL that the user sent. The way that I would do it is like this.

async def coin(ctx):

This will create the function.
Then it is simply getting the rest of the code set up for that image.

The rest of the code should look like this

print(ctx.message.attachments[0].url)
await ctx.send("work")

Here is an example of the full code:

@bot.command()
async def coin(ctx):
  print(ctx.message.attachments[0].url)
  await ctx.send("work")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading