Getting an image of a custom Discord embed - python

I need to programmatically get an image of a Discord embed. Here is an example of the kind of embed I mean.
I want to get an image like that without having to take a screenshot of the application myself. I'm hoping there's an easy way to get them, otherwise I may have to generate the images myself. I'm using discord.py.

You can use Message.embeds, then get the embed.image.url from the returned list.
For example, if you have a message object, my_message, you can do the following:
image_url = my_message.embeds[0].image.url
(This is assuming you've already got the message object. You can do this a number of ways, e.g. in your on_message event.)

Related

Edit message with VideoNote in Telebot

How can I edit VideoNote message and change old video note to another one in Telebot? I guess I need edit_message_media method, but I don't understand how to use it for video notes.
I've tried to do it this way:
bot.edit_message_media(chat_id=message.chat.id, message_id=message.message_id,
media=types.VideoNote(open("video.mp4", "rb")))
But it didn't work.
It seems it is impossible as for now (December 2022).
Telegram API has these methods for updating messages: editMessageText, editMessageCaption, editMessageMedia, editMessageReplyMarkup, stopPoll, deleteMessage,
The closest one is editMessageMedia but it expects InputMedia which in turn should be one of InputMediaAnimation, InputMediaDocument, InputMediaAudio, InputMediaPhoto, InputMediaVideo, but not VideoNote
Also, I tried editing this kind of message using the official Android and Windows clients but didn't find such an option.
I assume Telegram doesn't have this option at all.

Is there a way, using discord.py to send emojis without adding to their id number

When I send a message to discord, I constantly reach the character limit. This is due to having 3-20 emojis which all take up 25+ characters. I only want to send to one discord server so conflicting names isn't really the issue. Is there a way to send emojis without their id, thus reducing each emoji to a mere 5-10 characters.
I'm aware that you can send two messages, but I'd prefer to avoid this as it can get somewhat clunky.
Thanks :)
Currently I am just putting "<:EMOJINAME:emojiIDNUM>" as I have no idea how to solve this. They are custom server emojis.
Unfortunately, you can't use the "ID" of the emojis as they are all unique after you posted them.
If you want to use standard emojis you can have a look at https://unicode.org/emoji/charts/full-emoji-list.html. Just copy and paste the emojis.
But if you want to use emojis which are not from Discord you can post the emoji somewhere and add a \ to get the unicode/shorter "version" we can call it. This you copy and paste, but then you must not delete the message. Mostly the emoji must be on the server.
For a Discord emoji:
:white_check_mark: = :white_check_mark:
\:white_check_mark: = ✅
For a Unicode emoji:
:close: = :close:
\:close: = <:close:741224892984197120>
Adding this to your code should help to reduce it.

Is it possible to add a custom reaction image file from your computer to your message using discord.py?

I'm trying to add two custom emojis to my bot's message. To add the custom emoji, I may have to buy discord nitro/prime to use it in other servers if I'm not mistaken. Is there any way to use my custom emojis without having to spend any money?
I was thinking if it was possible to read an image from my computer files and then turn it into a custom reaction for my bot to use. So far, I have no code because I don't really know how to work with Pillow and Image Editing in Python/Discord.py
You can use create_custom_emoji().
Usage:
server = discord.utils.get(client.guilds, id=123456789) # your server's ID
with open("PATH TO YOUR IMAGE", "rb") as image:
server.create_custom_emoji(name="EMOJI NAME", image=image)
Here's the page in the docs: https://discordpy.readthedocs.io/en/latest/api.html?highlight=create_custom_emoji#discord.Guild.create_custom_emoji
SOLUTION
I basically just have to get the id of an emoji and then the name of it. You get the id by copying the link of the reaction you want. Just right click on it and copy link. After copying the link, paste it into your browser, you should see your emoji pop up into your browser.
For example, this link https://cdn.discordapp.com/emojis/755076996945543208.png?v=1. I just need to copy the numbers, which are 755076996945543208.
After getting the id, we need to get the emoji name. Which is pretty easy, I'm sure everybody knows how to do that.
After getting the emoji name and id all you have to do is this.
#client.command()
async def poll(ctx, *, message):
msg = await ctx.send(f"**{message}**")
await msg.add_reaction(emoji="name_of_emoji:emoji_id")
Thanks to everybody who participated and contributed to this question, I appreciate your help. :D

How would I convert my discord.py discord bots code that I use to get a list of members in a voice channel to the new discord.py version?

I have a command that creates of list of members in a specific voice channel. For example !attendance general for the "general" voice channel. My issue is that some of the parts no longer work since i was using an older version of discord.py.I recently ran the cmd line to upgrade discord.py and it seems a bunch of commands are now different.
My question is how do I get a specific channel and find its member list now? Below is my old code that no longer works.
https://i.imgur.com/TP8He1X.png
The part of code thats causing trouble is in the link. basically it loops through all voice channels for a specific one named general, then goes through each user in voice and checks if they have the tag "guest". If they do it adds to a list.
It seems that im not able to get a list of channels or loop through the members using ch.voice_members anymore, does anyone know the new formatting/commands for these issues?
Im summary I need to find commands for being able to check if a channel matches and then a way to loop through all the users.
I took a look at the discord.py docs - https://discordpy.readthedocs.io/en/latest/api.html
looks like you can change
for user in ch.voice_members
to
for user in ch.members
Looks like there are no longer separate properties for member lists

Telegram API trouble with article Python

Good day, how i can upload image/photo on method answerInlineQuery in parameter 'article'? how it' work on #imdb bot:
Because when i send image in parameter 'message_text' it's not always loaded.
That image from your example was grabbed from the link included in message.
You can set parse_mode=HTML and make a link to your image around unbreakable space like this:

Categories

Resources