Skip to content

Commit 479812e

Browse files
committed
fix: fix typings and formatting
1 parent f611994 commit 479812e

File tree

13 files changed

+43
-38
lines changed

13 files changed

+43
-38
lines changed

apis/websocket/scripts/build.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { createLogger } from '@revanced/bot-shared'
2-
import { cp, rm } from 'fs/promises'
2+
import { cp, exists, rm } from 'fs/promises'
33

44
const logger = createLogger()
55

66
logger.info('Cleaning previous build...')
7-
await rm('./dist', { recursive: true })
7+
if (await exists('./dist')) await rm('./dist', { recursive: true })
88

99
logger.info('Building WebSocket API...')
1010
await Bun.build({

apis/websocket/src/classes/Client.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export default class Client {
110110
protected _toBuffer(data: RawData) {
111111
if (data instanceof Buffer) return data
112112
if (data instanceof ArrayBuffer) return Buffer.from(data)
113-
return Buffer.concat(data)
113+
return Buffer.concat(data as Uint8Array[])
114114
}
115115
}
116116

bots/discord/config.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ export default {
1919
},
2020
timeout: 60000,
2121
forceSendTimeout: 300000,
22-
}
23-
}
22+
},
23+
},
2424
},
2525
moderation: {
2626
cure: {
@@ -77,7 +77,7 @@ export default {
7777
attachments: {
7878
scanAttachments: true,
7979
allowedMimeTypes: ['image/jpeg', 'image/png', 'image/webp', 'text/plain'],
80-
maxTextFileSize: 512000
80+
maxTextFileSize: 512000,
8181
},
8282
responses: [
8383
{

bots/discord/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@
4343
"discord-api-types": "^0.37.102",
4444
"drizzle-kit": "^0.22.8"
4545
}
46-
}
46+
}

bots/discord/src/commands/support/train/chat.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import Command from '$/classes/Command'
22
import CommandError, { CommandErrorType } from '$/classes/CommandError'
3-
import { config } from '../../../context'
4-
import type { FetchMessageOptions, MessageResolvable } from 'discord.js'
5-
import type { ConfigMessageScanResponseLabelConfig } from 'config.schema'
63
import { createSuccessEmbed } from '$/utils/discord/embeds'
4+
import type { ConfigMessageScanResponseLabelConfig } from 'config.schema'
5+
import type { FetchMessageOptions, MessageResolvable } from 'discord.js'
6+
import { config } from '../../../context'
77

88
const msRcConfig = config.messageScan?.humanCorrections?.allow
99

bots/discord/src/commands/support/train/context-menu.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import Command from '$/classes/Command'
22
import CommandError, { CommandErrorType } from '$/classes/CommandError'
3-
import { config } from '../../../context'
4-
import { type APIStringSelectComponent, ComponentType } from 'discord.js'
53
import type { ConfigMessageScanResponseLabelConfig } from 'config.schema'
4+
import { type APIStringSelectComponent, ComponentType } from 'discord.js'
5+
import { config } from '../../../context'
66

77
const msRcConfig = config.messageScan?.humanCorrections?.allow
88

bots/discord/src/events/discord/interactionCreate/chatCommand.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ withContext(on, 'interactionCreate', async (context, interaction) => {
99
const command = discord.commands[interaction.commandName]
1010

1111
logger.debug(`Command ${interaction.commandName} being invoked by ${interaction.user.tag} via chat`)
12-
if (!command)
13-
return void logger.error(`Chat command ${interaction.commandName} not implemented but registered!!!`)
12+
if (!command) return void logger.error(`Chat command ${interaction.commandName} not implemented but registered!!!`)
1413

1514
try {
1615
logger.debug(`Command ${interaction.commandName} being executed via chat`)

bots/discord/src/events/discord/messageCreate/stickyMessageReset.ts

+24-18
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,34 @@ withContext(on, 'messageCreate', async ({ discord, logger }, msg) => {
88
if (!store) return
99

1010
if (store.timerActive) {
11-
if (!store.forceTimerActive && store.forceTimerMs) {
12-
logger.debug(
13-
`Channel ${msg.channelId} in guild ${msg.guildId} is active, starting force send timer and clearing existing timer`,
14-
)
11+
// Timer is already active, so we try to start the force timer
12+
if (store.forceTimerMs) {
13+
// Force timer isn't active, so we start it
14+
if (!store.forceTimerActive) {
15+
logger.debug(
16+
`Channel ${msg.channelId} in guild ${msg.guildId} is active, starting force send timer and clearing existing timer`,
17+
)
1518

16-
// Clear the timer
17-
clearTimeout(store.timer)
18-
store.timerActive = false
19+
// Clear the timer
20+
clearTimeout(store.timer)
21+
store.timerActive = false
1922

20-
// (Re)start the force timer
21-
store.forceTimerActive = true
22-
if (!store.forceTimer)
23-
store.forceTimer = setTimeout(
24-
() =>
25-
store.send(true).then(() => {
26-
store.forceTimerActive = false
27-
}),
28-
store.forceTimerMs,
29-
) as NodeJS.Timeout
30-
else store.forceTimer.refresh()
23+
// (Re)start the force timer
24+
store.forceTimerActive = true
25+
if (!store.forceTimer)
26+
store.forceTimer = setTimeout(
27+
() =>
28+
store.send(true).then(() => {
29+
store.forceTimerActive = false
30+
}),
31+
store.forceTimerMs,
32+
) as NodeJS.Timeout
33+
else store.forceTimer.refresh()
34+
// Force timer is already active, so we force send
35+
} else store.send()
3136
}
3237
} else if (!store.forceTimerActive) {
38+
// Both timers aren't active, so we start the timer
3339
store.timerActive = true
3440
if (!store.timer) store.timer = setTimeout(store.send, store.timerMs) as NodeJS.Timeout
3541
}

bots/discord/src/events/discord/messageReactionAdd/correctResponse.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ const PossibleReactions = Object.values(Reactions) as string[]
2020

2121
withContext(on, 'messageReactionAdd', async (context, rct, user) => {
2222
if (user.bot) return
23-
23+
2424
const { database: db, logger, config } = context
2525
const { messageScan: msConfig } = config
26-
26+
2727
// If there's no config, we can't do anything
2828
if (!msConfig?.humanCorrections) return
2929

bots/discord/src/utils/discord/moderation.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export const cureNickname = async (member: GuildMember) => {
5757
cured =
5858
member.user.username.length >= 3
5959
? member.user.username
60-
: config.moderation?.cure?.defaultName ?? 'Server member'
60+
: (config.moderation?.cure?.defaultName ?? 'Server member')
6161

6262
if (cured.toLowerCase() === name.toLowerCase()) return
6363

bots/discord/src/utils/duration.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import parse from 'parse-duration'
22

3-
parse[''] = parse['s']
3+
parse[''] = parse['s']!
44
parse['mo'] = parse['M'] = parse['month']!
55

66
const defaultUnitValue = parse['']!

packages/api/src/classes/ClientWebSocket.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ export class ClientWebSocketManager {
207207
protected _toBuffer(data: RawData) {
208208
if (data instanceof Buffer) return data
209209
if (data instanceof ArrayBuffer) return Buffer.from(data)
210-
return Buffer.concat(data)
210+
return Buffer.concat(data as Uint8Array[])
211211
}
212212
}
213213

packages/shared/src/utils/serialization.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ export function serializePacket<TOp extends Operation>(packet: Packet<TOp>) {
1818
* @returns A packet
1919
*/
2020
export function deserializePacket(buffer: Buffer) {
21-
const data = BSON.deserialize(buffer)
21+
const data = BSON.deserialize(buffer as Uint8Array)
2222
return parse(PacketSchema, data) as Packet
2323
}

0 commit comments

Comments
 (0)