Skip to content

Sequelize table is not created, even though I used Sequelize.define()

Repository (code):

I am creating a Discord bot with Discord.js. I wanted to add three DM commands for the bot: dm, reply, and followup.

In order to reply to the last DM, I needed to use SQLITE. I made and required a database.js file to do that, using the discord.js guide for SQLite. But when I run the command dm, the table isn’t even created!

My code editor does in fact show the files database.js and database.sqlite.

I have also tried using node database.js.

In Discord, I get the messages from my alt and my main account, but it replies to my interaction with “Error! Either you or the recipient have disabled DMs!” This is actually my message that gets sent with a catch.

What could be the problem here?

P.S. If you prefer viewing the code right here on StackOverflow, here it is:


const { SlashCommandBuilder } = require("@discordjs/builders")
const { DirectMessages } = require("../database")

module.exports = {
    data: new SlashCommandBuilder()
        .setDescription("Directly messages a user!")
        .addUserOption(option =>
                .setDescription("The user to message"))
        .addStringOption(option =>
                .setDescription("The message to send")),
    async execute(interaction) {
        const user = interaction.options.getUser("user")
        const message = interaction.options.getString("message")

        try {
            await user.send(`**${interaction.user.tag} sent a message:** ${message}`)
            await interaction.user.send(`**Sent ${user.tag} a message:** ${message}`)
            await DirectMessages.create({
            interaction.reply({ content: "Successfully sent your message!", ephemeral: true })
        catch (error) {
            interaction.reply({ content: "Error! Either the recipient or yourself has disabled DMs!", ephemeral: true })


const Sequelize = require("sequelize")

const sequelize = new Sequelize("database", "user", "password", {
    host: "localhost",
    dialect: "sqlite",
    logging: false,
    // SQLite only
    storage: "database.sqlite",

const DirectMessages = sequelize.define("dms", {
    message: Sequelize.TEXT,
    from: Sequelize.STRING,
    to: Sequelize.STRING,

module.exports = {

Error: SQLITE_ERROR: no such table: dms


await sequelize.sync({ force: true });
console.log("All models were synchronized successfully.");

you should check Sequelize Synchronizing all model