Skip to content

Commit

Permalink
fix(recorder-example): bump dependencies (#8123)
Browse files Browse the repository at this point in the history
  • Loading branch information
tony-ist committed Jul 6, 2022
1 parent 0b979b0 commit 10ba008
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
8 changes: 4 additions & 4 deletions packages/voice/examples/recorder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
"author": "Amish Shah <contact@shah.gg>",
"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"
}
}
16 changes: 9 additions & 7 deletions packages/voice/examples/recorder/src/bot.ts
Original file line number Diff line number Diff line change
@@ -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.CLIENT_READY, () => console.log('Ready!'));

client.on(Events.MessageCreate, async (message) => {
client.on(Events.MESSAGE_CREATE, async (message) => {
if (!message.guild) return;
if (!client.application?.owner) await client.application?.fetch();

Expand All @@ -28,7 +30,7 @@ client.on(Events.MessageCreate, async (message) => {
*/
const recordable = new Set<string>();

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);
Expand All @@ -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);
8 changes: 4 additions & 4 deletions packages/voice/examples/recorder/src/createListeningStream.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
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 { EndBehaviorType, VoiceReceiver } from '@discordjs/voice';
import type { User } from 'discord.js';
import * as prism from 'prism-media';

function getDisplayName(userId: string, user?: User) {
return user ? `${user.username}_${user.discriminator}` : userId;
Expand All @@ -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,
},
});

Expand Down
1 change: 1 addition & 0 deletions packages/voice/examples/recorder/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
"baseUrl": ".",
"outDir": "dist",
"skipLibCheck": true,
"paths": {
"@discordjs/voice": ["../../"],
"libsodium-wrappers": ["./node_modules/libsodium-wrappers"]
Expand Down

0 comments on commit 10ba008

Please sign in to comment.