Skip to content

Instantly share code, notes, and snippets.

@scragly
Created October 28, 2018 03:27
Show Gist options
  • Save scragly/bbc8982bc3ea11a6c81c8dcc631c89a2 to your computer and use it in GitHub Desktop.
Save scragly/bbc8982bc3ea11a6c81c8dcc631c89a2 to your computer and use it in GitHub Desktop.
Local Image File Usage in Embeds
f = discord.File("some_file_path", filename="image.png")
e = discord.Embed()
e.set_image(url="attachment://image.png")
await messagable.send(file=f, embed=e)

This allows you to use a local image located with the bots files, instead of uploading first and then specifying that uploaded image's url.

@camckee316
Copy link

i have a command but the image is different each time the command is used, like when searching for pokemon. so how can i use a local for that pokemon and display it.

@wizcreations7
Copy link

wizcreations7 commented Dec 18, 2022

i have a command but the image is different each time the command is used, like when searching for pokemon. so how can i use a local for that pokemon and display it.

Just load all of the images into an array and use a random math function if you want to select a random image. If not, then name your pictures the name of the pokemon and grab that image. Shouldn't be difficult. Just use .setImage('attachment://yourfilepath') in your embed builder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment