I get this error when fetching the members
TypeError: Cannot read properties of undefined (reading 'send')
at C:UsersdarkeDocumentsHonorus bot2node_modulesdiscord.jssrcmanagersGuildMemberManager.js:504:24
at new Promise (<anonymous>)
at GuildMemberManager._fetchMany (C:UsersdarkeDocumentsHonorus bot2node_modulesdiscord.jssrcmanagersGuildMemberManager.js:501:12)
at GuildMemberManager.fetch (C:UsersdarkeDocumentsHonorus bot2node_modulesdiscord.jssrcmanagersGuildMemberManager.js:208:31)
at Object.execute (C:UsersdarkeDocumentsHonorus bot2srccommandsCommunityinteractionGiver.js:19:49)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.execute (C:UsersdarkeDocumentsHonorus bot2srceventsinteractionCreate.js:15:13)
It is random every time i restart my bot most of the time I get the error but sometimes it works until I restart it again
here is my code
const { SlashCommandBuilder } = require('@discordjs/builders')
const reactionGiverSchema = require('../../reactionGiverSchema')
module.exports = {
data: new SlashCommandBuilder()
.setName('reactiongiver')
.setDescription('Used to give a role when reacting to a message')
.addStringOption(role => role.setName('message_id').setDescription('L'ID du message pour donner la réaction').setRequired(true))
.addChannelOption(role => role.setName('channel').setDescription('Le channel dans lequel se trouve le message').setRequired(true))
.addRoleOption(role => role.setName('rôle').setDescription('Le rôle a donner après la réaction').setRequired(true))
.addBooleanOption(role => role.setName('reset').setDescription('Faut-il enlever le rôle au personnes qu'il l'ont déjà').setRequired(true)),
async execute(interaction, client) {
const channel_ID = interaction.options.get("channel").channel.id
const role_ID = interaction.options.get("rôle").role.id
const message_ID = interaction.options.get("message_id").value
if (interaction.options.get("reset").value == true){
const guild = await interaction.guild
const members = await guild.members.fetch()
members.forEach(element => {
const roles = element._roles
if (roles.includes(role_ID))
});
}
await reactionGiverSchema.create({ message_ID : message_ID, channel_ID : channel_ID, role_ID : role_ID})
await interaction.reply({ content: "Creation effectuer", ephemeral: true})
}
}
I haven’t found anybody with the same error except someone who had this error because his bot wasn’t ready but I’m sure that mine is when I use the command