Discord.js Animated Emojis - discord.js

I have a bot, and I want to use it to send a animated emoji.
I have the emoji ID, <:rgb_lego:993606148580184154>
but whenever I make it send the message, it just says
Pong! 🏓 The round trip took 76ms. ⚡:rgb_lego:
what am I doing wrong?

It depends on what server (guild) you sent it and how exactly you do it.
Guess you need to check & fetch the requested custom emojie from server and then sent it.
You might wanna check Discord.js docs for that. But if I remember it correctly, emojies should be accessed by bot via:
client.guild.emojis.[methodName] via GuildEmojiManager
The second problem could be relevant to the server, where you want to sent it, doesn't have the required emojie, so in that case it has been delivered as a text ref, not an emojie itself or the bot account doesn't have premium features required for using emojies or so on.

Related

Store data in discord message for button component

I want to make a simple bot that does some things when someone clicks a list item.
To make this possible I need to store the list item's id in the message. I didn't see any ways to store data in a message without showing it, so I added it to the footer and when the button triggers it gets the first embed's footer in the interaction's message.
My problem with this solution is that it looks bad.
Collectors are not an option because these list items are sent to a channel once when the channel is created, and if the bot restarts the collectors won't trigger.
How would you guys solve this?
Thanks!
Okay I solved this. I don't know how I've never thought of this before.
Basically I created a table in my database that has 2 columns:
discord message id
data
When I send the message to the channel I just store the data with the message's id. When the user clicks the button I just retrieve the data by the message id.

How to mention a user mentioned in the command discord js

So im working on a discord bot, and working on a command where it mentions a user. For example: -fakekick #user and the bot would say User has been kicked I've read through the docs and found a few sites but I couldn't really understand it as I just started discord js a few days ago. Thanks
To get the user object of a mentioned user, you can very simply use the mentions extension of the message object. We can very simply use it in order to define our user, and later on, mention him in a future message. That can be done very simply as so:
const user = message.mentions.users.first(); // Would get the first mentioned user's object
message.channel.send(`${user} has been kicked!`); // To mention a user, you simply need to mention his user object.

Why does client.users.cache only show 2 users discord.js

For a server of mine, I need my bot to DM everyone at regular periods of time. I use
client.users.cache.get(args[1]).send(toSend);
to do this, where args[1] contains the user's id and toSend is the message to send. However, it just turns up Cannot read property 'send' of undefined. Then I tried logging client.users.cache to the console and it appears that only 2 users are in it, the bot itself and me. Why is this so, given that the server has at least 30 users?

Limiting certain commands to certain channels [Discord.js]

So I have only found answers to this question for discord.js with commando which won't work with just discord.js
I want to limit an automated reaction to any attachment send in one channel. (And only in that one channel.) So doing it with roles won't work.
Kind regards Per.
If you want that a command can only be done in a certain channel you can check if the id of the channel were the message was sent is the id you have stored to allow the command to be done
if(message.channel.id === 'id of channel'){
//code of command
}

Watson Dialog does not recognize continuation of conversation

When trying to use the Dialog tool to get a feel for how the APIs work, I ran into a problem where a POST to /conversation creates a new conversation, instead of continuing an existing one. I am using the docs found at : http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/dialog/api/v1/
An initial POST returns a conversation and client id, but subsequent requests with those values added, along with an input value, just return information for a new conversation. Are these docs inaccurate?
Here is a screenshot from one of my many attempts at getting this to work. The client and connection IDs are from a previous POST to /conversation
http://imgur.com/4035dWe
Thanks for your help!
Your first call to Converse you should not specify the conversation ID. Dialog will return a conversation ID with the first response.
You then use that ID going forward to maintain the conversation. It is unclear if you are doing this in the example above.
It turns out I was using the incorrect encoding for the conversation / client ID's and input. Watson expects the form values to be URL encoded. Once I made that change, the problem was resolved.
Thanks to everyone who offered their time and help!

Resources