mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 16:30:58 -05:00
Remove migrations as MongoDB is no longer used
This commit is contained in:
parent
1011c39642
commit
da89a71128
@ -7,7 +7,6 @@ import {Model, DataTypes} from 'sequelize';
|
|||||||
import CacheServer from '../components/CacheServer.js';
|
import CacheServer from '../components/CacheServer.js';
|
||||||
import MessageTool from '../helpers/MessageTool.js';
|
import MessageTool from '../helpers/MessageTool.js';
|
||||||
import Formatters from '../helpers/Formatters.js';
|
import Formatters from '../helpers/Formatters.js';
|
||||||
import {readFileSync, existsSync} from 'node:fs';
|
|
||||||
|
|
||||||
class punishments extends Model {
|
class punishments extends Model {
|
||||||
declare public case_id: number;
|
declare public case_id: number;
|
||||||
@ -79,23 +78,6 @@ export class PunishmentsSvc {
|
|||||||
});
|
});
|
||||||
this.model.sync();
|
this.model.sync();
|
||||||
}
|
}
|
||||||
async migrate() {
|
|
||||||
let file:string = 'src/punishments.json';
|
|
||||||
if (!existsSync(file)) return Error(`File not found, have you tried checking if it exists? (${file})`);
|
|
||||||
|
|
||||||
await this.model.bulkCreate(JSON.parse(readFileSync(file, 'utf8')).map(x=>({
|
|
||||||
case_id: x._id,
|
|
||||||
type: x.type,
|
|
||||||
member: x.member,
|
|
||||||
moderator: x.moderator,
|
|
||||||
expired: x.expired,
|
|
||||||
time: x.time ? Number(x.time.$numberLong) : undefined,
|
|
||||||
reason: x.reason,
|
|
||||||
endTime: x.endTime ? Number(x.endTime.$numberLong) : undefined,
|
|
||||||
cancels: x.cancels,
|
|
||||||
duration: x.duration ? (typeof x.duration === 'object' ? Number(x.duration.$numberLong) : x.duration) : undefined
|
|
||||||
})));
|
|
||||||
}
|
|
||||||
async updateReason(caseId:number, reason:string) {
|
async updateReason(caseId:number, reason:string) {
|
||||||
const findCase = this.findCase(caseId);
|
const findCase = this.findCase(caseId);
|
||||||
if (findCase) return this.model.update({reason: reason}, {where: {case_id: caseId}});
|
if (findCase) return this.model.update({reason: reason}, {where: {case_id: caseId}});
|
||||||
|
@ -3,7 +3,6 @@ import MessageTool from '../helpers/MessageTool.js';
|
|||||||
import CacheServer from '../components/CacheServer.js';
|
import CacheServer from '../components/CacheServer.js';
|
||||||
import DatabaseServer from '../components/DatabaseServer.js';
|
import DatabaseServer from '../components/DatabaseServer.js';
|
||||||
import {Model, DataTypes} from 'sequelize';
|
import {Model, DataTypes} from 'sequelize';
|
||||||
import {readFileSync, existsSync} from 'node:fs';
|
|
||||||
import {ChatInputCommandInteraction, Snowflake} from 'discord.js';
|
import {ChatInputCommandInteraction, Snowflake} from 'discord.js';
|
||||||
|
|
||||||
class tagsystem extends Model {
|
class tagsystem extends Model {
|
||||||
@ -51,17 +50,6 @@ export class TagSystemSvc {
|
|||||||
});
|
});
|
||||||
this.model.sync();
|
this.model.sync();
|
||||||
}
|
}
|
||||||
async migrate() {
|
|
||||||
let file:string = 'src/tags.json';
|
|
||||||
if (!existsSync(file)) return Error(`File not found, have you tried checking if it exists? (${file})`);
|
|
||||||
|
|
||||||
await this.model.bulkCreate(JSON.parse(readFileSync(file, 'utf8')).map(x=>({
|
|
||||||
tagname: x._id,
|
|
||||||
message: x.message,
|
|
||||||
embedFlag: x.embedBool,
|
|
||||||
userid: x.user._id
|
|
||||||
})));
|
|
||||||
}
|
|
||||||
async createTag(userid:string, tagName:string, message:string, embedFlag:boolean) {
|
async createTag(userid:string, tagName:string, message:string, embedFlag:boolean) {
|
||||||
CacheServer.delete('tags');
|
CacheServer.delete('tags');
|
||||||
return await this.model.create({userid: userid, tagname: tagName, message: message.replace(/\\n/g, '\n'), embedFlag: embedFlag});
|
return await this.model.create({userid: userid, tagname: tagName, message: message.replace(/\\n/g, '\n'), embedFlag: embedFlag});
|
||||||
|
@ -3,7 +3,7 @@ import TClient from '../client.js';
|
|||||||
import MessageTool from '../helpers/MessageTool.js';
|
import MessageTool from '../helpers/MessageTool.js';
|
||||||
import DatabaseServer from '../components/DatabaseServer.js';
|
import DatabaseServer from '../components/DatabaseServer.js';
|
||||||
import {Model, DataTypes} from 'sequelize';
|
import {Model, DataTypes} from 'sequelize';
|
||||||
import {writeFileSync, readFileSync, existsSync} from 'node:fs';
|
import {writeFileSync} from 'node:fs';
|
||||||
import cron from 'node-cron';
|
import cron from 'node-cron';
|
||||||
import Logger from '../helpers/Logger.js';
|
import Logger from '../helpers/Logger.js';
|
||||||
|
|
||||||
@ -108,17 +108,5 @@ export class UserLevelsSvc {
|
|||||||
}
|
}
|
||||||
algorithm = (level:number)=>level*level*15;
|
algorithm = (level:number)=>level*level*15;
|
||||||
// Algorithm for determining levels. If adjusting, recommended to only change the integer at the end of equation.
|
// Algorithm for determining levels. If adjusting, recommended to only change the integer at the end of equation.
|
||||||
|
// Requires rank data to be reset if changed as it causes unexpected results.
|
||||||
// Deadge on 1.6k users in database...
|
|
||||||
async migrate() {
|
|
||||||
let file:string = 'src/userLevels.json';
|
|
||||||
if (!existsSync(file)) return Error(`File not found, have you tried checking if it exists? (${file})`);
|
|
||||||
|
|
||||||
await this.model.bulkCreate(JSON.parse(readFileSync(file, 'utf8')).map(x=>({
|
|
||||||
id: x._id,
|
|
||||||
messages: x.messages,
|
|
||||||
level: x.level,
|
|
||||||
pingToggle: x.notificationPing
|
|
||||||
})));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user