need help

I getting error when users connects in VC to early (Before Embed created and sended in channel) Bot trying to update embed on VoiceStateUpdate, but he can't because emded with member stats creating little longer than VC All works fine when i wait bot message before connect to VC Error
TypeError: Cannot read properties of null (reading 'messageChannelId')
at updateEvent (C:\Users\ыффц\Desktop\bot\src\events\voiceStateUpdate\LFG-Voice.js:46:48)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async updateOrDeleteEvent (C:\Users\ыффц\Desktop\bot\src\events\voiceStateUpdate\LFG-Voice.js:27:5)
at async module.exports (C:\Users\ыффц\Desktop\bot\src\events\voiceStateUpdate\LFG-Voice.js:16:7)
at async Client.<anonymous> (C:\Users\ыффц\Desktop\bot\node_modules\commandkit\dist\index.js:731:33)
TypeError: Cannot read properties of null (reading 'messageChannelId')
at updateEvent (C:\Users\ыффц\Desktop\bot\src\events\voiceStateUpdate\LFG-Voice.js:46:48)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async updateOrDeleteEvent (C:\Users\ыффц\Desktop\bot\src\events\voiceStateUpdate\LFG-Voice.js:27:5)
at async module.exports (C:\Users\ыффц\Desktop\bot\src\events\voiceStateUpdate\LFG-Voice.js:16:7)
at async Client.<anonymous> (C:\Users\ыффц\Desktop\bot\node_modules\commandkit\dist\index.js:731:33)
LFG-Message.js (create embed and VC) https://srcshare.io/6634b10aecdf3ead999ae523 LFG-Voice.js (Update embed on voiceStateUpdate) https://srcshare.io/6634b14cecdf3ead999ae52b
5 Replies
d.js toolkit
d.js toolkit7mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
it's me...
it's me...OP7mo ago
it's me...
it's me...OP7mo ago
[email protected] node v20.11.1 im aslo trying to create closed channel, then update permissions it successfully console.log ids but i still get error LFG-Message.js https://srcshare.io/6634b987c56cf36b82477a1a Error
849626183262797854
1217201760805060658
1220042458453381181
TypeError [InvalidType]: Supplied parameter is not a User nor a Role.
at PermissionOverwriteManager.upsert (C:\Users\ыффц\Desktop\bot\node_modules\discord.js\src\managers\PermissionOverwriteManager.js:101:30)
at PermissionOverwriteManager.edit (C:\Users\ыффц\Desktop\bot\node_modules\discord.js\src\managers\PermissionOverwriteManager.js:150:17)
at handleNewEvent (C:\Users\ыффц\Desktop\bot\src\events\messageCreate\LFG-Message.js:92:50)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async module.exports (C:\Users\ыффц\Desktop\bot\src\events\messageCreate\LFG-Message.js:21:7)
at async Client.<anonymous> (C:\Users\ыффц\Desktop\bot\node_modules\commandkit\dist\index.js:731:33) {
code: 'InvalidType'
}
TypeError: Cannot read properties of null (reading 'messageChannelId')
at updateEvent (C:\Users\ыффц\Desktop\bot\src\events\voiceStateUpdate\LFG-Voice.js:46:48)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async updateOrDeleteEvent (C:\Users\ыффц\Desktop\bot\src\events\voiceStateUpdate\LFG-Voice.js:27:5)
at async module.exports (C:\Users\ыффц\Desktop\bot\src\events\voiceStateUpdate\LFG-Voice.js:16:7)
at async Client.<anonymous> (C:\Users\ыффц\Desktop\bot\node_modules\commandkit\dist\index.js:731:33)
849626183262797854
1217201760805060658
1220042458453381181
TypeError [InvalidType]: Supplied parameter is not a User nor a Role.
at PermissionOverwriteManager.upsert (C:\Users\ыффц\Desktop\bot\node_modules\discord.js\src\managers\PermissionOverwriteManager.js:101:30)
at PermissionOverwriteManager.edit (C:\Users\ыффц\Desktop\bot\node_modules\discord.js\src\managers\PermissionOverwriteManager.js:150:17)
at handleNewEvent (C:\Users\ыффц\Desktop\bot\src\events\messageCreate\LFG-Message.js:92:50)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async module.exports (C:\Users\ыффц\Desktop\bot\src\events\messageCreate\LFG-Message.js:21:7)
at async Client.<anonymous> (C:\Users\ыффц\Desktop\bot\node_modules\commandkit\dist\index.js:731:33) {
code: 'InvalidType'
}
TypeError: Cannot read properties of null (reading 'messageChannelId')
at updateEvent (C:\Users\ыффц\Desktop\bot\src\events\voiceStateUpdate\LFG-Voice.js:46:48)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async updateOrDeleteEvent (C:\Users\ыффц\Desktop\bot\src\events\voiceStateUpdate\LFG-Voice.js:27:5)
at async module.exports (C:\Users\ыффц\Desktop\bot\src\events\voiceStateUpdate\LFG-Voice.js:16:7)
at async Client.<anonymous> (C:\Users\ыффц\Desktop\bot\node_modules\commandkit\dist\index.js:731:33)
it's me...
it's me...OP7mo ago
EventObject it is embed getEventObject.js https://srcshare.io/6634bb79725c4e267ee89ad5
SrcShare
Easily share your source code with other developers.
No description
it's me...
it's me...OP7mo ago
Screenshot from LFG-Message.js Line 83-84 The only solution I have found is to create a closed channel and then open it ( after the bot sends embed ) But I couldn't do it No, the only problem is that the bot is trying to update a non-existent message (because it takes half a second longer than the channel to create it). Embed is created successfully and sent to the right channel, when I go to the voice channel the bot tries to update the Embed with my information. Here is a video demo of the error in first attempt all works fine, because i wait bot message before joining in VC, and bot successfully update embed but in second attempt i join in VC right before bot message, then he tries to update message, but message doesent exist yet I realize that my code may be unreadable, but LFG-Message.js im creating VC
const voiceChannel = await createEventVoiceChannel(message.guild, message.channel, message.author, voiceChannelCounter);
const voiceChannel = await createEventVoiceChannel(message.guild, message.channel, message.author, voiceChannelCounter);
then creating Embed
const eventObject = getEventObject(message.guild, eventAuthor, authorBungieID, message.content, thumbnailURL, voiceChannel, remainingSlots, membersRaidStatsArray.join('\n'));
const eventObject = getEventObject(message.guild, eventAuthor, authorBungieID, message.content, thumbnailURL, voiceChannel, remainingSlots, membersRaidStatsArray.join('\n'));
then sent embed in message.channel
const eventMessage = await message.channel.send(eventObject);
const eventMessage = await message.channel.send(eventObject);
then i save messageId and other event info in DB
const newEvent = new eventSchema({
messageId: eventMessage.id,
messageChannelId: message.channel.id,
eventDescription: message.content,
voiceChannelId: voiceChannel.id,
voiceChannelCounter: voiceChannelCounter,
authorId: message.author.id,
});
const newEvent = new eventSchema({
messageId: eventMessage.id,
messageChannelId: message.channel.id,
eventDescription: message.content,
voiceChannelId: voiceChannel.id,
voiceChannelCounter: voiceChannelCounter,
authorId: message.author.id,
});
LFG-Voice.js Then onVoiceStateUpdate im find event info in DB by voiceChannel.id
const event = await eventSchema.findOne({ voiceChannelId: voiceChannel.id });
const event = await eventSchema.findOne({ voiceChannelId: voiceChannel.id });
Then find other info
const { thumbnailURL } = channelParams[event.messageChannelId];
let remainingSlots = voiceChannel.userLimit - voiceChannel.members.size;

