This is the part that is relevant to the question. If you message the bot “Here are my arguments what do you think about that?”, I want it to return: I need to figure out the command that counts the number of words in a sentence and change this: message.channel.send(`Arguments: ${}`); I’m no…
Tag: node.js
How to group by sub documents and get unique value of value field?
This is my database collection: Now I want to send the data of only the attribute where isVariation is not 0. Also I want to send the variant values of each attribute where isComplete =1. Hence the result should look like this The above result does not have value of 2.5 inch as the isComplete is 0 for this do…
How to add MySQL query results from a loop in Nodejs?
Essentially, I have an object with string keys and values (ex. {“michigan”:”minnesota”}). I’m trying to loop through all of these key value pairs and make a query from my database, and add the result to a list, which will then be what is returned to the front end. This is what I …
jest ReferenceError: Cannot access ” before initialization
I’m getting the error: ReferenceError: Cannot access ‘myMock’ before initialization Even though i respected jest documentation about the hoisting: A limitation with the factory parameter is that, since calls to jest.mock() are hoisted to the top of the file, it’s not possible to first …
React Native Firebase Array Query to do ArrayContains with AND operation
I have group collection. In each group document, I store which users are associated with the group via members array field in firebase. Eg: user1 & user2 are in xyz(id) group and I would like to query from client to get all the group where having user1 & user2 ( not OR ). I have tried firebase IN arra…
Reason after blacklisting command Discord.js
I want to add a reason to my blacklists (with the command !blacklist {userid} {reason}) which are visible in the embeds below like .addField (“💬 Reason:”, somecode) how can I fix this? Answer First you’ll want to check if there is no reason, this can be simple done by checking, for both appr…
How to return the variant values of each product if that product is a variant?
I have a database in MongoDB like this Now I want to return data where 500 GB has been in productId 1 and 3 The response should be like this: I have the possible values that I store in another collection for variantPossible values. The values that i am storing are like this: I want to return the variant value…
Adding style guide to next.js (react) returns Error: ENOENT: no such file or directory,
I just started learning next.js and I wanted to add some documentation using https://react-styleguidist.js.org/ I created my project using npx create-next-app After installing it, and adding some configuration I’m getting the following error when trying to run it using the following command: npx stylegu…
Top level await not working in Node JS 14.15.3
I am on running Node version 14.15.3 Welcome to Node.js v14.15.3. I thought it was cool that you could use await now in top level scripts, so I tried it. To not my surprise, it didn’t work. SyntaxError: await is only valid in async function at wrapSafe (internal/modules/cjs/loader.js:979:16) at Module._…
How to delete a file with an unknown extension using fs in NodeJS?
I want to delete a file named myfile with any extension. The error I get: But there is a file named myfile.jpg which I want to delete. Let’s pretend that we don’t know the extension. How can I delete it? Answer unlink doesn’t support regex to delete file. You will probably need to loop throu…