Antonin
Antonin
Explore posts from servers
DIAdiscord.js - Imagine an app
Created by Antonin on 8/10/2024 in #djs-voice
Voice Stream for personal radio
import { createWriteStream } from 'node:fs';
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;
}

export function createListeningStream(receiver: VoiceReceiver, userId: string, user?: User) {
const opusStream = receiver.subscribe(userId, {
end: {
behavior: EndBehaviorType.AfterSilence,
duration: 1000,
},
});

const oggStream = new prism.opus.OggLogicalBitstream({
opusHead: new prism.opus.OpusHead({
channelCount: 2,
sampleRate: 48000,
}),
pageSizeControl: {
maxPackets: 10,
},
});

const filename = `./recordings/${Date.now()}-${getDisplayName(userId, user)}.ogg`;

const out = createWriteStream(filename);

console.log(`👂 Started recording ${filename}`);

pipeline(opusStream, oggStream, out, (err) => {
if (err) {
console.warn(`❌ Error recording file ${filename} - ${err.message}`);
} else {
console.log(`✅ Recorded ${filename}`);
}
});
}
import { createWriteStream } from 'node:fs';
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;
}

export function createListeningStream(receiver: VoiceReceiver, userId: string, user?: User) {
const opusStream = receiver.subscribe(userId, {
end: {
behavior: EndBehaviorType.AfterSilence,
duration: 1000,
},
});

const oggStream = new prism.opus.OggLogicalBitstream({
opusHead: new prism.opus.OpusHead({
channelCount: 2,
sampleRate: 48000,
}),
pageSizeControl: {
maxPackets: 10,
},
});

const filename = `./recordings/${Date.now()}-${getDisplayName(userId, user)}.ogg`;

const out = createWriteStream(filename);

console.log(`👂 Started recording ${filename}`);

pipeline(opusStream, oggStream, out, (err) => {
if (err) {
console.warn(`❌ Error recording file ${filename} - ${err.message}`);
} else {
console.log(`✅ Recorded ${filename}`);
}
});
}
16 replies
DIAdiscord.js - Imagine an app
Created by Antonin on 8/10/2024 in #djs-voice
Voice Stream for personal radio
(node:275940) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 end listeners added to [AudioReceiveStream]. MaxListeners is 10. Use emitter.setMaxListeners() to increase limit
at genericNodeError (node:internal/errors:983:15)
at wrappedFn (node:internal/errors:537:14)
at _addListener (node:events:594:17)
at AudioReceiveStream.addListener (node:events:612:10)
at Readable.on (node:internal/streams/readable:1126:35)
at AudioReceiveStream.once (node:events:656:8)
at pipe (node:internal/streams/pipeline:440:11)
at pipelineImpl (node:internal/streams/pipeline:373:25)
at pipeline (node:internal/streams/pipeline:185:10)
at createListeningStream (C:\Users\nordi\Desktop\voice-examples-main\recorder\dist\createListeningStream.js:31:32)
(node:275940) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 end listeners added to [AudioReceiveStream]. MaxListeners is 10. Use emitter.setMaxListeners() to increase limit
at genericNodeError (node:internal/errors:983:15)
at wrappedFn (node:internal/errors:537:14)
at _addListener (node:events:594:17)
at AudioReceiveStream.addListener (node:events:612:10)
at Readable.on (node:internal/streams/readable:1126:35)
at AudioReceiveStream.once (node:events:656:8)
at pipe (node:internal/streams/pipeline:440:11)
at pipelineImpl (node:internal/streams/pipeline:373:25)
at pipeline (node:internal/streams/pipeline:185:10)
at createListeningStream (C:\Users\nordi\Desktop\voice-examples-main\recorder\dist\createListeningStream.js:31:32)
16 replies
DIAdiscord.js - Imagine an app
Created by Antonin on 8/10/2024 in #djs-voice
Voice Stream for personal radio
oh i have just this error :
(node:261732) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 end listeners added to [AudioReceiveStream]. MaxListeners is 10. Use emitter.setMaxListeners() to increase limit
(node:261732) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 end listeners added to [AudioReceiveStream]. MaxListeners is 10. Use emitter.setMaxListeners() to increase limit
why this error ?
16 replies
DIAdiscord.js - Imagine an app
Created by Antonin on 8/10/2024 in #djs-voice
Voice Stream for personal radio
all is working thanks you for you help me
16 replies
DIAdiscord.js - Imagine an app
Created by Antonin on 8/10/2024 in #djs-voice
Voice Stream for personal radio
I'm trying to record, but for the moment the bot is launching.
16 replies
DIAdiscord.js - Imagine an app
Created by Antonin on 8/10/2024 in #djs-voice
Voice Stream for personal radio
it's good thanks you !
16 replies
DIAdiscord.js - Imagine an app
Created by Antonin on 8/10/2024 in #djs-voice
Voice Stream for personal radio
I don't have it in the project's .json package, should I install it?
16 replies
DIAdiscord.js - Imagine an app
Created by Antonin on 8/10/2024 in #djs-voice
Voice Stream for personal radio
"dependencies": {
"@discordjs/opus": "^0.8.0",
"@discordjs/voice": "^0.11.0",
"discord-api-types": "^0.37.95",
"discord.js": "^13.10.3",
"libsodium-wrappers": "^0.7.10",
"node-crc": "^1.3.2",
"prism-media": "^2.0.0-alpha.0",
"tslib": "^2.6.3"
},
"dependencies": {
"@discordjs/opus": "^0.8.0",
"@discordjs/voice": "^0.11.0",
"discord-api-types": "^0.37.95",
"discord.js": "^13.10.3",
"libsodium-wrappers": "^0.7.10",
"node-crc": "^1.3.2",
"prism-media": "^2.0.0-alpha.0",
"tslib": "^2.6.3"
},
16 replies
DIAdiscord.js - Imagine an app
Created by Antonin on 8/10/2024 in #djs-voice
Voice Stream for personal radio
code :
import { createWriteStream } from 'node:fs';
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;
}

