aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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
5 files changed, 28 insertions, 4 deletions
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
});
}