Discord.js Changing Nickname and avatar continuously - discord

I want to change my bot's nickname which do not need to put in some thing like client.on("ready" or "message"
So far I've tried:
client.user.setNickname()
client.setNickname()
I've seen someone having a bot which changes its avatar and nickname continuously and I have no idea about their algorithm. (When I click the bot to view its profile it didn’t display anything)
If you want to have a look at the bot: https://discord.gg/pz8S2hrRnf
#server-bridge

You cannot set the nickname on the user property, but you can on a GuildMember.
As #Zsolt Meszaros said, you would have to use <Guild>.me.setNickname()
See more details at the docs here.

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.

Discord.js Animated Emojis

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.

How to get bot's role color? Discord.js

I am trying to match bot's embed color and it's role color. So far I found only this solution, but instead of a user's role color I want bot's color:
.setColor(message.member.displayHexColor)
I was trying to target the bot with message.author.bot but that doesn't work either.
I think that message.guild.me.displayHexColor is what you are looking for. guild.me returns bot user as a member of a current guild.
Technically, a bot is also a 'user' but at the very least a member of the server; context is important here.
Do you pick a member specifically or only when they do a command?
If it's the former, you can try the same thing you did with
.setColor(message.member.displayHexColor)
but choose the bot as member instead

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.

YAGPDB Discord Bot - Custom command to limit reaction

I am trying to create a voting channel where the YAGPDB bot will automatically react "👍" and "👎" to every message posted in that particular channel. And people will be able to react only one of them. Can someone advise on how to do it?
I was able to write the code this far:
{{addMessageReactions nil $.Message.ID ":thumbsup:" ":thumbsdown:"}}
On the Role Command category under Role Commands, just set it to Mode: Single

Resources