aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-09-06 21:31:29 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-09-06 21:31:29 -0400
commitbb061c938f4a967ed890f27c3ad56a63d6d6fec3 (patch)
tree10f808f2a7784235c5b19c0686f366128b6782c1
parentc9dbc3b7fa073889adf74a0ed47f1d5f0ad53362 (diff)
downloadtanzanite-bb061c938f4a967ed890f27c3ad56a63d6d6fec3.tar.gz
tanzanite-bb061c938f4a967ed890f27c3ad56a63d6d6fec3.tar.bz2
tanzanite-bb061c938f4a967ed890f27c3ad56a63d6d6fec3.zip
make stats persistant, fix automod logs, pm2 bs
-rw-r--r--ecosystem.config.js8
-rw-r--r--src/lib/extensions/discord-akairo/BushClient.ts4
-rw-r--r--src/lib/models/Stat.ts2
-rw-r--r--src/listeners/message/automodCreate.ts2
-rw-r--r--src/tasks/updateStats.ts22
-rw-r--r--src/tasks/updateSuperUsers.ts2
6 files changed, 32 insertions, 8 deletions
diff --git a/ecosystem.config.js b/ecosystem.config.js
index bcb74c7..d76aa26 100644
--- a/ecosystem.config.js
+++ b/ecosystem.config.js
@@ -1,7 +1,7 @@
module.exports = {
apps: [
{
- name: 'BushBot',
+ name: 'bush-bot',
script: 'yarn',
args: 'start',
out_file: '../bushbot.log',
@@ -15,7 +15,7 @@ module.exports = {
wait_ready: true
},
{
- name: 'BushBot-Beta',
+ name: 'bush-bot-beta',
script: 'yarn',
args: 'start',
out_file: '../bushbot-beta.log',
@@ -37,7 +37,7 @@ module.exports = {
'ref': 'origin/master',
'repo': 'https://github.com/NotEnoughUpdates/bush-bot.git',
'path': '/code/bush-bot',
- 'post-deploy': 'yarn install'
+ 'post-deploy': 'yarn install && yarn build && yarn start ecosystem.config.js --only bush-bot'
},
beta: {
'user': 'pi',
@@ -45,7 +45,7 @@ module.exports = {
'ref': 'origin/beta',
'repo': 'https://github.com/NotEnoughUpdates/bush-bot.git',
'path': '/code/bush-bot-beta',
- 'post-deploy': 'yarn install'
+ 'post-deploy': 'yarn install && yarn build && yarn start ecosystem.config.js --only bush-bot-beta'
}
}
};
diff --git a/src/lib/extensions/discord-akairo/BushClient.ts b/src/lib/extensions/discord-akairo/BushClient.ts
index d488525..a1966e2 100644
--- a/src/lib/extensions/discord-akairo/BushClient.ts
+++ b/src/lib/extensions/discord-akairo/BushClient.ts
@@ -32,6 +32,7 @@ import { permissionTypeCaster } from '../../../arguments/permission';
import { roleWithDurationTypeCaster } from '../../../arguments/roleWithDuation';
import { snowflakeTypeCaster } from '../../../arguments/snowflake';
import UpdateCacheTask from '../../../tasks/updateCache';
+import UpdateStatsTask from '../../../tasks/updateStats';
import { ActivePunishment } from '../../models/ActivePunishment';
import { Global } from '../../models/Global';
import { Guild as GuildModel } from '../../models/Guild';
@@ -285,7 +286,7 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re
this.util = new BushClientUtil(this);
this.db = new Sequelize({
- database: this.config.isDevelopment ? 'bushbot-dev' : 'bushbot',
+ database: this.config.isDevelopment ? 'bushbot-dev' : this.config.isBeta ? 'bushbot-beta' : 'bushbot',
username: this.config.db.username,
password: this.config.db.password,
dialect: 'postgres',
@@ -347,6 +348,7 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re
await this.dbPreInit();
await UpdateCacheTask.init(this);
void this.console.success('startup', `Successfully created <<cache>>.`, false);
+ this.stats.commandsUsed = await UpdateStatsTask.init();
this.taskHandler.startAll!();
}
diff --git a/src/lib/models/Stat.ts b/src/lib/models/Stat.ts
index 9391ad4..0059898 100644
--- a/src/lib/models/Stat.ts
+++ b/src/lib/models/Stat.ts
@@ -9,7 +9,7 @@ export interface StatModel {
export interface StatModelCreationAttributes {
environment: 'production' | 'development' | 'beta';
- commandsUsed: bigint;
+ commandsUsed?: bigint;
}
export class Stat extends BaseModel<StatModel, StatModelCreationAttributes> implements StatModel {
diff --git a/src/listeners/message/automodCreate.ts b/src/listeners/message/automodCreate.ts
index ae1bd21..b708e30 100644
--- a/src/listeners/message/automodCreate.ts
+++ b/src/listeners/message/automodCreate.ts
@@ -113,7 +113,7 @@ export default class AutomodMessageCreateListener extends BushListener {
message.url
})\n**Blacklisted Words:** ${util.surroundArray(Object.keys(offences), '`').join(', ')}`
)
- .addField('Message Content', `${(await util.codeblock(message.content, 1024), true)}`)
+ .addField('Message Content', `${await util.codeblock(message.content, 1024)}`)
.setColor(color)
.setTimestamp()
]
diff --git a/src/tasks/updateStats.ts b/src/tasks/updateStats.ts
new file mode 100644
index 0000000..7b0690f
--- /dev/null
+++ b/src/tasks/updateStats.ts
@@ -0,0 +1,22 @@
+import { BushTask } from '../lib/extensions/discord-akairo/BushTask';
+import { Stat } from '../lib/models/Stat';
+
+export default class UpdateStatsTask extends BushTask {
+ public constructor() {
+ super('updateStats', {
+ delay: 600_000, // 10 minutes
+ runOnStart: true
+ });
+ }
+ public override async exec(): Promise<void> {
+ const row =
+ (await Stat.findByPk(client.config.environment)) ?? (await Stat.create({ environment: client.config.environment }));
+ row.commandsUsed = client.stats.commandsUsed;
+ await row.save();
+ }
+
+ public static async init(): Promise<bigint> {
+ return ((await Stat.findByPk(client.config.environment)) ?? (await Stat.create({ environment: client.config.environment })))
+ .commandsUsed;
+ }
+}
diff --git a/src/tasks/updateSuperUsers.ts b/src/tasks/updateSuperUsers.ts
index 5b1555f..e0e51f5 100644
--- a/src/tasks/updateSuperUsers.ts
+++ b/src/tasks/updateSuperUsers.ts
@@ -4,7 +4,7 @@ import { Global } from '../lib/models/Global';
export default class UpdateSuperUsersTask extends BushTask {
public constructor() {
super('updateSuperUsers', {
- delay: 300_000, // 5 minutes
+ delay: 10_000,
runOnStart: true
});
}