Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

111
Views
document.querySelector in a discord.js bot

I want to connect a local site with a discord.js bot so if the thing I want to do works put it online in a server.

I want to sent in a discord server channel the value of an input.

js: src/bot/index.js

const { Client, Intents } = require('discord.js');
const { TOKEN } = require('./config.json');

channelid = "925049593056596009"

const client = new Client({ intents: 32767});


client.once('ready', () => {
    console.log('Ready!');
});

function test() {
    document.querySelector('.button').addEventListener('click', () => {
        channelid.send(document.querySelector('.input').value)
    })
}
test()
client.login(TOKEN);

html: src/html/application.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Applications</title>
</head>
<body>
    <script src="../bot/index.js"></script>

    <form>
        <input class="input" type="text" placeholder="say something">
        <button class="button">OK</button>
    </form>
</body>
</html>

Error:

   document.querySelector('.button').addEventListener('click', () => {
    ^

ReferenceError: document is not defined
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Add require.js to your project from this link require.js

Then load discord.js and its index.js as follows

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Applications</title> </head> <body> <script data-main="./src/discord.js" src="./src/require.js"></script> <script data-main="./src/index.js" src="./src/require.js"></script> <form> <input class="input" type="text" placeholder="say something"> <button class="button">OK</button> </form> </body> </html>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!