#Mongo db/discord.js

137 messages · Page 1 of 1 (latest)

dense stirrup
faint coralBOT
  • 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!
ivory dragon
dense stirrup
ivory dragon

did you save any data inside?

and make sure do schema.save() after making changes to the collection by using js code

dense stirrup
dense stirrup
dense stirrup
ivory dragon

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

dense stirrup

Wtf you mean the. Legth is useless it makes the playlist name only go up to 10

ivory dragon

wym length is for playlist name

dense stirrup

Did you even look at the code.

ivory dragon

you do data.length if statement in line 55

data is an object.

not a string

dense stirrup

Thought you were talking about 33.

ivory dragon

and also your log dont have error with your code?

dense stirrup

Nope

ivory dragon

check line 55 first

dense stirrup
ivory dragon

use data instead of data.length

line 33 dont have issue

dense stirrup

It don't get pass through 22 with find one btw.

ivory dragon

use findOne

and if you want fetch all document then use find() only

then use .then

dense stirrup

Findone don't work

ivory dragon

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

dense stirrup

Wdym

ivory dragon

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

dense stirrup

Should I change new data to data.save

ivory dragon

save songs and CreatedOn option

and also change all find() to findOne()

since you do not need every doc

dense stirrup

Ok

ivory dragon

findOne does only find specific user id

dense stirrup

So make createdOn to false for require

ivory dragon

and num.length should use .forEach to get the num data

ivory dragon

you do not required to fill that option in schema

ivory dragon
dense stirrup

What did I have to change here?

ivory dragon
dense stirrup

?

ivory dragon

your playlist schema

these code

ivory dragon
dense stirrup

Yea I did

Removed CreatedOn

ivory dragon

ok then run your code again

dense stirrup
ivory dragon
digital gazelleBOT

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
dense stirrup
ivory dragon

I cant help with that since its your network issue

it is similar to connect timed out

just restart bot

try again

dense stirrup

Ok

same errors hm would it be a my bots server issue or the dbs.

Or can you not tell

dense stirrup

Wait I can use mongodb://127.0.0.1:27017/myapp

ivory dragon

follow the connection string that mongodb gave you

you can either use localhost or cloud ver mongodb

dense stirrup

When I add ip do I remove the @
(mongodb://user:pw@host1.com:27017)

ivory dragon

the first thing to do is remove the error not change the connection string bruh

hero_bruh

dense stirrup

I can't even find the error.

In the stackoverflow

ivory dragon

connect first then fetch the data

dense stirrup

I already connected so how I fetch my data now

ivory dragon

then run the cmd again

dense stirrup

Same error

ivory dragon

did you connect when your bot ready?

if yes show your ready event file

dense stirrup

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

ivory dragon

try do a findOne any collection by using .then with mongoose.connect

dense stirrup

So just on my findone I just do .Then(mongoose.connect) ?

ivory dragon
ivory dragon
ivory dragon
dense stirrup

?

ivory dragon

show your current code pls

create command file

becuz I didnt found any name in the file called playlists

dense stirrup

Current

ivory dragon

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

dense stirrup

What I do with data.length

ivory dragon

do I what said

forEach

then return the value

dense stirrup

?

ivory dragon

did you learnt js before

dense stirrup

Yes

ivory dragon

then you dk forEach?

and you dk .length only for strings and arrays?

dense stirrup

Forgot for each existed sense I never use it

ivory dragon

forEach and length is basic

I won't spoonfeed anyone

and #rules rule 3 does said abt it

dense stirrup

Foreach(Data.legth).then(data.length)like this

ivory dragon

no

dense stirrup

Isn't that what you said tho

ivory dragon

.forEach(value => {return value;})

or .forEach(value => {...})

dense stirrup

so .ForEach(data.legth=>return Data.length)}

near tapir

that’s not even valid javascript. please learn js

digital gazelleBOT

mdn Array.prototype.forEach()
The forEach() method of Array instances executes a provided function once for each array element.

dense stirrup

cuz idk what to do with the foreach length.forEach((data) =>