Heimdall.
DIAdiscord.js - Imagine an app
•Created by Heimdall. on 6/30/2023 in #djs-questions
.setName is not a function
Hello, I cannot understand why it tells me that ".setName" is not a function.
Here is my code:
And here is my error:
Thanks !
const {EmbedBuilder} = require('@discordjs/builders');
const {GuildMember, Embed} = require('discord.js');
const Schema = require('../../Models/Welcome')
module.exports = {
name: "guildMemberAdd",
async execute(member) {
Schema.findOne({Guild: member.guild.id}, async (err, data) => {
if (!data) return;
let channel = data.Channel;
let Msg = data.Msg || " ";
let Role = data.Role;
const {user, guild} = member;
const welcomeChannel = member.guild.channels.cache.get(data.Channel);
const welcomeEmbed = new EmbedBuilder()
.setName("**Ho ! Un nouveau membre !**")
.setDescription(data.Msg)
.setColor(0x52D800)
.addFields({name: 'Membres:', value: `${guild.memberCount}`})
.setTimestamp();
welcomeChannel.send({embeds: [welcomeEmbed]});
member.roles.add(data.Role);
})
}
}
const {EmbedBuilder} = require('@discordjs/builders');
const {GuildMember, Embed} = require('discord.js');
const Schema = require('../../Models/Welcome')
module.exports = {
name: "guildMemberAdd",
async execute(member) {
Schema.findOne({Guild: member.guild.id}, async (err, data) => {
if (!data) return;
let channel = data.Channel;
let Msg = data.Msg || " ";
let Role = data.Role;
const {user, guild} = member;
const welcomeChannel = member.guild.channels.cache.get(data.Channel);
const welcomeEmbed = new EmbedBuilder()
.setName("**Ho ! Un nouveau membre !**")
.setDescription(data.Msg)
.setColor(0x52D800)
.addFields({name: 'Membres:', value: `${guild.memberCount}`})
.setTimestamp();
welcomeChannel.send({embeds: [welcomeEmbed]});
member.roles.add(data.Role);
})
}
}
Uncaught TypeError TypeError: (intermediate value).setName is not a function
at <anonymous> (c:\Users\...\Desktop\...\Events\Guild\guildMemberAdd.js:18:14)
at <anonymous> (c:\Users\...\Desktop\...\node_modules\mongoose\lib\model.js:4931:18)
at processTicksAndRejections (internal/process/task_queues:77:11)
Uncaught TypeError TypeError: (intermediate value).setName is not a function
at <anonymous> (c:\Users\...\Desktop\...\Events\Guild\guildMemberAdd.js:18:14)
at <anonymous> (c:\Users\...\Desktop\...\node_modules\mongoose\lib\model.js:4931:18)
at processTicksAndRejections (internal/process/task_queues:77:11)
5 replies
DIAdiscord.js - Imagine an app
•Created by Heimdall. on 6/29/2023 in #djs-questions
Verification system with a button on an Embed
Hello, I'm trying to make a verifitcation system.
Here is my code:
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:
Thanks for your help !
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 });
}
},
};
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)
5 replies