I want to do something like when someone presses a button the bot waits for a response in text of a mentioned channel in discord.js v14 - discord.js

actually I am making an announcement command with embeds and modals I did all the work after submitting the modal the bot does send an embed message preview your text embed and button with text send I want it so that after the user presses the button it asks what channel do you want to send the announcement to and waits for a text message response that has the channel mention. so can you please tell how to do it.

What you are looking for:
A way so when a user pressed a button a response comes that asks what channel the user wants to send announcement(x) to and then wait.
Recommended approach
Use the following guide:
https://discordjs.guide/interactions/buttons.html#building-and-sending-buttons
... and learn how to send buttons for discord.js v14.
After doing so you would want a
interaction.reply({ content: 'What channel would you like to send your announcement in?'});
line with an await function waiting for the user to send a second message i.e. #announcements-channel (message)
The bot would need to have an array of all the possible channel IDs which you can get by right clicking on a channel and selecting Copy ID (here is a photo)
Then the bot will get the (message) and send it in #announcements-channel using the channel ID and finish the command.

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.

Hide Text Sent via Post Activity Event

I'm currently sending a text programmatically to my bot following the article on https://github.com/microsoft/BotFramework-WebChat/tree/master/samples/04.api/d.post-activity-event
Everything is working fine but I want to hide the text being sent so that the user does not see it on the session. Is this possible to do?
Instead of initializing and using the useSendMessage hook, replace it with useSendPostBack. Using useSendPostBack will generate a postBack message activity which simply sends a value back to the bot without displaying it to the user. The value sent to the bot should be located in the value property of the associated activity.
const sendPostBack = useSendPostBack();
const handleHelpButtonClick = useCallback(() => sendPostBack('help'), [sendMessage]);
A complete list of available hooks can be reviewed in the Web Chat repo doc, hooks.

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

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
}

Resources