Skip to content
This repository was archived by the owner on Sep 18, 2025. It is now read-only.

Commit 8b9f464

Browse files
authored
fix: Hotfix deferral interactions
Take care of db latency issues
2 parents 266a3bc + ca22e0f commit 8b9f464

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+973
-334
lines changed

apps/bot/latestthreadcopy.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

apps/bot/latestvideo.copy.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

apps/bot/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"name": "jasper",
3-
"version": "2.8.2",
3+
"version": "2.8.3",
44
"scripts": {
55
"build": "gulp js && tsc",
66
"start": "node dist/index.js",
77
"dev": "yarn pretty && yarn build && yarn eslint && node dist/index.js",
8+
"dev-fast": "yarn build && node dist/index.js",
89
"eslint": "eslint \"**/*.{ts,mjs,cjs}\" --fix",
910
"pretty": "prettier --write \"./**/*.{js,jsx,mjs,cjs,ts,tsx,json}\"",
1011
"builddocker": "docker build -t jasper .",

apps/bot/src/classes/store.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ export class Store extends Redis {
1414
constructor(protected context: Context) {
1515
super({
1616
host: context.env.get('redis_host'),
17+
password: 'LenW6q9oXlekeSYm4OMUnHfuXEtTgacM',
1718
port: context.env.get('redis_port') as number,
1819
retryStrategy: (times) => {
1920
console.error(`Redis retry attempt ${times}`);
2021
return Math.min(times * 100, 3000);
2122
},
23+
username: 'default',
2224
});
2325
this.ctx = context;
2426

apps/bot/src/define.ts

Lines changed: 298 additions & 83 deletions
Large diffs are not rendered by default.

apps/bot/src/listeners/interactionCreateListener.ts

Lines changed: 218 additions & 32 deletions
Large diffs are not rendered by default.

apps/bot/src/listeners/messageReactionAddListener.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Options } from '../services/settingsService';
1111

1212
import { Listener } from './listener';
1313

14-
interface PlaywrightRenderRequest {
14+
interface WebserverRenderRequest {
1515
[key: string]: unknown;
1616
attachments?: null | string[];
1717
avatar: string;
@@ -114,7 +114,7 @@ export default class MessageReactionAddListener extends Listener<'messageReactio
114114
return [channel.id, channel.name].join(':');
115115
});
116116

117-
const response = await this.ctx.webserver.request<PlaywrightRenderRequest>(
117+
const response = await this.ctx.webserver.request<WebserverRenderRequest>(
118118
'POST',
119119
'/fun/skullboard',
120120
{

apps/bot/src/listeners/readyListener.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Context } from '../classes/context';
22
import { defineEvent } from '../define';
3+
import { Options } from '../services/settingsService';
34
import { cleanUpExpiredThreads, cleanUpInactiveThreads } from '../threadInactiveCheck';
45
import { updateSubCountChannel } from '../youtube';
56

@@ -11,6 +12,13 @@ export default class ReadyListener extends Listener<'ready'> {
1112
}
1213

1314
public execute(): void {
15+
try {
16+
for (const guild of this.ctx.guilds.cache.values()) {
17+
this.ctx.services.settings
18+
.configure<Options>({ guildId: guild.id })
19+
.catch(() => {});
20+
}
21+
} catch {}
1422
if (this.ctx.env.get('sub_update') === '1') {
1523
updateSubCountChannel(this.ctx, this.ctx.env.get('youtube_id'));
1624
}

apps/bot/src/plugins/configuration/subcommands/addActionSubCommand.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { ApplicationCommandOptionType } from '@antibot/interactions';
2-
import { ChatInputCommandInteraction, MessageFlags } from 'discord.js';
2+
import { ChatInputCommandInteraction } from 'discord.js';
33

44
import { Context } from '../../../classes/context';
55
import { defineSubCommand } from '../../../define';
66
import { Options, SetTextOptions } from '../../../services/settingsService';
77

88
export const AddActionSubCommand = defineSubCommand({
9+
deferral: { defer: true, ephemeral: true },
910
handler: async (ctx: Context, interaction: ChatInputCommandInteraction) => {
1011
const guildId = interaction.guildId!;
1112
const action = interaction.options.getString('action')!;
@@ -14,9 +15,8 @@ export const AddActionSubCommand = defineSubCommand({
1415
const actionsExistInDB = await ctx.services.settings.getText<string>(guildId, 'Actions');
1516

1617
if (actionsExistInDB.includes(action)) {
17-
await interaction.reply({
18+
await interaction.editReply({
1819
content: `For the record, **${action}** is already in the actions list.`,
19-
flags: MessageFlags.Ephemeral,
2020
});
2121
return;
2222
}
@@ -26,9 +26,8 @@ export const AddActionSubCommand = defineSubCommand({
2626
...{ key: 'Actions', values: action },
2727
});
2828

29-
await interaction.reply({
29+
await interaction.editReply({
3030
content: `I've added **${action}** to the actions list.`,
31-
flags: MessageFlags.Ephemeral,
3231
});
3332
},
3433
name: 'add_action',

apps/bot/src/plugins/configuration/subcommands/addBulkDelChannelSubCommand.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { GuildSnowflake } from '../../../services/settingsService';
88
import { Options } from '../../../services/tagService';
99

1010
export const AddBulkDelChannelSubCommand = defineSubCommand({
11+
deferral: { defer: true, ephemeral: true },
12+
1113
handler: async (ctx: Context, interaction: ChatInputCommandInteraction) => {
1214
const guildId = interaction.guildId!;
1315
const channel = interaction.options.getChannel('channel')!;
@@ -19,7 +21,7 @@ export const AddBulkDelChannelSubCommand = defineSubCommand({
1921
await ctx.services.settings.getBulkDeleteLogging<Snowflake>(guildId);
2022

2123
if (bulkDelSettings?.LogChannel === channel.id) {
22-
await interaction.reply({
24+
await interaction.editReply({
2325
components: [
2426
createConfigurationExistsEmbed({
2527
configName: 'Bulk Delete Logging',
@@ -40,7 +42,7 @@ export const AddBulkDelChannelSubCommand = defineSubCommand({
4042

4143
console.log('hi');
4244

43-
await interaction.reply({
45+
await interaction.editReply({
4446
components: [
4547
createConfigurationUpdateEmbed({
4648
configName: 'Bulk Delete Logging',

0 commit comments

Comments
 (0)