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

350
Visualizações
How do I make a command in Discord bot in js that insert data in a database with Sequelize?

I'm working on a Discord bot using node.js modules and Sequelize to database, and I want to add a command that users type and the bot registers them in database. This is the code so far:

const { SlashCommandBuilder } = require('@discordjs/builders');
const { User } = require('discord.js');
const tableData = require('../config/tableData');

module.exports = {
  data: new SlashCommandBuilder()
    .setName('Registro')
    .setInfo('Cria uma conta bancária no nosso banco de dados!'),
    async execute(interaction) {
      function insertData() {
        const newData = tableData.create({
          name: `${User.id}`,
          saldo: 0,
          farm: false,
      });
      return newData;
    }
    await interaction (insertData());
  },
};

But I really don't know why it's not working. First I have one file for the creation of database and the definition of the table to use, but when I export both, my bot throws an error that says it is not able to connect to my database. So I created a single file for each one and tried to connect, but honestly, I have no idea what I have to do.

about 4 years ago · Juan Pablo Isaza
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