database

I have a file called database.js
const client = requre('Client.js');
const Sequelize = require('sequelize');

const sequelize = new Sequelize('database', 'user', 'password', {
    host: 'localhost',
    dialect: 'sqlite',
    logging: false,
    storage: 'database.sqlite',
});

const blocked = sequelize.define('blocked', {
    user: {
        type: Sequelize.STRING,
        unique: true,
    },
});


and here is my command file:
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
const Client = require('../Constants/Client.js');
const Sequelize = require('sequelize');



module.exports = {
  data: new SlashCommandBuilder()
    .setName('test')
    .setDescription('test cmd')
    .addUserOption(option =>
      option.setName('user')
        .setDescription('user to be banned from using bot')
        .setRequired(true)),

  async execute(interaction) {
const person = interaction.options.getUser('user');
    try {
            const user = await blocked.create({
                user: person.id,
            });

            return interaction.reply(`added ${person.tag}`);
        }
        catch (error) {
            if (error.name === 'SequelizeUniqueConstraintError') {
                return interaction.reply('That tag already exists.');
            }

            return interaction.reply('Something went wrong with adding a tag.');
        }
    }
}; 
Was this page helpful?