How to add reactions to messages in discord.py without id - discord

I am new to discord.py coding. I can't find the I'd for arrow up emoji... I've tried client.emojis and others but it doesnt work... pls help or send me all the ids or a website to see all the ids

just type your emoji in :this: form and stic an \ before the emojiname thats it!
when you send it it will come as <:something:1234567890123>
copy the numbers at the end thats your emoji id
same can be done with members and channels just instead of :this: do :#random_dude: and for channels do #general
hope this helps! Goodluck on your development!

I'm not sure what your code looks like, but if you're interacting with your 'message' asyncs you could do this.
emoji = '\N{THUMBS UP SIGN}'
# or '\U0001f44d' or '👍'
await message.add_reaction(emoji)
If you can, can you add your code so I can see where your error might be?

As zjbrown said, the thumbs up emoji can be stored in a string (and sent) using "\N{THUMBS UP SIGN}", "\U0001f44d", or "👍".
You can google a built-in emoji's name to find websites that have emoji descriptions. Sometimes these sites also have the unicode name, but this is not guranteed. If you want to send a custom emoji, you will have to find the emoji's id.
For built-in emojis, you can use RoboDanny's charinfo command (you'll have to add it to your own bot or use the RoboDanny bot in the discord.py support server) to get the unicode name.
If it is a custom emoji, you can send it in chat and get the image url (right click -> copy url). Then, look for the string of numbers before the .png and copy that. (Numbers only - don't copy the beginning of the url!) You can then send custom emojis by using the string <:[emoji name]:[emoji id]> for static emojis and <a:[emoji name]:[emoji id]> for animated emojis.

Related

How can I properly upload too long messages as a file?

I was doing some research on Discord's capabilities today, and then I noticed that the "upload as file" option is given when a message is more than 2000 characters long.
The number plays a role here, but my statement can also be wrong, the fact is that some things are posted only as a link and or then not sent at all if I raise >2000.
Here now the problem:
I am requesting data from Genius for a lyrics command. I already have some kind of override built in for when len(data["lyrics"]) is greater than 2000 "characters", that should be Discord's limit after all, otherwise the bot wouldn't be able to process the embed I am trying to send.
How can I manage that lyrics >2000 are sent as a file?
Relevant code:
if len(data["lyrics"]) > 2000:
return await ctx.send(f"<{data['links']['genius']}>"))
This is the normal request, it works too, but it just throws out the link.
I then tried to send this via discord.File with the corresponding piece of code above, does not work. (Something like file=discord.File(data) was tried too!)
Something like ctx.file.send does not work in this case either
The following posts were viewed:
Uploading a file in a embed discord.py (not a image)
Discord.py - Sending a text file on DM
Discord.py Bot sending file to Discord Channel
Python discord.py ways to split output to bypass 2000 character limit
What I want my bot to do if data["lyrics"] > 2000:
You can save the text into a io.StringIO buffer and pass that into the discord.File constructor:
from io import StringIO
text = data["lyrics"]
if len(text) > 2000:
buffer = StringIO(text)
f = discord.File(buffer, filename="lyrics.txt")
await ctx.send(file=f)

Approval/Denial System using Discord.js

DISCORD.JS
Hey! So, recently, I was on a server that contained an amazing bot. That was an approval or denial system. So, what would happen for example, somebody would sign a google form and the google script will send the response via a webhook (I already know that code) in an embed to a private channel named "awaiting-result", now, the bot will automatically add reactions to the message, for example, ✅ and ❌. Then, a staff member will react with either one of those emojis and it will send to two different channels. If the reaction was a ✅, then the bot will remove all reactions from the original message, copy the exact embed from the google form response, and send it to a channel named "accepted-logs" with a message above it "Your log has been accepted by ${person}". If it was an ❌, it will do the exact same thing as the approved one. I have been trying hard, but cant find it. All I ready need is the bot code, not the form script. So basically, you react, copy the exact embed, send to another channel. Itll be very helpful, thanks!
List of useful links:
https://discordjs.guide/popular-topics/reactions.html#unicode-emojis
https://discordjs.guide/popular-topics/collectors.html#reaction-collectors
https://discordjs.guide/popular-topics/embeds.html#using-the-embed-constructor
I'm pretty sure you could just store the embed contents in an Object, then you can wait for the collector to collect a ✅ or ❌, check if the user has admin role (e.t.c), and then find the channel the embed needs to be sent too
let channel = client.channels.cache.find(channel => channel.name === "name");
and then you can send the embed to the channel via
channel.send(embed);
In order to make an embed, you just do:
let embed = new Discord.MessageEmbed();
And then you can add fields to it (see link #3). Then you can simply just do
let approvalChannel = client.channels.cache.find(channel => channel.name = "admin-approval");
approvalChannel.send(embed);
// Code for reaction collector

Making Discord.py bot case-insensitive

Is it possible to use the case_insensitive attribute on the Discord client? I would like this so my bot can respond to any command even if the user called command contains uppercase or lowercase.
The case_insensitive attribute does not defy between bot or client, even so, it's not hard to change it. They are both able to use this attribute. You can easily enable your bot to be case insensitive by defining it in your client
client = commands.Bot(command_prefix = "your prefix", case_insensitive=True)
It's also much easier to define your client on the same line instead of just doing discord.Client()
See the attributes of a discord.ext.commands.Bot: https://discordpy.readthedocs.io/en/latest/ext/commands/api.html?highlight=sensitive#bot
See the attributes of a discord.Client:
https://discordpy.readthedocs.io/en/latest/api.html?highlight=discord%20client#client
The attribute cse_insensitive is listed for the Bot but not for the Client. It does not exist in the Client. This means it is not possible.

Discord.js - Get Another Channel's Topic

I'm trying to basically do what the title says.
I've tried
let channel = message.channel.get(68352726916713XXXX)
message.channel.send(channel.topic)
and stuff like that, But nothing works.
Any suggestions or answers?
If you are trying to get a channel in the same guild as the message was sent in, use message.guild.channels.get. Otherwise, use client.channels.get.
let channel = message.guild.channels.get("68352726916713XXXX");
message.channel.send(channel.topic);

Discord.js - Detect if a message has an image or a link

So I'm something of a beginner to making bots and I'm semi-comfortable in the space I'm at now only poking around at Discord.js, but I've encountered an issue that I can't seem to move forward on.
I have something of a joke bot that's supposed to detect if a person's sent an image or a link, output a reply, and then delete the image (or link). (Really, I'd prefer to delete anything that isn't text, but I need the response to say exactly what kind of media it is, so I don't care if it's particularly limited...)
Here's what I have:
//remove instances of images
if (message.attachments.length > 0) {
message.channel.send(`${message.author} sent an image!`);
message.channel.send('This constitutes revelry and merriment and is strictly outlawed!')
message.delete();
}
//remove instances of links
if (message.embeds.length > 0) {
message.channel.send(`${message.author} sent an link!`);
message.channel.send('This constitutes revelry and merriment and is strictly outlawed!')
message.delete();
}
However, if I send an image, it simply does nothing.
Thanks in advance!
edit: I'd also like to say that the bot has other functionality that works perfectly (reacting, deleting, replying to mentions of certain words), so hopefully the only relevant code should be above.
message#attachments is a Collection so you have to use:
message.attachments.size

Resources