Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

348
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda