I have an economy system on my discord server and players can buy VIP for 30 days. Data are saved in firestore cloud database. The bot checks every 4 hours if someone has over his VIP and it should remove it but it doesn’t work. Console says: Cannot read property ‘roles’ of undefined. Here i…
How to create JSON Object in JavaScript?
I have JSON like this : I’m trying to create a JSON like this : Code : Suppose I don’t know how many data I have, how do I create this object in JavaScript? Answer You can use Array.reduce()
How to get 1st true value for *ngIf inside *ngFor
I have an array of items that need to be displayed based on roles. I need the first value which will fulfil the ngIf condition. I am adding my code below: My Array(kind of how it will originally look): My Html: – UserRole is a string value that I get when a user logs-in. I need to add a ngClass
How to use apps script to count cells number and change the context in other column based on it?
Currently, I have three columns in my google sheets, column 1 is the company name, column 2 is industries name and column 3 is turnover (but the data is repeated). And I want to count the same company name and divide the turnover based on that number use apps script. Here are the example and result I want. Th…
Parsing error: Unexpected token => when trying to deploy firebase cloud function. I couldn’t find any answers on here
my .eslintrc.js My firebase cloud function is throwing this error Parsing error: Unexpected token =>. Does anyone know why this is happening? I am using javascript btw not TS. Answer Arrow functions are an ES6 feature, but here you have an async arrow function. Async functions in general are an ES8 (or 201…
Why is bookmarklet script blocked? Webpage CSP seems ok
I have a bookmarklet. When the user clicks the bookmarklet, it inserts a tiny snippet of code. This code inserts a script element, which in turn gets the actual script that does the work. This works on most websites, but some websites block scripts via their content-security-policy. For example, they might ha…
How can I return the results of my backend Query onto my frontend to display on a page
simple query I am currently trying to learn about the MERN stack and developing an application. This is my simple query where I am just searching for snacks with “orit” substring and thus return snacks with “Doritos” etc. How may I integrate this query or take the result and display it…
arranging s around a polygon (HTML, css, .ejs)
I want to arrange some rectangular div components around a regular polygon. Basically one of the long sides of the divs will be coincident with a line segment around the polygon. In the final code, I’ll use .ejs (since the number of sides of the polygon is dynamic, 3-10 sides). In my “quick and di…
Using react-router to redirect upon form submission
When I enter a search term (name, email, username) I want the page to filter out one card from all of the cards based on the search value. I think when the user presses enter, we would need to redirect to a new page to display the card. I have the code for searchbar and the user component which would
Mongoose query where X is in both arrays and where Y is in only one array
I am building a filtering system and I am stuck on a problem, please keep in mind that this is demo code, this is not the same project but the concept is the same, I replaced the names to make it as easily understandable as possible. I got a filled filter object which gets sent like this (it consists of