Home > Back-end >  Database information embed discord.js
Database information embed discord.js

Time:10-30

I successfully connected my Discord Bot to my sql database. But right now the data I receive from the database is only getting logged in my console but I wanna change that. I want to make an embed with information from the database and fill the values with the information from the database. I tried to do that but it's giving me an error and I don't know what to change in the embed so it works properly. The database looks like this

MySQL connection:

connection.connect(function (err) {
  if (err) throw err;
  connection.query('SELECT * FROM`player_count`', function (err, result) {
    if (err) throw err;
    console.log(result);
  });
});

The data that is getting logged:


[
  RowDataPacket {
    id: 1,
    cop_count: '0',
    medic_count: '0',
    civ_count: '1'
  }
]

The embed I tried to make:


if (message.content.startsWith(prefix   'info')) {
  const connection = mysql.createConnection({
    host: 'private',
    port: '3306',
    user: 'User',
    password: 'private',
    database: 'test',
    charset: 'utf8mb4',
  });

  connection.connect(function (err) {
    if (err) throw err;
    connection.query('SELECT * FROM`player_count`', function (err, result) {
      if (err) throw err;

      const serverembed = new Discord.MessageEmbed()

        .setTitle('Info:')
        .setThumbnail('png')
        .setColor('GOLD')
        .addFields(
          { name: '           
  • Related