user existence check not working – discord.js

I’m trying to write a discord bot.

Now there is one command in which another user is selected. So far, all commands work except for one, checking for the existence of a user.

That’s how I do it

if (!userToMarry) {
      return message.channel.send('Please try again with a valid user.')}

If there is no such user, then a corresponding message should be displayed.

But instead I get this message

You provided an invalid userToMarry. Please try again.
Respond with cancel to cancel the command. The command will automatically be cancelled in 30 seconds.

How can this be fixed?

const { Command } = require('discord.js-commando');
const db = require("quick.db");


module.exports = class MarryCommand extends Command {
  constructor(client) {
    super(client, {
      name: 'marry',
      memberName: 'marry',
      group: 'test',
      description: 'Marry the mentioned user',
      guildOnly: true,
      args: [
        {
          key: 'userToMarry',
          prompt: 'Please select the member you wish to marry.',
          type: 'member'
        }
      ]
    });
  }

  run(message, { userToMarry }) {
    const exists = db.get(`${message.author.id}.user`);
    const married = db.get(`${userToMarry.id}.user`);
    if (!userToMarry) {
      return message.channel.send('Please try again with a valid user.')}

Js: ‘do A on class X’ prevents/overrides ‘do B on class X’

I’ve got a songbook with a complex setup. In the snippet you’ll find the core, a <div class"txt CHORUS"> and a <div class="txt LYRICS">.

The community helped me with a script to increase font-size of .txt.

I’m trying to use the same solution to increase padding-top of .LYRICS, but it prevents/overrides the increase in font-size of .LYRICS, and I’m not able to find anything like that on the web.

I’m posting without the code that breaks the scaling in order to demonstrate how the scaling works, and why I have to scale the padding-top of .LYRICS at the same rate of the font-size of .txt.

document.querySelector("button.in").addEventListener("click", () => zoom(1.1));
document.querySelector("button.out").addEventListener("click", () => zoom(0.9));

function zoom(coeff) {
    document.querySelectorAll(".txt, summary").forEach(el => {
        let css = getComputedStyle(el).getPropertyValue("font-size");
        let size = parseFloat(css);
        let unit = css.replace(/[d.-]*/, "");
        el.style.fontSize = size * coeff + unit;
    });
}
summary { font-size: 20pt }
.txt { font-family: monospace; white-space: pre-wrap; font-size: 14pt }
.zoombox { display: flex; padding: 8pt 0pt }
.chords { position: absolute; }
.lyrics { position: relative; padding-top: 15pt; }
.chords, .lyrics { line-height: 2.3; }
<div class="zoombox">
  <button class="btn zoom out">-</button>
  <div class="txt"> ZOOM </div>
  <button class="btn zoom in">+</button>
</div>

<details open>
  <summary>TITLE 1</summary>
  <div class="songs">
    <div class="txt chords">  Em   F        D#    </div>
    <div class="txt lyrics">A song with its lyrics</div>
  </div>
</details>

<details open>
  <summary>TITLE 2</summary>
  <div class="songs">
    <div class="txt chords">  Em   F        D#    </div>
    <div class="txt lyrics">A song with its lyrics</div>
  </div>
</details>

Strapi CMS third level populating

I have a problem with fetching third level data from Strapi CMS.

My Structure is the following:

Page > Content(Dynamic Zone) > Multiple Entitys e.g. HeroSliderElement.

So Calling this URL from Postman:

{{protocol}}://{{host}}:{{port}}/api/pages?populate[Content][populate]=*

But since inside my HeroSliderElement are images i have the problem, that i dont get these back.

Postman Request
There should be the media data linked from the CMS:

enter image description here

Does anyone have an Idea how to fix this?
Any help is appreciated!

I am currently using the following versions of packages:

  "dependencies": {
"@strapi/plugin-i18n": "4.0.7",
"@strapi/plugin-users-permissions": "4.0.7",
"@strapi/provider-upload-aws-s3": "^4.1.0",
"@strapi/strapi": "4.0.7",
"pg": "8.6.0",
"strapi-provider-upload-aws-s3": "^3.6.8"

},

Why is the value NaN

when I console log the nemo element it appears to be NaN. I have tried adding Number() to certain objects but it has made them undefined. Here is my JS

function newSum(elem) {

  console.log(elem.value)
  var sum = elem.parentElement.parentElement.children[5];

  var price = elem.parentElement.parentElement.children[2].textContent;

  sum.textContent = Number(price) * Number(elem.value);

  var sum = document.querySelectorAll(".summing");

  for (num of sum) {
    tota_sum.push(Number(num.textContent));
  }

  console.log(tota_sum);

  var overall = document.querySelector("#overall");

  var nemo;

  for (i = 0; i < tota_sum.length; i++) {
    nemo += Number(tota_sum[i]);
    console.log(nemo);
  }

}

Getting last element on click every time in Javascript loop with Phaser JS

I am making a game in Phaser although I believe the core of this issue is a lack of my JS understanding.

I am looping through a Phaser container and wish to apply a click handler on each child sprite, but when I execute the click on any of the sprites, it always returns the last child.

I have tried various suggestions on Stack Overflow eg here: JavaScript closure inside loops – simple practical example

but can never get the click to return anything other than the last item.

An Example:

let items = //my container with 4 child sprites to click on
let i = 0;
item.list.forEach(function(obj) {
    obj.setInteractive();
    (function(i) {
        obj.on('pointerdown', function(i){
            console.log(i);
        }.bind(this, i));
    })(i);
    i++;
});

In this example, every sprite I click on outputs ‘3’ tot he console, when it should output 0,1,2 or 3 depending on which was clicked.

Limits of parallel async axios calls in Express+NodeJS

I’m making a NodeJS express API which acts simply as a forwarder to other third party APIs.

Example: A call to /user API in my express app will forward it to some other public API after applying some logic. These are mostly non blocking async calls.

What are the limits of number of parallel requests an Express application can serve?

More specifically:

  1. Let’s say 1,000 apps call this endpoint at a given moment, will Express be able to manage all of them individually?
    There are 2 parts to this question:

    • Will Express as a server be able to take in 1,000 requests, and second
    • will Axios as a communication layer to outer world be able to process 1,000 calls in parallel?
  2. Do I need to manually implement some queuing logic for this to work? If no, what is practically the maximum number of parallel that can be supported?
  3. Is there any architectural pattern that is considered best practice for these kind of scenarios?

I think NodeJS is a better technology to use here compared to Java, because Node is by default single threaded asynchronous runtime. In Java, I’ll have to manually spin up parallel threads to the same task as above, but NodeJS event loop will smartly manage the async calls. Is that correct?

How do I convert a getJson Obj into an array?

I use the openmaps json response to get the border of the city of phoenix.
Heres my code:

    var phoenixbounds  =  [];
$.getJSON("https://nominatim.openstreetmap.org/search.php?q=phoenix&polygon_geojson=1&format=json", function(phoenix) {
  $.each( phoenix[5].geojson.coordinates[0], function( key, val ) {
    var ltlng = {};
    ltlng.lat = this[0];
    ltlng.lng = this[1];
   phoenixbounds.push(ltlng);
  });
});

Whenever I console log it, I get an object.However if I want to use Object.key / or Values it does not work.
How can I get my Object into this format?

   const triangleCoords = [
    { lat: 25.774, lng: -80.19 },
    { lat: 18.466, lng: -66.118 },
    { lat: 32.321, lng: -64.757 },
    { lat: 25.774, lng: -80.19 },
  ];

How to sort an array of HTML elements with JS

I want to sort an array of HTML elements. I want to sort them by the css left property value. That means that the element with the lowest left value is the first element of the array that I want to sort and the element with the highest left value is the last element of the array that I want to sort.

HTML:

<html>
 <body>
   <div class="games"></div>
   <div class="games"></div>
   <div class="games"></div>
 </body>
</html>

CSS:

.games {
  position: absolute;
  transform: scale(1);
  transition: left 0.4s ease;
  width: 20vw;
  height: 20vw;
  border-radius: 2.5vw;
  background-color: white;
  display: flex;
  justify-content: center;
}

.games:nth-of-type(1) {
  left: 6.5vw;
}

.games:nth-of-type(2) {
  left: 40;
}

.games:nth-of-type(3) {
  left: calc(100vw - 6.5vw - 20vw); /* same position if you write: right: 6.5vw*/
}

JS:

const games = document.querySelectorAll('.games');

games.sort((a, b) => {return parseInt(window.getComputedStyle(a).getPropertyValue('left') - parseInt(window.getComputedStyle(b).getPropertyValue('left')})

If somebody gives me an answer, please don’t give me an answer with jquery, because I don’t know anything in jquery.

unable to load from yargs in nodejs

unable to load from yargs.argv. i am using npm latest version. its showing undefined in terminal when i use yargs.argv
unable to load from yargs.argv. i am using npm latest version. its showing undefined in terminal when i use yargs.argv

unable to load from yargs.argv. i am using npm latest version. its showing undefined in terminal when i use yargs.argv

React router does not see the URL

I am trying to make a simple game using Reactjs and react-router. My lobbies.jsx file is in src/components/lobbies.jsx. When I try to compile the app I get this error. What is causing this?

‘Failed to compile
./src/App.js
Line 62: ‘lobbies’ is not defined no-undef

Search for the keywords to learn more about each error.’

        return (
            <Card className={"hostgamename"} style={{width: '18rem', height: '20rem', justifyItems: 'center', marginLeft: '28rem', marginTop:'10rem', display: this.state.onClicked ? 'block': 'none' }}>
            <Card.Body>
                <Card.Title style={{textAlign: 'center', fontSize: '2rem'}}>What is your name, Detective?</Card.Title>
                <input type={"text"} style={{ width: '100%', marginTop:'2rem' }}/>

                <Router>
                    <Routes>
                        <Route path='lobbies.jsx'>
                            <NavLink to={lobbies.jsx}><Button onClick={createJoinRooom}  variant={" btn-primary btn-lg"} size={"xl"}>LET'S GO</Button></NavLink>
                        </Route>
                    </Routes>
                </Router>
            </Card.Body>
            </Card>);

How to make pte (pearson) like test giving platform for practice with AI scoring in Laravel

I want to creat a website in laravel for practicing pte exam just like language academy and real pte. I am confused for AI scoring I would greatly appreciate if you share me knowledge and idea for this. If you have any iead about this then please suggest me.

I am expectring to get the easy way to add AI scoring in my website and also want some ideas about this project.

How to display all data inside the script?

I can get the data from my query, but i dont know why it only print or display the last data

<script>
    async function myFunction() {
        var name = ("SELECT name FROM Person", 10, (value) => {
         return value.forEach(reportChart)
       });
    }
    myFunction().then(function(value){reportChart(value);})
    function reportChart (value) {
      console.log(value) //please see the result below
         $("#chart").kendoChart({
            title: {
                text: "Library"
            },
            legend: {
                visible: false
            },
            seriesDefaults: {
                type: "bar"
            },
            series: [{
                name: "Total Visits",
                data: [value]
            }, {
                name: "Total Visits",
                data: [value]
            }],
            valueAxis: {
                max: 10,
                line: {
                    visible: false
                },
                minorGridLines: {
                    visible: true
                },
                labels: {
                    rotation: "auto"
                }
            },
             categoryAxis: {
                categories: [value],
                majorGridLines: {
                    visible: false
                }
              }, 
            tooltip: {
                visible: true,
                template: "#= series.name #: #= value #"
            }
        });
       
    }

    $(document).ready(reportChart);
    $(document).bind("kendo:skinChange", reportChart);
</script>

the result of console.log(value)

[‘Mark’]

[‘Joseph’]

[‘Luna’]

[‘Yuno’]

it only print the name yuno

enter image description here

please dont read this line, please dont read this line, please dont
read this line, please dont read this line, please dont read this
line, please dont read this line, please dont read this line, please
dont read this line, please dont read this line, please dont read this
line, please dont read this line, please dont read this line, please
dont read this line, please dont read this line, please dont read this
line, please dont read this line, please dont read this line, please
dont read this line,