Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

113
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda