diff --git a/packages/voice/examples/recorder/package.json b/packages/voice/examples/recorder/package.json index 336388063..47ce68f27 100644 --- a/packages/voice/examples/recorder/package.json +++ b/packages/voice/examples/recorder/package.json @@ -14,15 +14,15 @@ "author": "Amish Shah ", "license": "MIT", "dependencies": { - "@discordjs/opus": "^0.5.3", - "discord-api-types": "^0.30.0", - "discord.js": "^13.7.0", + "@discordjs/opus": "^0.8.0", + "discord-api-types": "^0.33.3", + "discord.js": "^13.8.0", "libsodium-wrappers": "^0.7.9", "node-crc": "^1.3.2", "prism-media": "^2.0.0-alpha.0" }, "devDependencies": { "tsconfig-paths": "^3.10.1", - "typescript": "~4.3.5" + "typescript": "^4.7.4" } } diff --git a/packages/voice/examples/recorder/src/bot.ts b/packages/voice/examples/recorder/src/bot.ts index a012f17e9..d66a53b78 100644 --- a/packages/voice/examples/recorder/src/bot.ts +++ b/packages/voice/examples/recorder/src/bot.ts @@ -1,19 +1,21 @@ -import Discord, { Events, Interaction } from 'discord.js'; import { getVoiceConnection } from '@discordjs/voice'; +import { GatewayIntentBits } from 'discord-api-types/v9'; +import Discord, { Interaction, Constants } from 'discord.js'; import { deploy } from './deploy'; import { interactionHandlers } from './interactions'; -import { GatewayIntentBits } from 'discord-api-types/v9'; // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports -const { token } = require('../auth.json'); +const { token } = require('../auth.json') as { token: string }; const client = new Discord.Client({ intents: [GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildMessages, GatewayIntentBits.Guilds], }); -client.on(Events.ClientReady, () => console.log('Ready!')); +const { Events } = Constants; -client.on(Events.MessageCreate, async (message) => { +client.on(Events.CLIENT_READY, () => console.log('Ready!')); + +client.on(Events.MESSAGE_CREATE, async (message) => { if (!message.guild) return; if (!client.application?.owner) await client.application?.fetch(); @@ -28,7 +30,7 @@ client.on(Events.MessageCreate, async (message) => { */ const recordable = new Set(); -client.on(Events.InteractionCreate, async (interaction: Interaction) => { +client.on(Events.INTERACTION_CREATE, async (interaction: Interaction) => { if (!interaction.isCommand() || !interaction.guildId) return; const handler = interactionHandlers.get(interaction.commandName); @@ -44,6 +46,6 @@ client.on(Events.InteractionCreate, async (interaction: Interaction) => { } }); -client.on(Events.Error, console.warn); +client.on(Events.ERROR, console.warn); void client.login(token); diff --git a/packages/voice/examples/recorder/src/createListeningStream.ts b/packages/voice/examples/recorder/src/createListeningStream.ts index 63bb6af73..60e659b04 100644 --- a/packages/voice/examples/recorder/src/createListeningStream.ts +++ b/packages/voice/examples/recorder/src/createListeningStream.ts @@ -1,8 +1,8 @@ +import { createWriteStream } from 'node:fs'; +import { pipeline } from 'node:stream'; import { EndBehaviorType, VoiceReceiver } from '@discordjs/voice'; import type { User } from 'discord.js'; -import { createWriteStream } from 'node:fs'; -import prism from 'prism-media'; -import { pipeline } from 'node:stream'; +import * as prism from 'prism-media'; function getDisplayName(userId: string, user?: User) { return user ? `${user.username}_${user.discriminator}` : userId; @@ -12,7 +12,7 @@ export function createListeningStream(receiver: VoiceReceiver, userId: string, u const opusStream = receiver.subscribe(userId, { end: { behavior: EndBehaviorType.AfterSilence, - duration: 100, + duration: 1000, }, }); diff --git a/packages/voice/examples/recorder/tsconfig.json b/packages/voice/examples/recorder/tsconfig.json index 99c059857..cadce793d 100644 --- a/packages/voice/examples/recorder/tsconfig.json +++ b/packages/voice/examples/recorder/tsconfig.json @@ -3,6 +3,7 @@ "compilerOptions": { "baseUrl": ".", "outDir": "dist", + "skipLibCheck": true, "paths": { "@discordjs/voice": ["../../"], "libsodium-wrappers": ["./node_modules/libsodium-wrappers"]