Error Const TaggedMembers = mentions.users.map

I’m probably not understanding but I would like someone to help me, I’m doing that if someone gives a mention to a user, read if they have afk set in the database so that they return it, I’m supposed to have already defined it in Async execute (message)

My code

const afkModel = require("../../Models/Afk");
const { Message} = require('discord.js')
module.exports = {
    name: "messageCreate",
    async execute(message, client, guild) {

       
        if (message.author.bot || !message.guild) return;

        let data = await  afkModel.findOne({ Guild: message.guild.id, UserID: message.author.id })
            if(!data) return;
            if (data.Afk) {
                if(!data) return;
                data.Afk = false;
                data.save();
            }
            return;
        }};

        const taggedMembers = mentions.users.map(msg => msg.id);

        if (taggedMembers.length > 0) {
            taggedMembers.forEach(m => {
                afkModel.findOne({ Guild: guild.id, UserID: m }, async (err, data) => {
                    if(!data) return;
                    if (data.Afk) {
                        if(!data) return;
                        message.reply(`This user is currently Afk. nReason: ${data.Reason || "None provided."}`);
                    }
                    return;
                })
            })
        } 

  ` 

My error

const taggedMembers = message.mentions.users.map(msg => msg.id);
                              ^

ReferenceError: message is not defined
    at Object.<anonymous> (/Users/joshuaacosta/Desktop/Sayu/Events/Messages/afk.js:20:31)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at loadEvents (/Users/joshuaacosta/Desktop/Sayu/Handlers/eventHandler.js:11:19)
    at /Users/joshuaacosta/Desktop/Sayu/index.js:41:5
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

I would like to know if I am doing wrong and what should I add so that my command works when a user mentanother user and if he has afk he responds with a mention replY

Uncaught ReferenceError: allowScroll is not defined at onScroll (customer:230:3)

I can’t solve the problem can you help me please

When I throw the scroll, other products should appear, but not

<html>
........
    var counter=0;
    var allowSroll=true;
    function onScroll(){
        if(allowScroll){
        const distanceToBottom = document.body.getBoundingClientRect().bottom;
        const documentHeight = document.documentElement.clientHeight;
        if (distanceToBottom < documentHeight + 150){
            allowScroll=false;
            counter++;
            console.log('onScroll: '+counter);
            
            begin+=5;
            
            xht.open("POST","/rest/books/search-find-partial", true);
            xht.setRequestHeader("Content-type", "application/json");
            var searchObject={search:'',begin:begin,length:length};
            xht.send(JSON.stringify(searchObject));
          
            setTimeout(function(){allowScroll=true;},1000);
            
        }
        }
        }
        window.addEventListener("scroll",onScroll);
</html>

How can I read json objects from json file in internal storage to Textview? Android Studio

I am building an android application that stores data in a json file locally and reads/displays the data when the user opens the app. I have successfully done the code for writing json objects into json arrays which are stored in the internal storage of my android device. My problem is to get the app to read those json objects back into the device, specifically into a textview(s).

Here is how the json array looks like:

[
    {
        "Record Group Code":"RepGrpID",
        "Province":"Central",
        "District":"Kairuku",
        "Facility":"Upulima SC",
        "Date":"09/03/2023"
    }
]

Here is a piece of code from my MainActivity.java where I created the readfile().

package com.example.covid_19vaccination;

import ...


public class MainActivity extends AppCompatActivity {

    private static final String FILE_NAME = "covid_data";

    TextView TextViewRGCode, TextViewProvince, TextViewDistrict, TexviewFacility, TextViewDate;

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        readFile();


        TextViewRGCode = findViewById(R.id.trRGC);
        TextViewProvince = findViewById(R.id.trProv);
        TextViewDistrict = findViewById(R.id.trDist);
        TextViewFacility = findViewById(R.id.trFac);
        TextViewRGCode = findViewById(R.id.trDate);

        ...

    }
}
       

and for the readFile() I did this:

private void readFile() {

        File file = new File(this.getFilesDir(),FILE_NAME);
        try {
            FileReader fileReader = new FileReader(file);
            BufferedReader bufferedReader = new BufferedReader(fileReader);
            StringBuilder stringBuilder = new StringBuilder();
            String line = bufferedReader.readLine();

            while (line != null) {

                stringBuilder.append(line).append("n");
                line = bufferedReader.readLine();

            }
            bufferedReader.close();


        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

this is where I am stuck. I want to get the values of each json object into and display in their respective Textview widgets but I don’t know what to do from here and can’t find a clear and direct approach for this on the internet. I am very new to android and Java and if anyone would help me out I would appreciate it.

How to solve deploying firebase cloud functions error?

I am using firebase cloud functions.
There is a function called fetchNewsScheduled, it will run every 2 hours =>

  1. clear the collection by fn clearNewsCollection to release database

  2. Fetch data from API and push them to the database
    That’s all…
    However, errors happen and I have no idea

type ArticleType = {
  _type: string;
  name: string;
  url: string;
  image: {
    _type: string;
    thumbnail: {
      _type: string;
      contentUrl: string;
      width: number;
      height: number;
    };
    isLicensed: boolean;
  };
  description: string;
  datePublished: string;
};

type SimplifiedArticleType = {
  name: string;
  url: string;
  imageUrl: string;
  description: string;
  datePublished: string;
};
async function clearNewsCollection() {
  const snapshot = await db.collection("news").get();
  const batch = db.batch();
  snapshot.forEach((doc) => {
    batch.delete(doc.ref);
  });
  await batch.commit();
  console.log(`Deleted ${snapshot.size} documents from`);
}
async function fetchNews() {
  const options = {
    method: "GET",
    url: "https://bing-news-search1.p.rapidapi.com/news",
    params: { safeSearch: "Off", textFormat: "Raw" },
    headers: {
      "X-BingApis-SDK": "true",
      "X-RapidAPI-Key": "my_key",
      "X-RapidAPI-Host": "bing-news-search1.p.rapidapi.com",
    },
  };

  try {
    await clearNewsCollection();

    const response = await axios.request(options);

    const newsArticles = response.data.value; //an array
    const simplifiedArticles = newsArticles.map((article: ArticleType) => {
      return {
        name: article.name,
        url: article.url,
        imageUrl: article.image?.thumbnail?.contentUrl,
        description: article.description,
        datePublished: article.datePublished, //eg. "2023-03-10T14:31:02.0000000Z", moment(datePublished).fromNow();
      };
    });

    const batch = db.batch();

    simplifiedArticles.forEach((article: SimplifiedArticleType) => {
      const docRef = db.collection("news").doc();
      batch.set(docRef, article);
    });
    await batch.commit();

    console.log("Batch write successful");
  } catch (error) {
    console.log("Error writing documents:", error);
  }
}
// Define the Cloud Function to run every 2 hours
export const fetchNewsScheduled = functions.pubsub
  .schedule("every 2 hours")
  .onRun(async (context) => {
    await fetchNews();
    return null;
  });

Error: There was an error deploying functions:

Error Failed to update function fetchNewsScheduled in region us-central1

search string in any object while debugging mouse click event in chrome dev tools

I’m exploring source code of website using dev tools event listener break point.
I want to search place in source code where variable/attribute/object/whatever with type string become contain my pattern.
In other words, i want kind of this:

Find('hahaha');
# processing
Result object: var a='you can't find me hahaha'
# or
Result object: var b='hahaha'

I know about watch expressions, but i must set there object name and full object value (can’t set a part of object value)


Why do i need it? Because i’m writing scraper for this website
and can’t get s parameter to open next page for category…And how i understand it’s generating inside bunch of javascript files. That’s how i want to understand process of generating parameters for next requests.


I’m such a newbie in js and dev tools at all, so if you can give any other workaround, i would be very glad

how to work with wave-component under a-frame 1.3.0? It is working only with a-frame 0.8.2

I have used wave-component with A-frame version 0.8.2. That component is not working with A-frame version 1.3.0. Do you know a solution for this?

Thank you for your help.

<html>

    <script>

        AFRAME.registerComponent('wave-component', {
            schema: {
                texturepath: {type: 'asset'}
            },
            init: function () {

                console.log(this.data.texturepath.src)

                var el = this.el;
                const loader = new THREE.TextureLoader();

                var geometry = new THREE.PlaneGeometry(10, 3, 100, 60);

                // Creating a material with the texture path provided
                var material = new THREE.MeshBasicMaterial({
                    map: loader.load(this.data.texturepath.src),
                    transparent: true
                });

                var wave = new THREE.Mesh(geometry, material);

                // wave.rotation.set(-0.1, 0, 0);
                wave.rotation.set(-0.3, 0.0, -0.0);
                // wave.rotation.set(0, 0, 0);
                const clock = new THREE.Clock();

                el.setObject3D('WaveMesh', wave);

                // Function to animate each vertex of the texture to simulate a wave effect
                function animate() {
                    const t = clock.getElapsedTime();

                    wave.geometry.vertices.map(v => {
                        // const waveX1 = 0.15 * Math.sin(v.x * 2 + t * 3);
                        const waveX1 = 0.15 * Math.sin(v.x * 2 + t * 3);
                        // const waveX2 = 0.05 * Math.sin(v.x * 3 + t * 2);
                        const waveX2 = 0.05 * Math.sin(v.x * 5 + t * 2);
                        // const waveY1 = 0.001 * Math.sin(v.y * 3 + t * 0.5);
                        const waveY1 = 0.1 * Math.sin(v.y * 10 + t * 0.5);
                        // const multi = (v.x + 2.5) / 5;
                        const multi = (v.x + 0.1) / 5;

                        v.z = (waveX1 + waveX2 + waveY1) * multi;
                    })

                    wave.geometry.verticesNeedUpdate = true;
                    requestAnimationFrame(animate);

                }
                animate();
            }
        });


    </script>

This script works fine with A-frame 0.8.2 but does not with A-frame 1.3.0

405 Method Not Allowed – Strapi Custom Plugin

I’m developing a Strapi Plugin that will contain 2 POST routes as /create-payment-intent and /confirm-payment-intent but my tests using Insomnia are always returning the error 405 Method Not Allowed.

I have no issues when starting the Strapi server (yarn develop && yarn build). I’ve tried different approachs but nothing has fixed it.

Follow my srcpluginspaymentserverroutesindex.ts:

const paymentRoutes = [
  {
    method: "POST",
    path: "/create-payment-intent",
    handler: "paymentController.createPaymentIntent",
    config: {
      auth: true,
      policies: [],
    },
  },
  {
    method: "POST",
    path: "/confirm-payment-intent",
    handler: "paymentController.confirmPaymentIntent",
    config: {
      auth: true,
      policies: [],
    },
  },
];

export default paymentRoutes;

and configplugins.js:

module.exports = ({ env }) => ({
    // ...
    'payment': {
        enabled: true,
        resolve: './src/plugins/payment',
    },
});

The routes I’m trying to reach are:

http://127.0.0.1:1337/v1/payment/create-payment-intent
http://127.0.0.1:1337/v1/payment/confirm-payment-intent

I’m using API Token generated in Strapi admin with full acess, so I don’t need to give permission to them, I guess.

Can anyone tell me what’s wrong please? Thank you!

How to record the current tab of the user without giving them the prompt to choose which screen they want to share

I am new to extension development, and I am trying to create something like loom chrome extension which would record user screen. After researching I found out that desktopCapture api can be used to record the user screen, but using the desktopCapture prompt the user to choose which screen they want to share.

I installed loom chrome extension and there was an option to record just the current tab of the user, and when I click on it, it didn’t ask for permissions or choice, it just record the current tab seamlessly. How is that happening? How can I record just the current tab without any prompts or permissions?

The official chrome extension mentions that **recording the user screen or tab without their permission is considered invasive and may violate user privacy. It’s always a good idea to be transparent with users about what you’re capturing and why** I am a little confused about it, loom didn’t ask for any permission before recording the current tab. And how to record the current tab without any privacy issues?

Amazon API Gateway Client initalization using Java – Not working

I have problem initializing API Gateway Client in Java using AWS-Java-SDK (tried old and newest version). I’ve checked 10 times if my access and secret keys are correct and they are. I’m not sure what i bad coded so it stops working after “Good 2” output. Need help please

Here’s my code:

        public void startAPIGateway() {

        callbacks.printOutput("Starting API Gateway");
        
        String API_NAME = "Testing";

        
        BasicAWSCredentials credentials = new BasicAWSCredentials(accessKeyField.getText(), secretKeyField.getText());
        callbacks.printOutput("Good 1");
        // Create an AWSStaticCredentialsProvider object with the credentials
        AWSStaticCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials);
        callbacks.printOutput("Good 2");
        
        // Create an AwsClientBuilder object with the region and endpoint;
        AmazonApiGatewayClientBuilder clientBuilder = AmazonApiGatewayClientBuilder.standard().withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("https://apigateway.eu-east-2.amazonaws.com", "eu-east-2"));
        callbacks.printOutput("Good 3");
        // Set the credentials provider on the client builder
        clientBuilder.setCredentials(credentialsProvider);
        clientBuilder.setRegion("eu-east-2");

        
        AmazonApiGateway client = clientBuilder.build();

        
        callbacks.printOutput("Goodzzzz");
        
        
        CreateRestApiRequest restApiRequest = new CreateRestApiRequest().withName(API_NAME);
        CreateRestApiResult createRestApiResult = client.createRestApi(restApiRequest);

callbacks.printOutput(createRestApiResult.getId());

// Add a new resource with a path variable
GetResourcesRequest getResourcesRequest = new GetResourcesRequest()
        .withRestApiId(createRestApiResult.getId());


GetResourcesResult getResourcesResult = client.getResources(getResourcesRequest);

CreateResourceRequest createResourceRequest = new CreateResourceRequest()
        .withRestApiId(createRestApiResult.getId())
        .withParentId(getResourcesResult.getItems().get(0).getId())
        .withPathPart("{proxy+}");

CreateResourceResult createResourceResult = client.createResource(createResourceRequest);
        
    }

enter image description here

How to convert an object composed by two arrays of objects into an array of one property of each object

this is the initial input
Object {

Belleza: Array(3) [ {…}, {…}, {…} ]
​​
0: Object { category: “Belleza”, text: “Alimentacion Saludable” }
​​
1: Object { category: “Belleza”, text: “Rutinas” }
​​
2: Object { category: “Belleza”, text: “Cuidado Facial” }
​​
​​

Viajes: Array [ {…}, {…} ]
​​
0: Object { category: “Viajes”, text: “Trabajo remoto” }
​​
1: Object { category: “Viajes”, text: “Viajar con poco dinero” }

​​}

I have the object above and I need to convert it into somthing like this:

{

Belleza:[“Alimentacion Saludable”,”Rutinas”,”Cuidado Facial”],
Viajes:[Trabajo remoto,Viajar con poco dinero]

}

I tried whit reducing method but didn’t work, to be hones I dont know how to implement it

Keeping a nav bar (WITH DROP DOWN!!) on all pages without having to copy paste it every time

I would like for a nav bar with some specifications to be kept on every page. I have tried a few solutions on this thread How can I reuse a navigation bar on multiple pages? but surprisingly none of them worked for me – it makes the nav bar dissapear completely.

I suspect this is due to the fact that I have a dropdown on my nav bar, and also the specification that it should stay fixed on teh top of each screen when I scroll down.

Here is the navbar code:

<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">

        <link rel="stylesheet" href="style.css">
        <script src="https://kit.fontawesome.com/0a48c3a8e0.js" crossorigin="anonymous"></script>

    </head>
<div class="navbar">
    <a class="active" href="home.html"> Home </a>
    <a href="about.html">About</a>
    <a href="start">Start</a>
    <a href="blog">Blog</a>
    <div class="dropdown">
        <button class="dropbutton"> Interests</button>
        <div class="dropdown-content">
                <a href="finance">Finance</a>
                <a href="music">Music</a>
                <a href="language">Language</a>
                <a href="math">Math</a>
        </div>
    </div>

    <div class="search-container">
    <input type="text" placeholder="Search...">
    <button type="submit"><i class="fa-sharp fa-solid fa-magnifying-glass"></i></button>
    </div>

</div>
</html>

  .navbar {
    background-color: black;
    /*overflow: hidden; WE DONT WANT THIS! prevent drop down*/
    width: 100%;
    position: fixed;
    top: 0px 

  }
  .navbar a{
    float: left;
    color: aliceblue;
    text-align: center;
    padding: 10px 10px; 
    font-size: 25px;
    text-decoration: none; 
  }
  .navbar a:hover {
    background-color: lightseagreen;
    color: black;
  }
  .navbar a:active {
    background-color: lightseagreen;
    color: aliceblue;
  }

  .dropdown{
    float: left;
    overflow: hidden;
  }

  .dropdown .dropbutton {
    font-size: 25px;
    border: none;
    outline: none;
    color: aliceblue;
    padding: 10px 10px;
    background-color: inherit;
    font-family: inherit; /* Important for vertical align on mobile phones */
    margin: 0; /* Important for vertical align on mobile phones */
  }

  .navbar a:hover, .dropdown:hover .dropbutton {
    background-color: lightseagreen;
  }

  /* hide dropdown default*/
  .dropdown-content {
    display: none;
    position: absolute;
    background-color: black;
    min-width: 160px;
  }

  .dropdown-content a {
    float: none;
    color: aliceblue;
    text-align: center;
    padding: 10px 10px; 
    font-size: 25px;
    text-decoration: none; 
    display: block;
  }

    /* Show the dropdown menu on hover */

.dropdown:hover .dropdown-content{
  display: block;
}
.navbar a.active{
  background-color: lightseagreen;
}
.navbar input[type=text]{
  float: none;
  padding: 5px 10px;
  border: none;
  margin-top: 10px;
}
.navbar .search-container {
  float: right;
}
.navbar .search-container button {
  float: right;
  padding: 5px 10px;
  margin-top: 10px;
  margin-right: 16px;
  background: #ddd;
  font-size: 17px;
  border: none;
  cursor: pointer;
}

I tried most of the JAVASCRIPT solutions on the thread. Because I am a newbie new to this, i want to keep it as close to JS, HTML and CSS first ie with the basics. I also did try some of the JQuery solutions but it did not work unfortunately either.

These are extracts from the things I tried (they all didnt work anyway)

I have a MAIN HOME PAGE called home.html, and my nav bar is in a SEPERATE FILE nameed navbar.html

   <!--<script src="nav.js"></script>-->

   <div id="nav-placeholder"></div>
   <script>
    $.get("navbar.html", function(data){
        $("#nav-placeholder").replaceWith(data);
    });
    </script>

Webhook revalidation always returning `304` using Supabase

Here is this automatic webhook revalidation response:
image

And here is what I do:
image

As you can see, I send an API request every time I either insert of delete something from the database, but I get a 304 error. However, if I do it manually by sending an API request manually by following it as a link, it goes successfully, so it shows 200. What is the reason why it only works whenever I do manually?

Issues Authenticating with AAD using Cypress

I’m trying to write automated tests using Cypress for an application which is authenticated through Azure Active Directory.

I’m following a guide found on the cypress website, and it is successfully loading the login page, entering the password and seems to be successful til the last step – when the POST token API call fails with an error 400 and including this error message from AAD

Tokens issued for the ‘Single-Page Application’ client-type may only be redeemed via cross-origin requests

Some research has indicated that this is due to the “origin” header not being passed, and the header is actually not being sent with the request.

If I modify the chromeWebSecurity field in the config, it works for a while, but then randomly and inconsistantly starts failing again

module.exports = defineConfig({
  e2e: {
    setupNodeEvents,
    specPattern: "cypress/e2e/features/*.feature",
    baseUrl: "https://xxxxxxxxx", //My website url
    chromeWebSecurity:true,
    experimentalModifyObstructiveThirdPartyCode:true,
    }
//...
});

The login code is copied almost directly from the example in the guide, but I’ve reproduced it here

function loginViaAAD(username, password) {
    cy.visit('https://xxxxxxxxx')//My website

    // Login to your AAD tenant.
    cy.origin(
      'login.microsoftonline.com',
      {
        args: {
          username,
          password
        },
      },
      ({ username, password }) => {
        cy.get('input[type="email"]').type(username, {
          log: false,
        })
        cy.get('input[type="submit"]').click()
        cy.get('input[type="password"]').type(password, {
                    log: false,
                  })
                  cy.get('input[type="submit"]').click()
                  cy.contains("Yes").click();
      }
    )
        cy.url().should("contain","https://xxxxxxx"); //My website
    }

How can I fix this, why isn’t Cypress sending the origin header with the request?

curl convertion to xhr fails [duplicate]

here is my curl line which works flawlessly :

curl -D- -u user:pwd -X POST -H "X-Atlassian-Token: nocheck" -F "[email protected]" https://domain/csbugtrack/rest/api/2/issue/584025/attachments

I’ve tried to make an XHR request (a fetch request does also not work) :

const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.open("POST", "https://domain/csbugtrack/rest/api/2/issue/584025/attachments", true);
xhr.setRequestHeader("X-Atlassian-Token", "nocheck");
xhr.setRequestHeader("Authorization", 'Basic ' + btoa('user:pwd'));
const form = new FormData();
form.append('file', new File(['test'], 'D:test.txt'));
xhr.send(form);

and I get :

Blocage d’une requête multiorigines (Cross-Origin Request) : la politique « Same Origin » ne permet pas de consulter la ressource distante située sur https://domain/csbugtrack/rest/api/2/issue/584025/attachments. Raison : l’en-tête CORS « Access-Control-Allow-Origin » est manquant. Code d’état : 200.

why curl does better and how can I solve this ?

(I’ve also tried a fetch request which has the similar CORS issue)