Bene
Bene
DIAdiscord.js - Imagine an app
Created by Bene on 9/23/2023 in #djs-questions
Attachment to Embed
No description
4 replies
DIAdiscord.js - Imagine an app
Created by Bene on 9/16/2023 in #djs-questions
Can't Edit Message in DM
I can't edit a message in DM Code: https://pastebin.com/PQ2n0gvZ Error: https://pastebin.com/MZcrkSzP Obliviously the error indicates that the message isn't in a channel so it also isn't in the cache. I know this but I also couldn't find any working solution for this problem online. Thanks for any help ^^
2 replies
DIAdiscord.js - Imagine an app
Created by Bene on 1/18/2023 in #djs-questions
Interaction already been acknowledged
Code:
client.on("interactionCreate", async interaction => {
const split = interaction.customId.split("_");
const final = split[1];
if (interaction.customId === split[0]) {
const buttons = new MessageActionRow()
.addComponents(
new MessageButton()
.setLabel("Begrüßen")
.setStyle("PRIMARY")
.setCustomId(`customid`)
.setEmoji("👋")
);
await interaction.update({ components: [buttons] });

interaction.ack();
interaction.followUp(`**${interaction.user.username}** begrüßt **${final}**`)

}
})
client.on("interactionCreate", async interaction => {
const split = interaction.customId.split("_");
const final = split[1];
if (interaction.customId === split[0]) {
const buttons = new MessageActionRow()
.addComponents(
new MessageButton()
.setLabel("Begrüßen")
.setStyle("PRIMARY")
.setCustomId(`customid`)
.setEmoji("👋")
);
await interaction.update({ components: [buttons] });

interaction.ack();
interaction.followUp(`**${interaction.user.username}** begrüßt **${final}**`)

}
})
Error: Unhandled promise rejection: DiscordAPIError: Interaction has already been acknowledged. at RequestHandler.execute (C:\Users\freie\Desktop\Strandbots\nightbot\node_modules\discord.js\src\rest\RequestHandler.js:350:13) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async RequestHandler.push (C:\Users\freie\Desktop\Strandbots\nightbot\node_modules\discord.js\src\rest\RequestHandler.js:51:14) at async ButtonInteraction.update (C:\Users\freie\Desktop\Strandbots\nightbot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:218:5) at async Client.<anonymous> (C:\Users\freie\Desktop\Strandbots\nightbot\main.js:36:3) { method: 'post', path: '/interactions/1065263126636937216/aW50ZXJhY3Rpb246MTA2NTI2MzEyNjYzNjkzNzIxNjo0WFpEOVlNNTdhUFQ1SGNGUWRUM1VIR3Z5cnB5bFEwUFp0dkhvMWFhd0pLSDlRRWIwMmY0QmZXMWxnNVpmelBGU FNvWUVSMzFNNFZwM29TVUkzeXM1TGFFMVNFWWRTeVNZM0s0NDE0N0hpbDFHMG5rTmtZUEVUa3ZaWHg2NzZkRQ/callback', code: 40060, httpStatus: 400, requestData: { json: { type: 7, data: [Object] }, files: [] } }
3 replies
DIAdiscord.js - Imagine an app
Created by Bene on 1/14/2023 in #djs-questions
DiscordAPIError: Interaction has already been acknowledged.
client.on('interactionCreate', async (interaction) => {
const split = interaction.customId.split("_")
const customfilter = split[0]
const userid = split[1]
const member = await interaction.guild.members.fetch(userid)
if (customfilter == 'userbannen') {

const embed = new MessageEmbed()
.setTitle('Erfolg!')
.setDescription('Ich habe den User gebannt')
.setColor('RED')

interaction.reply({ embeds: [embed], ephemeral: true })
member.ban()


}
client.on('interactionCreate', async (interaction) => {
const split = interaction.customId.split("_")
const customfilter = split[0]
const userid = split[1]
const member = await interaction.guild.members.fetch(userid)
if (customfilter == 'userbannen') {

const embed = new MessageEmbed()
.setTitle('Erfolg!')
.setDescription('Ich habe den User gebannt')
.setColor('RED')

interaction.reply({ embeds: [embed], ephemeral: true })
member.ban()


}
At this part of my code the Bot should reply to the interaction and also should ban the member (I got the id of the member in the interaction custom id) Error:
Unhandled promise rejection: DiscordAPIError: Interaction has already been acknowledged.
at RequestHandler.execute (C:\Users\freie\Desktop\Strandbots\nextmain\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async RequestHandler.push (C:\Users\freie\Desktop\Strandbots\nextmain\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
at async ButtonInteraction.reply (C:\Users\freie\Desktop\Strandbots\nextmain\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:103:5) {
method: 'post',
path: '/interactions/1063928874129444944/aW50ZXJhY3Rpb246MTA2MzkyODg3NDEyOTQ0NDk0NDpUY3gyMGplQnVLVGhPd09aMEFkVEhGdmg4ZmFFZlFHZ0NwSDg0OERIMXZ0a3ljalNYSThLcFR6ME83MklmQ3dhNlBWOWt4b0ptOTJnZkYzN09yc3Vtc2tMajN2a004bmZYYUZLZ0IyaHI1WmhOWDJWdmlucXFzRXBaVHF2YXJnRg/callback',
code: 40060,
httpStatus: 400,
requestData: { json: { type: 4, data: [Object] }, files: [] }
}
Unhandled promise rejection: DiscordAPIError: Interaction has already been acknowledged.
at RequestHandler.execute (C:\Users\freie\Desktop\Strandbots\nextmain\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async RequestHandler.push (C:\Users\freie\Desktop\Strandbots\nextmain\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
at async ButtonInteraction.reply (C:\Users\freie\Desktop\Strandbots\nextmain\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:103:5) {
method: 'post',
path: '/interactions/1063928874129444944/aW50ZXJhY3Rpb246MTA2MzkyODg3NDEyOTQ0NDk0NDpUY3gyMGplQnVLVGhPd09aMEFkVEhGdmg4ZmFFZlFHZ0NwSDg0OERIMXZ0a3ljalNYSThLcFR6ME83MklmQ3dhNlBWOWt4b0ptOTJnZkYzN09yc3Vtc2tMajN2a004bmZYYUZLZ0IyaHI1WmhOWDJWdmlucXFzRXBaVHF2YXJnRg/callback',
code: 40060,
httpStatus: 400,
requestData: { json: { type: 4, data: [Object] }, files: [] }
}
16 replies
DIAdiscord.js - Imagine an app
Created by Bene on 1/7/2023 in #djs-questions
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?
30 replies
DIAdiscord.js - Imagine an app
Created by Bene on 12/9/2022 in #djs-questions
roleMembers.slice is not a function
So I have a problem: I wan't to fetch members and see if they have a role and then get the first then and splice them so I can do something with every single members of those 10 but I can't even splice them Code:
client.on('ready', async () => {
const guild = client.guilds.cache.get('1038758589055127604');

guild.members.fetch().then(members => {
const roleMembers = members.filter(member => {member.roles.cache.has('1050754704776372294')});

const firstTenMembers = roleMembers.slice(0, 10)

const firstMember = firstTenMembers[0]
const secondMember = firstTenMembers[1]
const thirdMember = firstTenMembers[2]
const fourthMember = firstTenMembers[3]

//then i want to put it in a Canvas

});
client.on('ready', async () => {
const guild = client.guilds.cache.get('1038758589055127604');

guild.members.fetch().then(members => {
const roleMembers = members.filter(member => {member.roles.cache.has('1050754704776372294')});

const firstTenMembers = roleMembers.slice(0, 10)

const firstMember = firstTenMembers[0]
const secondMember = firstTenMembers[1]
const thirdMember = firstTenMembers[2]
const fourthMember = firstTenMembers[3]

//then i want to put it in a Canvas

});
Error:
Unhandled promise rejection: TypeError: roleMembers.slice is not a function
at C:\Users\freie\Desktop\Strandbots\bademeisterv2\main.js:73:39
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Unhandled promise rejection: TypeError: roleMembers.slice is not a function
at C:\Users\freie\Desktop\Strandbots\bademeisterv2\main.js:73:39
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
4 replies
DIAdiscord.js - Imagine an app
Created by Bene on 12/5/2022 in #djs-questions
How to do two interaction
so i have a really dumb question, but i don't know what to do
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'),
)

interaction.reply(`${interaction.user} begrüßt <@${btn_id}>`)
interaction.update({ 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'),
)

interaction.reply(`${interaction.user} begrüßt <@${btn_id}>`)
interaction.update({ components: [buttons] })

}
})
This is my code i want to reply to the interaction and then update it but it's not working. Discordjs v13.12.0
59 replies
DIAdiscord.js - Imagine an app
Created by Bene on 12/3/2022 in #djs-questions
Discord Welcome Button
I try to make the Welcome Button from Discord in a Bot but i dont know how i get the ID from the Joined user to the interactionCreate of the Bot
35 replies
DIAdiscord.js - Imagine an app
Created by Bene on 12/3/2022 in #djs-questions
MY Code is not working
client.on("guildMemberAdd", async member => { const canvas = Canvas.createCanvas(1772, 633); const ctx = canvas.getContext('2d'); const background = await Canvas.loadImage(./welcome.png); ctx.drawImage(background, 0, 0, canvas.width, canvas.height); ctx.strokeStyle = '#f2f2f2'; ctx.strokeRect(0, 0, canvas.width, canvas.height); var textString3 = ${member.user.username}; if (textString3.length >= 14) { ctx.font = 'bold 100px Genta'; ctx.fillStyle = '#f2f2f2'; ctx.fillText(textString3, 720, canvas.height / 2 + 20); } else { ctx.font = 'bold 150px Genta'; ctx.fillStyle = '#f2f2f2'; ctx.fillText(textString3, 720, canvas.height / 2 + 20); } var textString2 = #${member.user.discriminator}; ctx.font = 'bold 40px Genta'; ctx.fillStyle = '#f2f2f2'; ctx.fillText(textString2, 730, canvas.height / 2 + 58); var textString4 = Member #${member.guild.memberCount}; ctx.font = 'bold 60px Genta'; ctx.fillStyle = '#f2f2f2'; ctx.fillText(textString4, 750, canvas.height / 2 + 125); var textString4 = ${member.guild.name}; ctx.font = 'bold 60px Genta'; ctx.fillStyle = '#f2f2f2'; ctx.beginPath(); ctx.arc(315, canvas.height / 2, 250, 0, Math.PI * 2, true); ctx.closePath(); ctx.clip(); const avatar = await Canvas.loadImage(member.user.displayAvatarURL({ format: 'jpg' })); ctx.drawImage(avatar, 65, canvas.height / 2 - 250, 500, 500); const attachment = new MessageAttachment(canvas.toBuffer(), 'welcome-image.png'); const row = new MessageActionRow() .addComponents( new MessageButton() .setTitle('Begrüßen') .setStyle('SECONDARY') .setCustomId('begrusn') ) const channel = client.channels.cache.get('1037278054503956550') channel.send({ files: [attachment], components: [row] })
20 replies
DIAdiscord.js - Imagine an app
Created by Bene on 11/26/2022 in #djs-questions
Change Presence Modal
So i tried changing the Bot's Presence with an Interaction Modal But i get this Error: Unhandled promise rejection: TypeError: Cannot read properties of undefined (reading 'user')
116 replies