Refactor to more consistent structure (e.g. "plugins")
This commit is contained in:
72
plugins/nag/models.ts
Normal file
72
plugins/nag/models.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
import {
|
||||
BOOLEAN,
|
||||
DATE,
|
||||
INTEGER,
|
||||
Model,
|
||||
type Sequelize,
|
||||
STRING,
|
||||
} from 'sequelize';
|
||||
|
||||
export class Nag extends Model {
|
||||
// Primary key
|
||||
declare id: number;
|
||||
// User who created this nag
|
||||
declare userId: string;
|
||||
// Guild (server) of original nag request
|
||||
declare guildId: string;
|
||||
// Channel of original nag request
|
||||
declare channelId: string;
|
||||
// Message of original nag request
|
||||
declare messageId: string;
|
||||
// Description of what you're supposed to do
|
||||
declare text: string;
|
||||
// Custom failure text
|
||||
declare failText?: string;
|
||||
// Should we @here?
|
||||
declare mentionHere?: boolean;
|
||||
}
|
||||
|
||||
export class CheckIn extends Model {
|
||||
// Date of the last time user ran /checkin
|
||||
declare lastCheckIn: Date;
|
||||
}
|
||||
|
||||
export async function initializeModels(sequelize: Sequelize) {
|
||||
Nag.init(
|
||||
{
|
||||
id: {
|
||||
primaryKey: true,
|
||||
type: INTEGER,
|
||||
autoIncrement: true,
|
||||
},
|
||||
userId: {
|
||||
type: STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
text: {
|
||||
type: STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
failText: {
|
||||
type: STRING,
|
||||
},
|
||||
mentionHere: {
|
||||
type: BOOLEAN,
|
||||
},
|
||||
},
|
||||
{sequelize},
|
||||
);
|
||||
CheckIn.init(
|
||||
{
|
||||
lastCheckIn: {
|
||||
type: DATE,
|
||||
allowNull: false,
|
||||
},
|
||||
},
|
||||
{sequelize},
|
||||
);
|
||||
Nag.hasMany(CheckIn);
|
||||
CheckIn.belongsTo(Nag);
|
||||
await Nag.sync();
|
||||
await CheckIn.sync();
|
||||
}
|
||||
Reference in New Issue
Block a user