Verification system with a button on an Embed

Hello, I'm trying to make a verifitcation system. Here is my code:
const { EmbedBuilder, ButtonStyle, ActionRowBuilder, ButtonBuilder, SlashCommandBuilder, CommandInteraction, PermissionFlagsBits } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('createverify')
.setDescription('Choisissez votre salon de vérificaton.')
.addChannelOption(option =>
option.setName('salon')
.setDescription("Envoyer l'embed de vérification dans ce salon.")
.setRequired(true)
)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
async execute(interaction) {
const channel = interaction.options.getChannel('channel');
const verifyEmbed = new EmbedBuilder()
.setTitle('Verification')
.setDescription('Clique sur le bouton ci-dessous pour accéder au serveur.')
.setColor(0xffffff)
let sendChannel = channel.send({
embeds: ([verifyEmbed]),
components: [
new ActionRowBuilder().setComponents(
new ButtonBuilder().setCustomId('verify').setLabel('Verify').setStyle(ButtonStyle.Success),
),
],
});
if (!sendChannel) {
return interaction.reply({ content: "Quelque chose ne s'est pas passé comme prévu.", ephemeral: true });
} else {
return interaction.reply({ content: "Salon de vérification défini avec succès!", ephemeral: true });
}
},
};
const { EmbedBuilder, ButtonStyle, ActionRowBuilder, ButtonBuilder, SlashCommandBuilder, CommandInteraction, PermissionFlagsBits } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('createverify')
.setDescription('Choisissez votre salon de vérificaton.')
.addChannelOption(option =>
option.setName('salon')
.setDescription("Envoyer l'embed de vérification dans ce salon.")
.setRequired(true)
)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
async execute(interaction) {
const channel = interaction.options.getChannel('channel');
const verifyEmbed = new EmbedBuilder()
.setTitle('Verification')
.setDescription('Clique sur le bouton ci-dessous pour accéder au serveur.')
.setColor(0xffffff)
let sendChannel = channel.send({
embeds: ([verifyEmbed]),
components: [
new ActionRowBuilder().setComponents(
new ButtonBuilder().setCustomId('verify').setLabel('Verify').setStyle(ButtonStyle.Success),
),
],
});
if (!sendChannel) {
return interaction.reply({ content: "Quelque chose ne s'est pas passé comme prévu.", ephemeral: true });
} else {
return interaction.reply({ content: "Salon de vérification défini avec succès!", ephemeral: true });
}
},
};
The code should send an embed message with a button so people can take their member role by clicking on the button. I'm getting the error:
Uncaught TypeError TypeError: Cannot read properties of null (reading 'send')
at execute (c:\Users\...\Desktop\...\Commands\Public\createverify.js:19:35)
at execute (c:\Users\...\Desktop\...\Events\Interactions\interactionCreate.js:14:21)
at <anonymous> (c:\Users\...\Desktop\...\Handlers\eventHandler.js:25:63)
at emit (events:513:28)
at handle (c:\Users\...\Desktop\...
2\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports (c:\Users\...\Desktop\...
2\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at handlePacket (c:\Users\...\Desktop\..
2\node_modules\discord.js\src\client\websocket\WebSocketManager.js:354:31)
at <anonymous> (c:\Users\...\Desktop\...
2\node_modules\discord.js\src\client\websocket\WebSocketManager.js:238:12)
at emit (c:\Users\...\Desktop\...
2\node_modules\@vladfrangu\async_event_emitter\dist\index.js:282:31)
at <anonymous> (c:\Users\...\Desktop\...
2\node_modules\@discordjs\ws\dist\index.js:1103:51)
at emit (c:\Users\...\Desktop\...
2\node_modules\@vladfrangu\async_event_emitter\dist\index.js:282:31)
at onMessage (c:\Users\...\Desktop\...
2\node_modules\@discordjs\ws\dist\index.js:938:14)
at processTicksAndRejections (internal/process/task_queues:95:5)
Uncaught TypeError TypeError: Cannot read properties of null (reading 'send')
at execute (c:\Users\...\Desktop\...\Commands\Public\createverify.js:19:35)
at execute (c:\Users\...\Desktop\...\Events\Interactions\interactionCreate.js:14:21)
at <anonymous> (c:\Users\...\Desktop\...\Handlers\eventHandler.js:25:63)
at emit (events:513:28)
at handle (c:\Users\...\Desktop\...
2\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports (c:\Users\...\Desktop\...
2\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at handlePacket (c:\Users\...\Desktop\..
2\node_modules\discord.js\src\client\websocket\WebSocketManager.js:354:31)
at <anonymous> (c:\Users\...\Desktop\...
2\node_modules\discord.js\src\client\websocket\WebSocketManager.js:238:12)
at emit (c:\Users\...\Desktop\...
2\node_modules\@vladfrangu\async_event_emitter\dist\index.js:282:31)
at <anonymous> (c:\Users\...\Desktop\...
2\node_modules\@discordjs\ws\dist\index.js:1103:51)
at emit (c:\Users\...\Desktop\...
2\node_modules\@vladfrangu\async_event_emitter\dist\index.js:282:31)
at onMessage (c:\Users\...\Desktop\...
2\node_modules\@discordjs\ws\dist\index.js:938:14)
at processTicksAndRejections (internal/process/task_queues:95:5)
Thanks for your help !
3 Replies
d.js toolkit
d.js toolkit12mo ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
duck
duck12mo ago
option.setName('salon') const channel = interaction.options.getChannel('channel');
<CommandInteractionOptionResolver>.getChannel() takes the name of the option to get the value of for its param your channel option's name is salon, not channel therefore it's returning null, since it was unable to resolve the value of a channel option named channel
Heimdall.
Heimdall.12mo ago
Oh damn I didn't see that ! Thanks a lot