i try:
discord.utils.get(client.get_all_emojis(), id=469334117020991508)
but this return none every time
I would like to get the url custom emoji from chat text.
Your code should work - you're using get_all_emojis() correctly. The most likely reason that it is returning None is that there is no emoji with that id. Try something like print(list(client.get_all_emojis())) and see if there is actually an entry with that id.
Related
I am programming an entertainment bot with discord.py, and I want to code a function that allows you to look at other users' in game money and stuff with replit databases. Since making data with a user tag is inefficient since people change their usernames and tags all the time, I am using IDs. I am trying to find a way to get a user tag (eg. Dude#1234) from a user number id (eg. 871954599731396648). I couldn't find a solution. I already know how to use ctx.message.author.id but I can't find a way to make that work with every discord user.
To get the tag you can use the following method
user = await bot.fetch_user(ID) # ID must be an int and this could be could be client for you, be careful as this pings the API and can be abused if not correctly limited.
# user.discriminator will return their tag.
You can check all attributes that user can have here
To get the tag, you first have to get the user object from the id using discord.utils.get:
user_id = #insert the id of the user which you want the tag of
user = await discord.utils.get(client.get_all_members(), id =user_id)#might by something like bot.get_all_members for you
tag = user.name
I am creating a bot command that allows the user to create nice looking embeds on the server.
#bot.command()
async def embed(ctx,title_str,text_str,url_str, feildname_list):
my_embed=discord.Embed(title=title_str, url=url_str, description=text_str, color=0xFF5733)
await ctx.send(embed=my_embed)
currently feildname_listis unused.
what i'd like to do is to create a series of inline fields using the names from fieldname list, with an ascending integer in them.
like this:
Using the documentation I found this command
add_field(*, name, value, inline=True)
which works- but felt inelegant. It feels like there should be a way of adding the fields as a key word argument when I am creating my_embed- but i can't see one in the documentation. Is there such a way?
no, there isn't a way to do what you ask
O = discord.PermissionOverwrite()
O.manage_webhooks=True
User=get(ctx.guild.members, name="User1")
await chan.set_permissions(User, overwrite=O)
What I'm doing wrong?
I get no errors but the channels permission for the member doesn't change.
Help me please.
First, there's a built in method called get_member that I strongly suggest you use, simply using a user name is pretty easy to get messed up as someone could just change their name. But it seems your code is rather sound, so some more information (if you need to use user name) such as how you're calling this and what get exactly is would help a ton!
Do list cards in teams still work?
I want to try out a simple list card with support for scrolling.
However, I cannot get it working in App Studio(Card Editor) or from the code.
I do not see any way of sending a list card using CardFactory as well.
Yes, they definitely still do work, I happened to test one this morning. You're right though that App Studio's Card Editor doesn't support them though, and CardFactory doesn't have a mechanism for them either, so you either need to create the JSON object explicitly, or use a JSON string.
I'm using C#, so can't send you a code sample, but it should just be a case of making sure your final output matches the correct format for List Cards
The list card sample json is here - https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-reference#list-card
This cannot be tested in the Adaptive cards designer - https://adaptivecards.io/designer
I got this working by using the following code in Java
Attachment attachment = new Attachment();
attachment.setContentType("application/vnd.microsoft.teams.card.list");
attachment.setContent(createCardJson("ListCard.json")));
Activity act=MessageFactory.attachment(attachment);
We have to change the ListCard.json to just have the content part of the json (from the link above) stored with the file. The content type is set with the attachment object
I was wondering if anyone know how to get preferred channel layout from CoreAudio. I try to use kAudioDevicePropertyPreferredChannelLayout to get the channel label. However, it always shows kAudioChannelLabel_Unknown value. Is there something driver issue? or it's necessary to set some properties before asking kAudioDevicePropertyPreferredChannelLayout.
my code is here:
https://gist.github.com/ChunMinChang/ea74c8228745449873716e1d98ba956e/e61fedea3e08bcff64ef3db05931a1c757768d70
Answer by myself.
Instead of kAudioDevicePropertyPreferredChannelLayout, Using kAudioUnitProperty_AudioChannelLayout allow me to get the correct channel configuration.
Maybe it would be better if we use kAudioDevicePropertyPreferredChannelLayout to get the layout first. If it returns Unknown, then we use kAudioUnitProperty_AudioChannelLayout to get it.
Code: https://gist.github.com/ChunMinChang/ea74c8228745449873716e1d98ba956e/96b5d39e3fa7d5d6e160c53917b213f9af3ba2c9#file-preferredchannellayout-cpp