mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-11-17 17:23:08 +02:00
feat: upgrade script
This commit is contained in:
parent
95f76716ed
commit
dc0ac88fa7
2
.gitignore
vendored
2
.gitignore
vendored
@ -6,7 +6,7 @@ site/
|
|||||||
|
|
||||||
# files
|
# files
|
||||||
.env
|
.env
|
||||||
sskey.env
|
version
|
||||||
user/config.js
|
user/config.js
|
||||||
user/database.sqlite
|
user/database.sqlite
|
||||||
user/plugins/*/
|
user/plugins/*/
|
@ -160,7 +160,8 @@ class Bot extends Client {
|
|||||||
|
|
||||||
this.setMaxListeners(this.config.max_listeners); // set the max listeners for each event
|
this.setMaxListeners(this.config.max_listeners); // set the max listeners for each event
|
||||||
|
|
||||||
require('./updater')(this); // check for updates
|
require('./update/notifier')(this); // check for updates
|
||||||
|
require('./update/upgrade')(this); // upgrade
|
||||||
|
|
||||||
const listeners = new ListenerLoader(this);
|
const listeners = new ListenerLoader(this);
|
||||||
listeners.load(); // load listeners
|
listeners.load(); // load listeners
|
||||||
|
@ -5,7 +5,7 @@ const link = require('terminal-link');
|
|||||||
const semver = require('semver');
|
const semver = require('semver');
|
||||||
const { format } = require('leekslazylogger');
|
const { format } = require('leekslazylogger');
|
||||||
|
|
||||||
const { version: current } = require('../package.json');
|
const { version: current } = require('../../package.json');
|
||||||
|
|
||||||
module.exports = async client => {
|
module.exports = async client => {
|
||||||
if (!client.config.update_notice) return;
|
if (!client.config.update_notice) return;
|
29
src/update/upgrade.js
Normal file
29
src/update/upgrade.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const { path } = require('../utils/fs');
|
||||||
|
const FILE = path('./version');
|
||||||
|
const { version: current } = require('../../package.json');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {import('../..').Bot} client
|
||||||
|
*/
|
||||||
|
module.exports = async client => {
|
||||||
|
if (!fs.existsSync(FILE)) {
|
||||||
|
return fs.writeFileSync(FILE, current);
|
||||||
|
} else {
|
||||||
|
const previous = fs.readFileSync(FILE, { encoding: 'utf8' });
|
||||||
|
if (previous !== current) {
|
||||||
|
client.log.info('Running upgrade task');
|
||||||
|
client.log.info('Writing version');
|
||||||
|
fs.writeFileSync(FILE, current);
|
||||||
|
|
||||||
|
const guilds = await client.db.models.Guild.findAll();
|
||||||
|
guilds.forEach(async guild => {
|
||||||
|
guild.set('blacklist', {
|
||||||
|
members: [],
|
||||||
|
roles: []
|
||||||
|
});
|
||||||
|
await guild.save();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user