discord-temp-channels icon indicating copy to clipboard operation
discord-temp-channels copied to clipboard

Error after restarting bot with quick.db

Open UnDeadLolomat opened this issue 4 years ago • 4 comments

"stack": "TypeError: parentChannel.options.childFormat is not a function Thats the error when i set the voicechannel with quick,db and restart my bot. When i then join the voicechannel the error pops up and doesnt create a new voice channel. When i run the set command, the channel is already set and recognized tho, so i dont think it deletes the channel. Idk what to do, because i also tried it with mongoDB and didnt got it working. Can u help me there ? The code snippet from u: Here + the full error Here . Thanks!

UnDeadLolomat avatar Jul 06 '21 16:07 UnDeadLolomat

Hello @UnDeadLolomat :D

Would it be possible to tell us what happens when you save the options to the database? It seems that options.childFormat is not a function once you set it with db.push.

The problem is probably located in two places here:

  1. first place is when you save the data in quick.db:
db.push("temp-channels", {
    channelID: message.member.voice.channel.id,
    options: options
});
  1. second is when you get that data back from quick.db and use it directly:
db.get("temp-channels").forEach((channelData) => {
    tempChannels.registerChannel(channelData.channelID, channelData.options);
});

The best way to troubleshoot this would be to check the typeof the options property of channelData in your forEach loop.

HunteRoi avatar Sep 18 '21 18:09 HunteRoi

i have this error too but i have no clue on how to fix

RumiDaNeko avatar Nov 14 '21 02:11 RumiDaNeko

@HunteRoi

RumiDaNeko avatar Nov 14 '21 02:11 RumiDaNeko

Hello there @NotMinhDucGamingTV & @UnDeadLolomat !

The issue is due to your options#childFormat not being inserted in the quick.db. As you may know, once an object is translated into JSON, it only keeps its attributes, not its methods. Which mean that:

{
    childAutoDeleteIfEmpty: true,
    childAutoDeleteIfOwnerLeaves: true,
    childMaxUsers: 3,
    childBitrate: 64000,
    childFormat: (member, count) => `#${count} | ${member.user.username}'s lounge`
}

will effectively become the following once saved in the database:

{
    "childAutoDeleteIfEmpty": true,
    "childAutoDeleteIfOwnerLeaves": true,
    "childMaxUsers": 3,
    "childBitrate": 64000
}

HunteRoi avatar Oct 15 '22 13:10 HunteRoi