I am looking to put an invite link to my bot in the description of the embed as a hyperlink. I want it to display something similar to click here and then lead to the bot's invite link. If anybody knows how to do this, if you could please advise me that would be great! :)
Like so: [text to click](url)
Note: This won't work in the title, footer or field titles, if you want a hyperlink in the title use the url kwarg
You can do:
async def invite(ctx):
embed = discord.Embed(
color= discord.Colour.dark_teal() # or any color you want
)
embed.add_field(name='If you wish to add me in your server,' ,value='[Click here to add]( bot link )', inline=False)
await ctx.send(embed=embed)
You can put hyperlinks in this way just in field value.
Related
This is my embed rn
It uses the google API to get upcoming events on a calendar but I have to limit the number of events it gets since the message will be too long. The list of calendars is stored in the description of the embed. Is there any way to limit the embed to a certain size and be able to scroll down in the description so all events can be displayed?
As Zimano said, you can't have scrollable elements in embeds, but what you can do is a multi-page embed, the easiest approach would be with ext.menus (To install it: python -m pip install -U git+https://github.com/Rapptz/discord-ext-menus)
import discord
from discord.ext import menus
class MultiPageEmbed(menus.ListPageSource):
async def format_page(self, menu, entry):
return entry
#bot.command()
async def whatever(ctx):
# Put all your embeds here
embeds = [discord.Embed(title="Embed 1"), discord.Embed(title="Embed 2"), discord.Embed(title="Embed 3")]
menu = menus.MenuPages(MultiPageEmbed(embeds, per_page=1))
await menu.start(ctx)
Unfornatelly it's still in beta so there's no docs about it.
No, you can't add scrollable elements in embeds.
I have attempted this as my code.
#client.command()
async def party(ctx):
party = client.get_emoji(786138532069900350)
await ctx.send('{}'.format(party))
but it replies as None
It's an animated default discord emoji Emoji
So what am I doing wrong?
To send an animated emoji you should find the emoji name and the emoji id..
To send a normal emoji we use this format:
<:emojiname:emojiid>
To send an animated one we use:
<a:emojiname:emojiid>
After that you need to edit your code as follows..
#client.command()
async def party(ctx):
party = "<a:youremojiname:emojiid>" #assigning the emoji
await ctx.send(party) #sending the emoji
Or if none of these methods work, simply send it like:
await ctx.send("https://cdn.discordapp.com/emojis/836234327016210482.gif?v=1")
With a some research I found https://github.com/Rapptz/discord.py/issues/390:
Basically what it includes to use custom emojis
To use a custom emoji, you use the emoji name, then it's id which can be
extracted from the middle id from its link id.
For example, the id of this emoji is:
Original link: https://cdn.discordapp.com/emojis/3489241209391.png?v=1
Emoji id: 3489241209391
In the example shown below, it would appear as the emoji when sent in a message
<:emoji_name:emoji_id>
example: <:myemoji:3489241209391>
With an animated emoji is the same, but append an "a" at the front
<a:emoji_name:emoji_id>
I have noticed that your get_emoji variable name is party, the same as command (or function's) name, That's why it is returning None. Please change the variable name to something other then function's name.
Example:
#client.command()
async def party(ctx):
partyemoji = client.get_emoji(786138532069900350) # problem was here
await ctx.send(partyemoji) # instead of formatting string simply use variable name.
P.S: If it still returns None check if your emoji ID is valid or not.
my bot should make embeds from all messages in a specific channel. He deletes every message, that's not in an embed and puts them automatically in an embed. Now, that's working, but I have problems with the pictures that my users upload.
My question: How can I save the picture that uploaded a user in a "log-channel" and get the new discord image link from that picture?
I need the "new discord image link" to put it in the embed.
a discord.Message instance holds the attachments attribute, which will get you a list of the attachments to a message. You can then use discord.Attachment.to_file() to get a discord.File instance, which you can use in an embed.
Example:
message = SomeMessageInstance
# realistically you should be looping over the attachments, and sending an embed for each
file = await message.attachments[0].to_file()
file.filename = 'image.png'
embed = discord.Embed()
embed.set_image(url='attachment://image.png')
await Channel.send(file=file, embed=embed)
I have tried for what feels like hours to get the Composer to send a suggestion back to the user. I want the suggestion, if clicked, to open another website.
First, I created a template:
# urlCard(title, value)
[CardAction
Type = openUrl
Title = ${title}
Value = ${value}
]
This works fine if I use it from a hero card, for example:
[HeroCard
title = Click that button
text = This is a test hero card
buttons = ${urlCard( 'Google', 'https://google.com/' )}
]
But I cannot get suggestions to work with [Suggestions:
[Suggestions
SuggestionActions = ${urlCard( 'Google', 'https://google.com/' )}
]
This is what I see in the Bot Framework Emulator:
How can I send suggestions to the user, without being in a hero card?
I have no experience with the Composer but I can tell you how the Python API works and maybe it can help you to figure this out.
In Python (JS is very similar) you would do something like:
CardAction(title="Yes?", type=ActionTypes.im_back, value='yes')
CardAction(title="No?", type=ActionTypes.im_back, value='no')
The suggested actions disappear after the user makes a selection and the bot will receive a message with the action value. I don't think you can embed a URL however, so maybe this is the actual issue you have.
This worked for me:
[Activity
SuggestedActions = ${openUrl( 'Google', 'https://google.com/' )}
]
Nice telegrm bot's menu
I'm found an interesting menu on Telegram's #ShopBot
So right how i want to make menu for my bot, just like this one.
Where coud i find code examples or tutrorals how to make checkbox-like buttons like in this menu using python-telegram-bot framework ?
Try it:
#bot.message_handler(commands=['menu'])
def menu(m):
cid = m.chat.id
menuKeyboard = types.InlineKeyboardMarkup()
menuKeyboard.add(types.InlineKeyboardButton('Button1', callback_data='button1'),
types.InlineKeyboardButton('Button2', callback_data='button2'))
bot.send_message(cid, "Menu", reply_markup=menuKeyboard)