#Mongo db/discord.js
137 messages · Page 1 of 1 (latest)
- 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!
.find should be .findOne
make sure your schema have the correct format
Pretty sure it is but just to double check here
Schema: https://sourceb.in/FeW8RG0Z6E
the only possibility is there is no data in db
did you save any data inside?
and make sure do schema.save() after making changes to the collection by using js code
no
there is one at
await newData.save();
const embed = new EmbedBuilder()
.setDescription(Playlist Created **${createplaylist}**)
.setColor("Blue")
interaction.reply({ embeds: [embed] })
},
};
also am i making data using this?
just do if statement with !data
why would you use length
or data
length is useless here
and also .length can't be used in object
did you learn js?
but arrays and strings only
not for objects
Wtf you mean the. Legth is useless it makes the playlist name only go up to 10
wym length is for playlist name
Did you even look at the code.
you do data.length if statement in line 55
data is an object.
not a string
Thought you were talking about 33.
and also your log dont have error with your code?
Nope
check line 55 first
What should I use then
use data instead of data.length
line 33 dont have issue
It don't get pass through 22 with find one btw.
use findOne
and if you want fetch all document then use find() only
then use .then
Findone don't work
if there is no data in your db, it wont log anything since it is null
and also you didnt fill up required option while saving the data
this is an err
Wdym
you didnt fill up songs and CreatedOn
while doing data.save()
the number two screenshot does show you the error
and you can compare with number 1 screenshot, you said songs and CreatedOn data are also required
Should I change new data to data.save
no need but you need to change number 2 screenshot code
save songs and CreatedOn option
and also change all find() to findOne()
since you do not need every doc
Ok
findOne does only find specific user id
So make createdOn to false for require
and num.length should use .forEach to get the num data
yes or just delete it
you do not required to fill that option in schema
and do num.songs (the Playlist? idk since your db dont have playlist count but songs and playlist name)
What did I have to change here?
fill up required option in your schema
?
your playlist schema
these code
check if you fill up required options
Yea I did
Removed CreatedOn
ok then run your code again
network issue for first
Common causes of DiscordAPIError[10062]: Unknown interaction:
- Initial response took more than 3 seconds ➞ defer the response *.
- Wrong interaction object inside a collector.
- Two processes handling the same command (the first consumes the interaction, so it won't be valid for the other instance)
* Note: you cannot defer modal or autocomplete value responses
How'd I fix?
restart bot
I cant help with that since its your network issue
it is similar to connect timed out
just restart bot
try again
Ok
same errors hm would it be a my bots server issue or the dbs.
Or can you not tell
Wait I can use mongodb://127.0.0.1:27017/myapp
follow the connection string that mongodb gave you
you can either use localhost or cloud ver mongodb
When I add ip do I remove the @
(mongodb://user:pw@host1.com:27017)
the first thing to do is remove the error not change the connection string bruh

I can't even find the error.
In the stackoverflow
Or is it like not in there
I already connected so how I fetch my data now
then run the cmd again
did you connect when your bot ready?
if yes show your ready event file
I have connect on its own
File
const config = require('../configuration/index')
async function connect() {
mongoose.set('strictQuery', true)
mongoose.connect(config.mongodbURL, {
useNewUrlParser:true,
autoIndex:false,
useUnifiedTopology:true
});
mongoose.connection.once("open", () => {
console.log("🟩 Connected to mongoose");
});
mongoose.connection.on("error", (error) => {
console.log(`🟥 MongoDB connection error: ${error}`);
})
return;
}
module.exports = { connect }```
It always says connected to mongoose
try do a findOne any collection by using .then with mongoose.connect
So just on my findone I just do .Then(mongoose.connect) ?
mongoose connect first
wait I dont think playlists.findOne() is in this cmd file
.
that should be another file
?
show your current code pls
create command file
becuz I didnt found any name in the file called playlists
Current
why you still use data.length
use forEach then return the value or just use .then
and your num.songs do forEach also and return the value or use .then
What I do with data.length
do I what said
forEach
then return the value
?
did you learnt js before
Yes
then you dk forEach?
and you dk .length only for strings and arrays?
Forgot for each existed sense I never use it
you should learn js again #resources
forEach and length is basic
I won't spoonfeed anyone
and #rules rule 3 does said abt it
Foreach(Data.legth).then(data.length)like this
no
Isn't that what you said tho
.forEach(value => {return value;})
or .forEach(value => {...})
so .ForEach(data.legth=>return Data.length)}
that’s not even valid javascript. please learn js
Array.prototype.forEach()
The forEach() method of Array instances executes a provided function once for each array element.
how do i do the .then way?
cuz idk what to do with the foreach length.forEach((data) =>