I still don't get how those buttons work. I have an file called messages.ts that should handle all my message related stuff. For now I only have one function in it that sends a message with a button.
Full code of message.ts:
import DiscordJS from 'discord.js'
const botChannelID = '000000';
const pointsNeeded = 400;
export function postEnoughActivityMessage(guildMember: DiscordJS.GuildMember) {
(guildMember.guild.channels.cache.find((x: DiscordJS.GuildBasedChannel) => x.id === botChannelID) as DiscordJS.TextChannel).send({
"tts": false,
"components": [
{
"type": 1,
"components": [
{
"style": 3,
"label": `Zum Member Befördern`,
"custom_id": `addToMember`,
"disabled": false,
"type": 2
}
]
}
],
"embeds": [
{
"type": "rich",
"title": `<:tada:988855833809002546> Neue Aktivitätsstufe erreicht! <:tada:988855833809002546>`,
"description": `**${guildMember.displayName}** hat **${pointsNeeded}** Punkte gesammelt und somit die Chance verdient in den Member Rang gehoben zu werden.`,
"color": 0x3b4ea3,
"thumbnail": {
"url": guildMember.displayAvatarURL() as string,
"height": 0,
"width": 0
}
}
]
});
}
What I want to do is that the button can only be pressed once, after that the button should be removed and I want to somehow know that this button was pressed with the id/guildMember used in the message (not the one who pressed it).
If have found out that you can listen for button presses on the client with this:
inside my app.ts:
client.on('interactionCreate', interaction => {
if (!interaction.isButton()) return;
console.log(); // TODO
});
But I have no clue how to remove the button or how to pass the guildMember used in the creation of the message to this function.
I have the feeling that I can't do it like that because everything I see of button code looks very differend than my code. So what should I rewrite to make it work?