Button UserID push through

So I have a Event where the Bot sends a Welcome-Message with a Button to Welcome the User, similar to the Discord in-build function so to get like the name into the InteractionCreate Event I need to push it through with the button ID I guess. But how can I Filter the button Interaction then bc I have multiple and normally you would filter it with the interaction.customid but here I can't I guess so how do I filter it?
23 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Bene
Bene2y ago
I got discord.js v13.12.0 and node 18
Parogo_72
Parogo_722y ago
which name do you want to get?
Bene
Bene2y ago
so from the user that just joined
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Parogo_72
Parogo_722y ago
interaction.user.username exists
Bene
Bene2y ago
jep
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Bene
Bene2y ago
Jep, I know so I push it trough with the Button custom ID
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Bene
Bene2y ago
I don't need the Info from the interaction.user I wanna have the user ID of the Person just joined I send the code rl quick
Parogo_72
Parogo_722y ago
and isnt that person the one that pushes the button?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Parogo_72
Parogo_722y ago
whatever, in any case interaction.customId is a string nothing stops you to do .setCustomId("real custom id" + "_" + userId) and split the string by _
Bene
Bene2y ago
Nononono the Person who pushes the button can like welcome the person who joined wait a sec
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Bene
Bene2y ago
client.on("guildMemberAdd", async member => {
console.log('Jemand ist gejoint')


const buttons = new MessageActionRow()
.addComponents(
new MessageButton()
.setLabel('Begrüßen')
.setStyle('PRIMARY')
.setCustomId(member.user.id)
.setEmoji('👋'),
)

const channel = client.channels.cache.get('1037278054503956550')

channel.send({
components: [buttons]
})

})


client.on("interactionCreate", async interaction => {
if (interaction.isButton()) {
const btn_id = interaction.customId
const buttons = new MessageActionRow()
.addComponents(
new MessageButton()
.setLabel('Begrüßen')
.setStyle('PRIMARY')
.setCustomId(`customid`)
.setEmoji('👋')
.setDisabled('true'),
)
await interaction.update({ components: [buttons] })


interaction.followUp(`${interaction.user} begrüßt <@${btn_id}>`)


}
})
client.on("guildMemberAdd", async member => {
console.log('Jemand ist gejoint')


const buttons = new MessageActionRow()
.addComponents(
new MessageButton()
.setLabel('Begrüßen')
.setStyle('PRIMARY')
.setCustomId(member.user.id)
.setEmoji('👋'),
)

const channel = client.channels.cache.get('1037278054503956550')

channel.send({
components: [buttons]
})

})


client.on("interactionCreate", async interaction => {
if (interaction.isButton()) {
const btn_id = interaction.customId
const buttons = new MessageActionRow()
.addComponents(
new MessageButton()
.setLabel('Begrüßen')
.setStyle('PRIMARY')
.setCustomId(`customid`)
.setEmoji('👋')
.setDisabled('true'),
)
await interaction.update({ components: [buttons] })


interaction.followUp(`${interaction.user} begrüßt <@${btn_id}>`)


}
})
This is the Code and I'm trying to filter the interaction
Parogo_72
Parogo_722y ago
my answer still applies
Bene
Bene2y ago
Bro no
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Parogo_72
Parogo_722y ago
nothing stops you to do .setCustomId("real custom id" + "_" + userId) and split the string by _
So interaction.customId.split("_") will be an array with the first element being the real customId and the second element being the userId
Bene
Bene2y ago
you got this button like discord has it y'all know how it works and I'm trying to make it with my Bot
Bene
Bene2y ago
Ahh thanks this could work I'm so dumb thanks