2021年5月5日星期三

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'toObject' of null [closed]

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'toObject' of null

package is mongoose, discord.js and the file name is voice voiceStateUpdate.js.

Game.findOne({ name: "counter" }, { counter: 1, _id: 0 })                                  .then(count => {                                      const counter = count.toObject().counter;                                      mongoose.connection.db.collection("games").updateOne({ name: "counter" }, { $inc: { counter: 1 } });                                        newState.guild.channels.create(`게임-${counter}`, {                                          type: "text",                                          parent: "839659460536565770"                                      })                                          .then(ch => {                                              members.forEach(m => {                                                  ch.createOverwrite(m, {                                                      "VIEW_CHANNEL": true,                                                      "SEND_MESSAGES": true,                                                      "READ_MESSAGE_HISTORY": true,                                                      "USE_EXTERNAL_EMOJIS": true                                                  }).then(chan => chan.send(`${m.user}`));                                              });                                          });  

The error occurs in the part. The content of the error is the same as the title. Is there a workaround for this problem?

https://stackoverflow.com/questions/67410599/unhandledpromiserejectionwarning-typeerror-cannot-read-property-toobject-of May 06, 2021 at 09:03AM

没有评论:

发表评论