const eventAuthor = await updateAndGetEventAuthor(event, voiceChannel, voiceStateMember);
const authorBungieID = await getAuthorBungieID(eventAuthor.id);
const membersRaidStats = await getMembersRaidStats(voiceChannel, eventAuthor.id, event.messageChannelId);

const membersRaidStatsArray = Array.isArray(membersRaidStats)? membersRaidStats : [membersRaidStats];
const { thumbnailURL } = channelParams[event.messageChannelId];
let remainingSlots = voiceChannel.userLimit - voiceChannel.members.size;

const eventAuthor = await updateAndGetEventAuthor(event, voiceChannel, voiceStateMember);
const authorBungieID = await getAuthorBungieID(eventAuthor.id);
const membersRaidStats = await getMembersRaidStats(voiceChannel, eventAuthor.id, event.messageChannelId);

const membersRaidStatsArray = Array.isArray(membersRaidStats)? membersRaidStats : [membersRaidStats];
Then create new emded
const eventObject = getEventObject(voiceChannel.guild, eventAuthor, authorBungieID, event.eventDescription, thumbnailURL, voiceChannel, remainingSlots, membersRaidStatsArray.join('\n'));
const eventObject = getEventObject(voiceChannel.guild, eventAuthor, authorBungieID, event.eventDescription, thumbnailURL, voiceChannel, remainingSlots, membersRaidStatsArray.join('\n'));
Then fetch message and update it with eventObejct (new Embed)
const eventMessage = await eventChannel.messages.fetch(event.messageId).catch(() => null);
await eventMessage.edit(eventObject);
const eventMessage = await eventChannel.messages.fetch(event.messageId).catch(() => null);
await eventMessage.edit(eventObject);
Want results from more Discord servers?
Add your server