mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-11 13:56:15 +00:00
fix: fix typings and formatting
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { createLogger } from '@revanced/bot-shared'
|
||||
import { cp, rm } from 'fs/promises'
|
||||
import { cp, exists, rm } from 'fs/promises'
|
||||
|
||||
const logger = createLogger()
|
||||
|
||||
logger.info('Cleaning previous build...')
|
||||
await rm('./dist', { recursive: true })
|
||||
if (await exists('./dist')) await rm('./dist', { recursive: true })
|
||||
|
||||
logger.info('Building WebSocket API...')
|
||||
await Bun.build({
|
||||
|
||||
@@ -110,7 +110,7 @@ export default class Client {
|
||||
protected _toBuffer(data: RawData) {
|
||||
if (data instanceof Buffer) return data
|
||||
if (data instanceof ArrayBuffer) return Buffer.from(data)
|
||||
return Buffer.concat(data)
|
||||
return Buffer.concat(data as Uint8Array[])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ export default {
|
||||
},
|
||||
timeout: 60000,
|
||||
forceSendTimeout: 300000,
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
moderation: {
|
||||
cure: {
|
||||
@@ -77,7 +77,7 @@ export default {
|
||||
attachments: {
|
||||
scanAttachments: true,
|
||||
allowedMimeTypes: ['image/jpeg', 'image/png', 'image/webp', 'text/plain'],
|
||||
maxTextFileSize: 512000
|
||||
maxTextFileSize: 512000,
|
||||
},
|
||||
responses: [
|
||||
{
|
||||
|
||||
@@ -43,4 +43,4 @@
|
||||
"discord-api-types": "^0.37.102",
|
||||
"drizzle-kit": "^0.22.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import Command from '$/classes/Command'
|
||||
import CommandError, { CommandErrorType } from '$/classes/CommandError'
|
||||
import { config } from '../../../context'
|
||||
import type { FetchMessageOptions, MessageResolvable } from 'discord.js'
|
||||
import type { ConfigMessageScanResponseLabelConfig } from 'config.schema'
|
||||
import { createSuccessEmbed } from '$/utils/discord/embeds'
|
||||
import type { ConfigMessageScanResponseLabelConfig } from 'config.schema'
|
||||
import type { FetchMessageOptions, MessageResolvable } from 'discord.js'
|
||||
import { config } from '../../../context'
|
||||
|
||||
const msRcConfig = config.messageScan?.humanCorrections?.allow
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import Command from '$/classes/Command'
|
||||
import CommandError, { CommandErrorType } from '$/classes/CommandError'
|
||||
import { config } from '../../../context'
|
||||
import { type APIStringSelectComponent, ComponentType } from 'discord.js'
|
||||
import type { ConfigMessageScanResponseLabelConfig } from 'config.schema'
|
||||
import { type APIStringSelectComponent, ComponentType } from 'discord.js'
|
||||
import { config } from '../../../context'
|
||||
|
||||
const msRcConfig = config.messageScan?.humanCorrections?.allow
|
||||
|
||||
|
||||
@@ -9,8 +9,7 @@ withContext(on, 'interactionCreate', async (context, interaction) => {
|
||||
const command = discord.commands[interaction.commandName]
|
||||
|
||||
logger.debug(`Command ${interaction.commandName} being invoked by ${interaction.user.tag} via chat`)
|
||||
if (!command)
|
||||
return void logger.error(`Chat command ${interaction.commandName} not implemented but registered!!!`)
|
||||
if (!command) return void logger.error(`Chat command ${interaction.commandName} not implemented but registered!!!`)
|
||||
|
||||
try {
|
||||
logger.debug(`Command ${interaction.commandName} being executed via chat`)
|
||||
|
||||
@@ -8,28 +8,34 @@ withContext(on, 'messageCreate', async ({ discord, logger }, msg) => {
|
||||
if (!store) return
|
||||
|
||||
if (store.timerActive) {
|
||||
if (!store.forceTimerActive && store.forceTimerMs) {
|
||||
logger.debug(
|
||||
`Channel ${msg.channelId} in guild ${msg.guildId} is active, starting force send timer and clearing existing timer`,
|
||||
)
|
||||
// Timer is already active, so we try to start the force timer
|
||||
if (store.forceTimerMs) {
|
||||
// Force timer isn't active, so we start it
|
||||
if (!store.forceTimerActive) {
|
||||
logger.debug(
|
||||
`Channel ${msg.channelId} in guild ${msg.guildId} is active, starting force send timer and clearing existing timer`,
|
||||
)
|
||||
|
||||
// Clear the timer
|
||||
clearTimeout(store.timer)
|
||||
store.timerActive = false
|
||||
// Clear the timer
|
||||
clearTimeout(store.timer)
|
||||
store.timerActive = false
|
||||
|
||||
// (Re)start the force timer
|
||||
store.forceTimerActive = true
|
||||
if (!store.forceTimer)
|
||||
store.forceTimer = setTimeout(
|
||||
() =>
|
||||
store.send(true).then(() => {
|
||||
store.forceTimerActive = false
|
||||
}),
|
||||
store.forceTimerMs,
|
||||
) as NodeJS.Timeout
|
||||
else store.forceTimer.refresh()
|
||||
// (Re)start the force timer
|
||||
store.forceTimerActive = true
|
||||
if (!store.forceTimer)
|
||||
store.forceTimer = setTimeout(
|
||||
() =>
|
||||
store.send(true).then(() => {
|
||||
store.forceTimerActive = false
|
||||
}),
|
||||
store.forceTimerMs,
|
||||
) as NodeJS.Timeout
|
||||
else store.forceTimer.refresh()
|
||||
// Force timer is already active, so we force send
|
||||
} else store.send()
|
||||
}
|
||||
} else if (!store.forceTimerActive) {
|
||||
// Both timers aren't active, so we start the timer
|
||||
store.timerActive = true
|
||||
if (!store.timer) store.timer = setTimeout(store.send, store.timerMs) as NodeJS.Timeout
|
||||
}
|
||||
|
||||
@@ -20,10 +20,10 @@ const PossibleReactions = Object.values(Reactions) as string[]
|
||||
|
||||
withContext(on, 'messageReactionAdd', async (context, rct, user) => {
|
||||
if (user.bot) return
|
||||
|
||||
|
||||
const { database: db, logger, config } = context
|
||||
const { messageScan: msConfig } = config
|
||||
|
||||
|
||||
// If there's no config, we can't do anything
|
||||
if (!msConfig?.humanCorrections) return
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ export const cureNickname = async (member: GuildMember) => {
|
||||
cured =
|
||||
member.user.username.length >= 3
|
||||
? member.user.username
|
||||
: config.moderation?.cure?.defaultName ?? 'Server member'
|
||||
: (config.moderation?.cure?.defaultName ?? 'Server member')
|
||||
|
||||
if (cured.toLowerCase() === name.toLowerCase()) return
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import parse from 'parse-duration'
|
||||
|
||||
parse[''] = parse['s']
|
||||
parse[''] = parse['s']!
|
||||
parse['mo'] = parse['M'] = parse['month']!
|
||||
|
||||
const defaultUnitValue = parse['']!
|
||||
|
||||
@@ -207,7 +207,7 @@ export class ClientWebSocketManager {
|
||||
protected _toBuffer(data: RawData) {
|
||||
if (data instanceof Buffer) return data
|
||||
if (data instanceof ArrayBuffer) return Buffer.from(data)
|
||||
return Buffer.concat(data)
|
||||
return Buffer.concat(data as Uint8Array[])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,6 @@ export function serializePacket<TOp extends Operation>(packet: Packet<TOp>) {
|
||||
* @returns A packet
|
||||
*/
|
||||
export function deserializePacket(buffer: Buffer) {
|
||||
const data = BSON.deserialize(buffer)
|
||||
const data = BSON.deserialize(buffer as Uint8Array)
|
||||
return parse(PacketSchema, data) as Packet
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user