/[sudobot]/trunk/src/models/Punishment.ts
ViewVC logotype

Diff of /trunk/src/models/Punishment.ts

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 86 by rakin, Mon Jul 29 17:28:32 2024 UTC revision 428 by rakin, Mon Jul 29 17:30:11 2024 UTC
# Line 1  Line 1 
1  import { DataTypes, Model } from 'sequelize';  /**
2  import DiscordClient from '../client/Client';  * This file is part of SudoBot.
3    *
4    * Copyright (C) 2021-2022 OSN Inc.
5    *
6    * SudoBot is free software; you can redistribute it and/or modify it
7    * under the terms of the GNU Affero General Public License as published by
8    * the Free Software Foundation, either version 3 of the License, or
9    * (at your option) any later version.
10    *
11    * SudoBot is distributed in the hope that it will be useful, but
12    * WITHOUT ANY WARRANTY; without even the implied warranty of
13    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14    * GNU Affero General Public License for more details.
15    *
16    * You should have received a copy of the GNU Affero General Public License
17    * along with SudoBot. If not, see <https://www.gnu.org/licenses/>.
18    */
19    
20  class Punishment extends Model {}  import { Schema, model } from 'mongoose';
21    
22  Punishment.init({  export interface IPunishment {
23      id: {      user_id: string
24          type: DataTypes.INTEGER,      mod_id: string
25          primaryKey: true,      mod_tag: string,
26          autoIncrement: true,      guild_id: string;
27          allowNull: false,      reason?: string;
28      },      type: string
29        meta?: object;
30        createdAt: Date;
31    }
32    
33    const schema = new Schema({
34      user_id: {      user_id: {
35          type: DataTypes.STRING,          type: String,
36          allowNull: false,          required: true,
37      },      },
38      mod_id: {      mod_id: {
39          type: DataTypes.STRING,          type: String,
40          allowNull: false,          required: true,
41      },      },
42      mod_tag: {      mod_tag: {
43          type: DataTypes.STRING,          type: String,
44          allowNull: false,          required: true,
45      },      },
46      guild_id: {      guild_id: {
47          type: DataTypes.STRING,          type: String,
48          allowNull: false,          required: true,
49      },      },
50      reason: {      reason: {
51          type: DataTypes.TEXT,          type: String,
52          allowNull: true          required: false
53      },      },
54      type: {      type: {
55          type: DataTypes.STRING,          type: String,
56          allowNull: false          required: true
57      },      },
58      meta: {      meta: {
59          type: DataTypes.JSON,          type: Object,
60          allowNull: false,          required: true,
61          defaultValue: {}          default: {}
62      },      },
63  }, {      createdAt: {
64      sequelize: DiscordClient.client.db.sequelize,          type: Date,
65      modelName: 'Punishment',          required: true,
66      updatedAt: false,          default: () => new Date()
67      tableName: 'punishments'      }
68  });  });
69    
 export default Punishment;  
70    // class Punishment extends Model {}
71    
72    // Punishment.init({
73    //     id: {
74    //         type: DataTypes.INTEGER,
75    //         primaryKey: true,
76    //         autoIncrement: true,
77    //         allowNull: false,
78    //     },
79    //     user_id: {
80    //         type: DataTypes.STRING,
81    //         allowNull: false,
82    //     },
83    //     mod_id: {
84    //         type: DataTypes.STRING,
85    //         allowNull: false,
86    //     },
87    //     mod_tag: {
88    //         type: DataTypes.STRING,
89    //         allowNull: false,
90    //     },
91    //     guild_id: {
92    //         type: DataTypes.STRING,
93    //         allowNull: false,
94    //     },
95    //     reason: {
96    //         type: DataTypes.TEXT,
97    //         allowNull: true
98    //     },
99    //     type: {
100    //         type: DataTypes.STRING,
101    //         allowNull: false
102    //     },
103    //     meta: {
104    //         type: DataTypes.JSON,
105    //         allowNull: false,
106    //         defaultValue: {}
107    //     },
108    // }, {
109    //     sequelize: DiscordClient.client.db.sequelize,
110    //     modelName: 'Punishment',
111    //     updatedAt: false,
112    //     tableName: 'punishments'
113    // });
114    
115    export default model('Punishment', schema);

Legend:
Removed from v.86  
changed lines
  Added in v.428

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26