うちはライム
DIAdiscord.js - Imagine an app
•Created by うちはライム on 12/24/2023 in #djs-voice
Tried to make voice listener in a VC and it didn't log anything
const { AudioReceiveStream, joinVoiceChannel, EndBehaviorType, VoiceReceiver } = require('@discordjs/voice');
const { EmbedBuilder } = require('discord.js');
const axios = require("axios").default;
const fs = require("fs");
/**
*
* @param {import("discord.js").CommandInteraction} context
*/
module.exports = async (context) => {
const {member, client, guild} = context;
const targetChannel = member.voice.channel;
// VC connection verification conditions goes here
const reply = await context.followUp("Starting...");
const connection = joinVoiceChannel({
channelId: targetChannel.id,
guildId: guild.id,
adapterCreator: guild.voiceAdapterCreator,
selfDeaf: false
});
const listener = new AudioReceiveStream({end: EndBehaviorType.AfterSilence});
const writeStream = fs.createWriteStream('user_audio.pcm');
listener.pipe(writeStream);
listener.on('end', async () => {
const audioData = fs.readFileSync('user_audio.pcm');
// play with the voice a lil bit here
});
}
const { AudioReceiveStream, joinVoiceChannel, EndBehaviorType, VoiceReceiver } = require('@discordjs/voice');
const { EmbedBuilder } = require('discord.js');
const axios = require("axios").default;
const fs = require("fs");
/**
*
* @param {import("discord.js").CommandInteraction} context
*/
module.exports = async (context) => {
const {member, client, guild} = context;
const targetChannel = member.voice.channel;
// VC connection verification conditions goes here
const reply = await context.followUp("Starting...");
const connection = joinVoiceChannel({
channelId: targetChannel.id,
guildId: guild.id,
adapterCreator: guild.voiceAdapterCreator,
selfDeaf: false
});
const listener = new AudioReceiveStream({end: EndBehaviorType.AfterSilence});
const writeStream = fs.createWriteStream('user_audio.pcm');
listener.pipe(writeStream);
listener.on('end', async () => {
const audioData = fs.readFileSync('user_audio.pcm');
// play with the voice a lil bit here
});
}
2 replies