Skip to content
This repository was archived by the owner on Dec 22, 2024. It is now read-only.

Commit af1f76f

Browse files
committed
Added database-related code
1 parent b0be9c0 commit af1f76f

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
.env
3+
database.sqlite
34
commands/experimental

database-models.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const Sequelize = require('sequelize');
2+
3+
const sequelize = new Sequelize('database', 'user', 'password', {
4+
dialect: 'sqlite',
5+
logging: false,
6+
storage: 'database.sqlite',
7+
});
8+
9+
const SubmissionsTable = sequelize.define('SubmissionsTable', {
10+
storedSubmissionId: {
11+
type: Sequelize.INTEGER,
12+
primaryKey: true,
13+
unique: true,
14+
},
15+
storedApplicantId: Sequelize.STRING,
16+
storedSubmissionLink: Sequelize.STRING,
17+
});
18+
19+
const ControllerStatsTable = sequelize.define('ControllerStatsTable', {
20+
storedControllerId: {
21+
type: Sequelize.STRING,
22+
primaryKey: true,
23+
unique: true,
24+
},
25+
storedControllerCount: {
26+
type: Sequelize.INTEGER,
27+
defaultValue: 0,
28+
allowNull: false,
29+
},
30+
storedControllerName: Sequelize.STRING,
31+
});
32+
33+
module.exports = {
34+
SubmissionsTable,
35+
ControllerStatsTable,
36+
};

events/ready.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
const { Events } = require('discord.js');
2+
const { SubmissionsTable, ControllerStatsTable } = require('../database-models');
23

34
module.exports = {
45
name: Events.ClientReady,
56
once: true,
67
execute(client) {
8+
SubmissionsTable.sync();
9+
ControllerStatsTable.sync();
710
console.log(`[INFO] Bot ready! Logged in as ${client.user.tag}`);
811
}
912
};

0 commit comments

Comments
 (0)