Reputation: 121
I am trying to send local images through discord Embed to a list of servers. My bot is hosted in Amazon cluster. I can see images in embed on my laptop where I send the command, but some users (including myself from my phone) may not see some of those images in embeds. See example picture at the end of this post. It seems it depends on the end device, windows/MAC, iPhone/Android, which is weird. Following is the command function. This function gets an image and a text and makes an embed.
@commands.command(name='img', help='How to use command')
async def img(self, ctx, *, msg: str):
await ctx.channel.purge(limit=1)
try:
embed = discord.Embed(title='Title \n',
description=f'{msg} \n\n',
colour=discord.Colour.dark_blue())
embed.set_footer(icon_url=ctx.author.avatar_url,
text="footer text")
embed.timestamp = datetime.utcnow()
if len(ctx.message.attachments)>0:
attachment = ctx.message.attachments[0] # gets first attachment in the message
embed.set_image(url=attachment.url)
_channels = [self.client.get_channel(channel_id) for channel_id in self.discord_channels['id']]
for channel in _channels:
try:
await channel['channel'].send(embed=embed)
except Exception as e:
print(e)
except Exception as e:
print(e)
where self.discord_channels['id']]
is a list of channel IDs to which the embed should be sent. But, the image inside the output embeds, while being seen on my device may not be visible by "some" other users.
Any idea how I can solve this? Ideally, I like to take a screenshot and just paste it on discord along with using this command (instead of saving it first as an image file on hard drive and then using the upload button while using this command).
Upvotes: 1
Views: 1027
Reputation: 121
I was able to solve it by changing reading from URL to proxy_url embed.set_image(url=attachment.proxy_url)
, but also not deleting the original command when the embed is being constructed. I just save the msg_id of the command and then delete it at the end of the function (when embed are sent to all servers), using that msg_id.
Upvotes: 1