diff options
| author | Andrew Lee <andrew@alee14.me> | 2025-03-03 11:42:27 -0500 |
|---|---|---|
| committer | Andrew Lee <andrew@alee14.me> | 2025-03-03 11:42:27 -0500 |
| commit | fd7f8eba960981482fabf350995bf753feebb176 (patch) | |
| tree | 2bd0c85b09a04ecd8e1f20fc409eb4b8a22289a7 | |
| parent | cf1382d88c5e3298923c8cb243b7bc5751e68b53 (diff) | |
| download | AleeBot-fd7f8eba960981482fabf350995bf753feebb176.tar.gz AleeBot-fd7f8eba960981482fabf350995bf753feebb176.tar.bz2 AleeBot-fd7f8eba960981482fabf350995bf753feebb176.zip | |
More commands ported; Almost all 2.x features have been added
| -rw-r--r-- | bot/.gitignore | 1 | ||||
| -rw-r--r-- | bot/bun.lockb | bin | 69331 -> 116354 bytes | |||
| -rw-r--r-- | bot/deploy-command.js | 2 | ||||
| -rw-r--r-- | bot/package.json | 6 | ||||
| -rw-r--r-- | bot/src/api/routes/quotes.js | 70 | ||||
| -rw-r--r-- | bot/src/api/server.js | 4 | ||||
| -rw-r--r-- | bot/src/bot.js | 31 | ||||
| -rw-r--r-- | bot/src/commands/ask.js | 2 | ||||
| -rw-r--r-- | bot/src/commands/attack.js | 17 | ||||
| -rw-r--r-- | bot/src/commands/info.js | 4 | ||||
| -rw-r--r-- | bot/src/commands/quote.js | 35 | ||||
| -rw-r--r-- | bot/src/commands/rm.js | 21 | ||||
| -rw-r--r-- | bot/src/commands/serverinfo.js | 31 | ||||
| -rw-r--r-- | bot/src/commands/userinfo.js | 2 | ||||
| -rw-r--r-- | bot/src/events/ClientReady.js | 24 | ||||
| -rw-r--r-- | bot/src/events/GuildCreate.js | 30 | ||||
| -rw-r--r-- | bot/src/events/GuildDelete.js | 28 | ||||
| -rw-r--r-- | bot/src/models/guild-settings.js | 27 | ||||
| -rw-r--r-- | bot/src/models/quote.js | 64 | ||||
| -rw-r--r-- | bot/src/storage/activities.js | 13 | ||||
| -rw-r--r-- | bot/src/storage/consts.js | 2 | ||||
| -rw-r--r-- | bot/src/utils/sequelize.js | 8 | ||||
| -rw-r--r-- | bot/src/utils/sync.js | 17 |
23 files changed, 383 insertions, 56 deletions
diff --git a/bot/.gitignore b/bot/.gitignore index 37d13a0..3a41eb2 100644 --- a/bot/.gitignore +++ b/bot/.gitignore @@ -135,3 +135,4 @@ dist .yarn/install-state.gz .pnp.* +database.db diff --git a/bot/bun.lockb b/bot/bun.lockb Binary files differindex 27f2b53..c9cc9bb 100644 --- a/bot/bun.lockb +++ b/bot/bun.lockb diff --git a/bot/deploy-command.js b/bot/deploy-command.js index 8aa3b68..b2403a1 100644 --- a/bot/deploy-command.js +++ b/bot/deploy-command.js @@ -10,7 +10,7 @@ for (const file of commandFiles) { commands.push(command.data.toJSON()); } -const rest = new REST().setToken(process.env.abbtoken); +const rest = new REST().setToken(process.env.token); // and deploy your commands! (async() => { diff --git a/bot/package.json b/bot/package.json index 1adf119..148a229 100644 --- a/bot/package.json +++ b/bot/package.json @@ -6,13 +6,15 @@ "author": "Andrew Lee", "license": "GPL-3.0", "scripts": { - "start": "node src/bot.js --beta", + "start": "node src/bot.js", "lint": "eslint ." }, "dependencies": { "cors": "^2.8.5", "discord.js": "^14.18.0", - "express": "^4.21.2" + "express": "^4.21.2", + "sequelize": "^6.37.5", + "sqlite3": "^5.1.7" }, "devDependencies": { "@eslint/js": "^9.21.0", diff --git a/bot/src/api/routes/quotes.js b/bot/src/api/routes/quotes.js new file mode 100644 index 0000000..d39bb28 --- /dev/null +++ b/bot/src/api/routes/quotes.js @@ -0,0 +1,70 @@ +import { Router } from 'express'; +import { pendingQuote, quote as newQuote } from '../../models/quote.js'; + +export const quoteRouter = Router(); + +quoteRouter.get('/quotes/pending', async (req, res) => { + try { + const quotes = await pendingQuote.findAll(); + res.json(quotes); + } catch (error) { + console.error('Error fetching quotes:', error); + res.status(500).send('Internal Server Error'); + } +}); + +quoteRouter.post('/quotes/add', async (req, res) => { + const { author, authorImage, quote, year, submitterID } = req.body; + try { + await newQuote.create({ + author: author, + authorImage: authorImage, + quote: quote, + year: year, + submitter: submitterID + }); + res.status(200).send('Added a new quote'); + } catch (error) { + console.error('Something went wrong:', error); + res.status(500).send('Internal Server Error'); + } +}); + +quoteRouter.post('/quotes/approve', async (req, res) => { + const { id } = req.body; + try { + const quote = await pendingQuote.findByPk(id); + if (quote) { + await newQuote.create({ + author: quote.author, + authorImage: quote.authorImage, + quote: quote.quote, + year: quote.year, + submitter: quote.submitterID + }); + await pendingQuote.destroy({ where: { id } }); + res.status(200).send('Quote approved'); + } else { + res.status(404).send('Quote not found'); + } + } catch (error) { + console.error('Error approving quote:', error); + res.status(500).send('Internal Server Error'); + } +}); + +quoteRouter.post('/quotes/reject', async (req, res) => { + const { id } = req.body; + try { + const quote = await pendingQuote.findByPk(id); + if (quote) { + await pendingQuote.destroy({ where: { id } }); + res.status(200).send('Quote rejected'); + } else { + res.status(404).send('Quote not found'); + } + } catch (error) { + console.error('Error rejecting quote:', error); + res.status(500).send('Internal Server Error'); + } +}); diff --git a/bot/src/api/server.js b/bot/src/api/server.js index ac4f8ca..0b0397e 100644 --- a/bot/src/api/server.js +++ b/bot/src/api/server.js @@ -4,12 +4,16 @@ import cors from 'cors'; import 'dotenv/config'; import { readFileSync } from 'node:fs'; +import { quoteRouter } from './routes/quotes.js'; + const app = express(); export const apiServer = (client) => { app.use(cors()); // Allow cross-origin requests app.use(express.json()); + app.use('/api', quoteRouter); + app.get('/api/version', (req, res) => { const { version } = JSON.parse(readFileSync('./package.json', 'utf-8')); res.json({ diff --git a/bot/src/bot.js b/bot/src/bot.js index 7f1f41a..95871e0 100644 --- a/bot/src/bot.js +++ b/bot/src/bot.js @@ -3,21 +3,22 @@ import 'dotenv/config'; import { event } from './handlers/event.js'; import { command } from './handlers/command.js'; import { apiServer } from './api/server.js'; +import { syncDB } from './utils/sync.js'; +//import { deployCommands } from './util/deploy.js'; -const client = new Client({ intents: [GatewayIntentBits.Guilds] }); +const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers] }); -command(client).then(() => console.log('[>] Command module loaded')); -event(client).then(() => console.log('[>] Event module loaded')); -apiServer(client); - -if (process.argv.indexOf('--beta') === -1) { - client.login(process.env.abtoken).catch(function() { - console.log('[X] Login failed. The token that you have put in is invalid.'); - process.exit(0); - }); -} else { - client.login(process.env.abbtoken).catch(function() { - console.log('[X] Login failed. The token that you have put in is invalid.'); - process.exit(0); - }); +async function init(client) { + await syncDB(); + //deployCommands().then(() => console.log('[>] Deployed commands')); + await apiServer(client); + await event(client).then(() => console.log('[>] Event module loaded')); + await command(client).then(() => console.log('[>] Command module loaded')); } + +init(client); + +client.login(process.env.token).catch(function() { + console.log('[X] Login failed. The token that you have put in is invalid.'); + process.exit(1); +}); diff --git a/bot/src/commands/ask.js b/bot/src/commands/ask.js index fec0846..4193e92 100644 --- a/bot/src/commands/ask.js +++ b/bot/src/commands/ask.js @@ -27,7 +27,7 @@ export default { ]; return await interaction.reply( - `<@${interaction.user.id}> asked:\n**${question}**\nMy answer:\n**${answers[Math.floor(Math.random() * answers.length)]}**` + `**${interaction.user.displayName}** asked:\n**${question}**\nMy answer:\n**${answers[Math.floor(Math.random() * answers.length)]}**` ); } }; diff --git a/bot/src/commands/attack.js b/bot/src/commands/attack.js new file mode 100644 index 0000000..2863e5a --- /dev/null +++ b/bot/src/commands/attack.js @@ -0,0 +1,17 @@ +import { SlashCommandBuilder } from 'discord.js'; + +export default { + data: new SlashCommandBuilder() + .setName('attack') + .setDescription('You don\'t like someone? Attack them!') + .addStringOption(option => + option + .setName('target') + .setDescription('Enter the target you want to attack.') + .setRequired(true)), + async execute(interaction) { + const target = interaction.options.getString('target'); + + return await interaction.reply(`${interaction.user.displayName} :right_facing_fist: ${target}`); + } +}; diff --git a/bot/src/commands/info.js b/bot/src/commands/info.js index 64d8f7a..33e1665 100644 --- a/bot/src/commands/info.js +++ b/bot/src/commands/info.js @@ -7,7 +7,7 @@ export default { .setName('info') .setDescription('Shows information about the host.'), async execute(interaction) { - const embed = new EmbedBuilder() + const hostEmbed = new EmbedBuilder() .setTitle('Information on AleeBot\'s Host') .addFields( { name: 'OS Hostname: ', value: hostname(), inline: true }, @@ -17,6 +17,6 @@ export default { { name: 'OS Version: ', value: release(), inline: true } ) .setColor(abEmbedColour); - return await interaction.reply({ embeds: [embed] }); + return await interaction.reply({ embeds: [hostEmbed] }); } }; diff --git a/bot/src/commands/quote.js b/bot/src/commands/quote.js new file mode 100644 index 0000000..eaac975 --- /dev/null +++ b/bot/src/commands/quote.js @@ -0,0 +1,35 @@ +import { SlashCommandBuilder, EmbedBuilder } from 'discord.js'; +import { quote as quoteDB } from '../models/quote.js'; +export default { + data: new SlashCommandBuilder() + .setName('quote') + .setDescription('It gives you a quote.') + .addNumberOption(option => + option + .setName('id') + .setDescription('Enter the quote ID to get a specific quote.')), + async execute(interaction) { + let quoteID = interaction.options.getNumber('id'); + + if (!quoteID) { + const quoteList = await quoteDB.findAll({ attributes: ['id'] }); + const random = crypto.getRandomValues(new Uint32Array(1)); + quoteID = quoteList[random[0] % quoteList.length].id; + } + + const quote = await quoteDB.findOne({ where: { id: quoteID } }); + + if (quote) { + let userSubmitter = await interaction.client.users.fetch(quote.submitter); + const quoteEmbed = new EmbedBuilder() + .setAuthor({ name: quote.author, iconURL: quote.authorImage }) + .setDescription(quote.quote) + .setColor('#1fd619') + .setFooter({ text: `- ${quote.year}\nSubmitted by ${userSubmitter.username}` }); + + return await interaction.reply({ embeds: [quoteEmbed] }); + } else { + return await interaction.reply('Cannot find quote, specify the correct quote id.'); + } + } +}; diff --git a/bot/src/commands/rm.js b/bot/src/commands/rm.js new file mode 100644 index 0000000..ec6f647 --- /dev/null +++ b/bot/src/commands/rm.js @@ -0,0 +1,21 @@ +import { SlashCommandBuilder, PermissionFlagsBits } from 'discord.js'; + +export default { + data: new SlashCommandBuilder() + .setName('rm') + .setDescription('Purges messages.') + .addNumberOption(option => + option + .setName('amount') + .setDescription('Enter the amount of messages you want to delete.') + .setRequired(true)) + .setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages), + async execute(interaction) { + const amount = interaction.options.getNumber('amount'); + + if (amount > 100) return interaction.reply('Put a number less than 100.'); + + return await interaction.channel.bulkDelete(amount) + .then( (messages) => interaction.reply(`Deleted ${messages.size} messages.`)); + } +}; diff --git a/bot/src/commands/serverinfo.js b/bot/src/commands/serverinfo.js new file mode 100644 index 0000000..01b39e8 --- /dev/null +++ b/bot/src/commands/serverinfo.js @@ -0,0 +1,31 @@ +import { SlashCommandBuilder, EmbedBuilder } from 'discord.js'; +import { abEmbedColour } from '../storage/consts.js'; + +export default { + data: new SlashCommandBuilder() + .setName('serverinfo') + .setDescription('Information about this server.'), + async execute(interaction) { + // const listedChannels = []; + let guildOwner = await interaction.guild.fetchOwner(); + let memberCountNoBots = await interaction.guild.members.fetch().then((members) => members.filter(member => !member.user.bot).size); + + const serverEmbed = new EmbedBuilder() + .setAuthor({ name: `${interaction.guild.name}`, iconURL: interaction.guild.iconURL() }) + .setDescription('Server Information') + .setThumbnail(interaction.guild.iconURL()) + .addFields( + { name: 'Main Information', value: `**Server Name:** ${interaction.guild.name}\n**Server ID:** ${interaction.guild.id}\n**Server Owner:** ${guildOwner.user.tag}`}, + { name: 'Join Dates', value: `**Created At:** ${interaction.guild.createdAt.toUTCString()}\n**AleeBot Joined:** ${interaction.guild.joinedAt.toUTCString()}`}, + { name: 'Total Members (with bots)', value: `${interaction.guild.memberCount}` }, + { name: 'Total Members (without bots)', value: `${memberCountNoBots}` } + ) + /*message.guild.channels.cacheType.forEach(channel => { + listedChannels.push(channel) + })*/ + //.addField('Channels', `${listedChannels.join('\n')}`) + //.addField('Total Channels', message.guild.channelCountMode) + .setColor(abEmbedColour); + return await interaction.reply({ embeds: [serverEmbed] }); + } +}; diff --git a/bot/src/commands/userinfo.js b/bot/src/commands/userinfo.js index 01b7577..b51ef0a 100644 --- a/bot/src/commands/userinfo.js +++ b/bot/src/commands/userinfo.js @@ -16,6 +16,6 @@ export default { { name: 'Create and Join Times', value: `**Created At:** ${interaction.member.user.createdAt.toUTCString()}\n**Joined Guild At:** ${interaction.member.joinedAt.toUTCString()}`} ) .setColor(abEmbedColour); - return await interaction.reply({embeds: [userEmbed]}); + return await interaction.reply({ embeds: [userEmbed] }); } }; diff --git a/bot/src/events/ClientReady.js b/bot/src/events/ClientReady.js index 335a2ac..def2c88 100644 --- a/bot/src/events/ClientReady.js +++ b/bot/src/events/ClientReady.js @@ -1,8 +1,9 @@ -import { Events } from 'discord.js'; +import { EmbedBuilder, Events, version } from 'discord.js'; import { readFileSync } from 'node:fs'; import { activities } from '../storage/activities.js'; -const { version } = JSON.parse(readFileSync('./package.json', 'utf-8')); +import { readyMsg, abEmbedColour } from '../storage/consts.js'; +const { version: abVersion } = JSON.parse(readFileSync('./package.json', 'utf-8')); function botActivity(client) { const activity = activities[Math.floor(Math.random() * activities.length)]; @@ -25,10 +26,27 @@ export default { console.log('[>] AleeBot is now ready!'); console.log(`[i] Logged in as ${client.user.tag}`); console.log(`[i] Bot ID: ${client.user.id}`); - console.log(`[i] Running version ${version} | Serving in ${client.guilds.cache.size} guilds`); + console.log(`[i] Running version ${abVersion} | Serving in ${client.guilds.cache.size} guilds`); botActivity(client); + if (readyMsg) { + const readyEmbed = new EmbedBuilder() + .setAuthor({ name: 'AleeBot Status', iconURL: client.user.avatarURL() }) + .setDescription('AleeBot has started') + .addFields( + { name: 'Version', value: `${abVersion}`, inline: true }, + { name: 'Node.JS Version', value: `${process.versions.node}`, inline: true }, + { name: 'Discord.JS Version', value: `${version}`, inline: true } + ) + .setColor(abEmbedColour); + + + let statusChannel = client.channels.cache.get(process.env.statusChannelID); + if (!statusChannel) return console.error('The status channel does not exist! Skipping.'); + statusChannel.send({ embeds: [readyEmbed]}); + } + setInterval(function() { botActivity(client); }, 200000); diff --git a/bot/src/events/GuildCreate.js b/bot/src/events/GuildCreate.js index f31be46..565d8f2 100644 --- a/bot/src/events/GuildCreate.js +++ b/bot/src/events/GuildCreate.js @@ -1,20 +1,24 @@ -import { Events } from 'discord.js'; +import { EmbedBuilder, Events } from 'discord.js'; +import { abEmbedColour } from '../storage/consts.js'; export default { name: Events.GuildCreate, async execute(guild) { console.log(`[i] New guild joined: ${guild.name} (${guild.id}). This guild has ${guild.memberCount} members!`); - // const logEmbed = new Discord.MessageEmbed() - // .setAuthor('AleeBot', client.user.avatarURL()) - // .setDescription('I got added to a server!') - // .addField('Server Name:', `${guild.name}`, true) - // .addField('Server ID:', `${guild.id}`, true) - // .addField('Members', `${guild.memberCount}`, true) - // .setColor('#5cd65c') - // .setFooter(`We now run on ${client.guilds.cache.size} guilds.`); - // - // let statusChannel = client.channels.cache.get(statusChannelID); - // if (!statusChannel) return; - // statusChannel.send({ embeds: [logEmbed]}); + const logEmbed = new EmbedBuilder() + .setAuthor({ name: 'AleeBot', iconURL: guild.client.user.avatarURL() }) + .setDescription('I got added to a server!') + .addFields( + { name: 'Server Name:', value: `${guild.name}`, inline: true }, + { name: 'Server ID:', value: `${guild.id}`, inline: true }, + { name: 'Members', value: `${guild.memberCount}`, inline: true } + ) + + .setColor(abEmbedColour) + .setFooter({ text: `We now run on ${guild.client.guilds.cache.size} guilds.` }); + + let statusChannel = guild.client.channels.cache.get(process.env.statusChannelID); + if (!statusChannel) return; + statusChannel.send({ embeds: [logEmbed]}); } }; diff --git a/bot/src/events/GuildDelete.js b/bot/src/events/GuildDelete.js index a684632..50c4412 100644 --- a/bot/src/events/GuildDelete.js +++ b/bot/src/events/GuildDelete.js @@ -1,19 +1,23 @@ -import { Events } from 'discord.js'; +import { EmbedBuilder, Events } from 'discord.js'; +import { abEmbedColour } from '../storage/consts.js'; export default { name: Events.GuildDelete, async execute(guild) { console.log(`[i] I have been removed from: ${guild.name} (${guild.id})`); - // const logEmbed = new Discord.MessageEmbed() - // .setAuthor('AleeBot', client.user.avatarURL()) - // .setDescription('I got removed from a server...') - // .addField('Server Name:', `${guild.name}`, true) - // .addField('Server ID:', `${guild.id}`, true) - // .setColor('#ff021b') - // .setFooter(`We now run on ${client.guilds.cache.size} guilds.`); - // - // let statusChannel = client.channels.cache.get(statusChannelID); - // if (!statusChannel) return; - // statusChannel.send({ embeds: [logEmbed]}); + const logEmbed = new EmbedBuilder() + .setAuthor({ name: 'AleeBot', iconURL: guild.client.user.avatarURL() }) + .setDescription('I got removed from a server...') + .addFields( + { name: 'Server Name:', value: `${guild.name}`, inline: true }, + { name: 'Server ID:', value: `${guild.id}`, inline: true }, + ) + + .setColor(abEmbedColour) + .setFooter({ text: `We now run on ${guild.client.guilds.cache.size} guilds.` }); + + let statusChannel = guild.client.channels.cache.get(process.env.statusChannelID); + if (!statusChannel) return; + statusChannel.send({ embeds: [logEmbed]}); } }; diff --git a/bot/src/models/guild-settings.js b/bot/src/models/guild-settings.js new file mode 100644 index 0000000..81cfbc2 --- /dev/null +++ b/bot/src/models/guild-settings.js @@ -0,0 +1,27 @@ +import { INTEGER, STRING } from 'sequelize'; +import { sequelize } from '../utils/sequelize.js'; + +export const guildSettings = sequelize.define('guild-settings', { + id: { + type: INTEGER, + primaryKey: true, + autoIncrement: true, + }, + guildID: { + type: STRING, + allowNull: false + }, + logChannelID: { + type: STRING, + allowNull: true + } + // qotdChannelID: { + // type: Sequelize.STRING, + // allowNull: true + // }, + // qotdToggle: { + // type: Sequelize.BOOLEAN, + // allowNull: true + // } + +}); diff --git a/bot/src/models/quote.js b/bot/src/models/quote.js new file mode 100644 index 0000000..25c8f01 --- /dev/null +++ b/bot/src/models/quote.js @@ -0,0 +1,64 @@ +import { INTEGER, STRING, TEXT } from 'sequelize'; +import { sequelize } from '../utils/sequelize.js'; + +export const quote = sequelize.define('quotes', { + id: { + type: INTEGER, + autoIncrement: true, + primaryKey: true + }, + author: { + type: STRING, + allowNull: false + }, + authorImage: { + type: STRING, + allowNull: false + }, + quote: { + type: TEXT, + allowNull: false + }, + year: { + type: STRING, + allowNull: false + }, + submitter: { + type: STRING, + allowNull: false + } + +}) + +export const pendingQuote = sequelize.define('pending-quotes', { + id: { + type: INTEGER, + autoIncrement: true, + primaryKey: true + }, + author: { + type: STRING, + allowNull: false + }, + authorImage: { + type: STRING, + allowNull: false + }, + quote: { + type: TEXT, + allowNull: false + }, + year: { + type: STRING, + allowNull: false + }, + submitterAuthor: { + type: STRING, + allowNull: false + }, + submitterID: { + type: STRING, + allowNull: false + } + +}); diff --git a/bot/src/storage/activities.js b/bot/src/storage/activities.js index b50f2dd..ffdb468 100644 --- a/bot/src/storage/activities.js +++ b/bot/src/storage/activities.js @@ -59,12 +59,12 @@ const activities = [ { name: 'Pocket Gakusei', type: 0 }, { name: 'Hidden Heroes', type: 0 }, { name: 'Skybreakers', type: 0 }, - { name: 'Always Running', type: 0 }, - { name: 'Only Up', type: 0 }, - { name: 'Trade', type: 0 }, - { name: 'Breeze', type: 0 }, - { name: 'Steady', type: 0 }, - { name: 'Bluejay', type: 0 }, + { name: 'Always Running', type: 2 }, + { name: 'Only Up', type: 2 }, + { name: 'Trade', type: 2 }, + { name: 'Breeze', type: 2 }, + { name: 'Steady', type: 2 }, + { name: 'Bluejay', type: 2 }, { name: 'Exposing TAS-Corp', type: 4 }, { name: 'Fighting Evelyn Claythorne', type: 4 }, { name: 'Frying Dr. Sheridan', type: 4 }, @@ -95,6 +95,7 @@ const activities = [ { name: 'Linux, but actually GNU/Linux', type: 4 }, { name: 'Debloating my ThinkPad', type: 4 }, { name: 'Turbotastic!', type: 4 }, + { name: 'Artemis', type: 0 }, { name: `Now running on Discord.JS ${discordVersion}!`, type: 4 } ]; diff --git a/bot/src/storage/consts.js b/bot/src/storage/consts.js index 89f1b8a..12a53eb 100644 --- a/bot/src/storage/consts.js +++ b/bot/src/storage/consts.js @@ -1 +1,3 @@ export const abEmbedColour = '#0066a6'; +export const readyMsg = true; + diff --git a/bot/src/utils/sequelize.js b/bot/src/utils/sequelize.js new file mode 100644 index 0000000..c5c036e --- /dev/null +++ b/bot/src/utils/sequelize.js @@ -0,0 +1,8 @@ +import { Sequelize } from 'sequelize'; + +export const sequelize = new Sequelize('database', 'user', 'password', { + host: 'localhost', + dialect: 'sqlite', + logging: false, + storage: 'database.db', +}); diff --git a/bot/src/utils/sync.js b/bot/src/utils/sync.js new file mode 100644 index 0000000..ecee7b1 --- /dev/null +++ b/bot/src/utils/sync.js @@ -0,0 +1,17 @@ +import { quote, pendingQuote } from '../models/quote.js'; +import { guildSettings } from '../models/guild-settings.js'; + + +export function syncDB() { + quote.sync({alter: true}).then(() => { + console.log('Quote database synced!'); + }); + + pendingQuote.sync({alter: true}).then(() => { + console.log('Pending Quote database synced!'); + }); + + guildSettings.sync({alter: true}).then(() => { + console.log('Guild database synced!'); + }); +} |