export function createListeningStream(receiver: VoiceReceiver, userId: string, user?: User) {
const opusStream = receiver.subscribe(userId, {
end: {
behavior: EndBehaviorType.AfterSilence,
duration: 1000,
},
});

const oggStream = new prism.opus.OggLogicalBitstream({
opusHead: new prism.opus.OpusHead({
channelCount: 2,
sampleRate: 48000,
}),
pageSizeControl: {
maxPackets: 10,
},
});

const filename = `./recordings/${Date.now()}-${getDisplayName(userId, user)}.ogg`;

const out = createWriteStream(filename);

console.log(`👂 Started recording ${filename}`);

pipeline(opusStream, oggStream, out, (err?: { message: string }) => {
if (err) {
console.warn(`❌ Error recording file ${filename} - ${err.message}`);
} else {
console.log(`✅ Recorded ${filename}`);
}
});
}
import { createWriteStream } from 'node:fs';
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;
}

export function createListeningStream(receiver: VoiceReceiver, userId: string, user?: User) {
const opusStream = receiver.subscribe(userId, {
end: {
behavior: EndBehaviorType.AfterSilence,
duration: 1000,
},
});

const oggStream = new prism.opus.OggLogicalBitstream({
opusHead: new prism.opus.OpusHead({
channelCount: 2,
sampleRate: 48000,
}),
pageSizeControl: {
maxPackets: 10,
},
});

const filename = `./recordings/${Date.now()}-${getDisplayName(userId, user)}.ogg`;

const out = createWriteStream(filename);

console.log(`👂 Started recording ${filename}`);

pipeline(opusStream, oggStream, out, (err?: { message: string }) => {
if (err) {
console.warn(`❌ Error recording file ${filename} - ${err.message}`);
} else {
console.log(`✅ Recorded ${filename}`);
}
});
}
16 replies
DIAdiscord.js - Imagine an app
Created by Antonin on 8/10/2024 in #djs-voice
Voice Stream for personal radio
with example i have this error :
16 replies
PPrisma
Created by Antonin on 8/5/2024 in #help-and-questions
Error: PrismaClientUnknownRequestError:Invalid `prisma.user.groupBy()` invocation:
the error occurs systematically if there are too many requests and I have to restart my database to get back to normal. my github login is antonind72, the project is not public as it belongs to a customer
7 replies
PPrisma
Created by Antonin on 8/5/2024 in #help-and-questions
Error: PrismaClientUnknownRequestError:Invalid `prisma.user.groupBy()` invocation:
with Prisma Accelerate connection string
7 replies
PPrisma
Created by Antonin on 7/1/2024 in #help-and-questions
cacheStrategy is never
okey is good all work i have conflict ( DATABASE_URL x2 in .env )
7 replies
PPrisma
Created by Antonin on 7/1/2024 in #help-and-questions
cacheStrategy is never
PrismaClientKnownRequestError:
Invalid `prisma.user.findFirst()` invocation:


Error validating datasource `db`: the URL must start with the protocol `prisma://`

clientVersion: '5.16.1',
meta: { modelName: 'User' }
}
PrismaClientKnownRequestError:
Invalid `prisma.user.findFirst()` invocation:


Error validating datasource `db`: the URL must start with the protocol `prisma://`

clientVersion: '5.16.1',
meta: { modelName: 'User' }
}
finally I was using the wrong instance of prisma, but now I get this error
7 replies
PPrisma
Created by Antonin on 7/1/2024 in #help-and-questions
cacheStrategy is never
Hello, I have this error with accelerate, do you know how to fix it?
7 replies