const Discord = require('discord.js');

const { Client, GatewayIntentBits } = require('discord.js');

const client = new Client({ intents:

  [

      GatewayIntentBits.Guilds,

      GatewayIntentBits.GuildMessages,

      GatewayIntentBits.GuildVoiceStates,

]

});

const config =  require('./config.json');

const { joinVoiceChannel, createAudioPlayer, NoSubscriberBehavior, createAudioResource, AudioPlayerStatus, VoiceConnectionStatus, StreamType } = require('@discordjs/voice');

const { join } = require('path');

client.once('ready', async() => {

    console.log("connected");

    const channels = client.guilds.cache.find(f => f.name==="<my-guild>").channels;

  let channel= channels.cache.find(r => r.name === "General");

const connection = joinVoiceChannel({

channelId: channel.id,

guildId: channel.guildId,

adapterCreator: channel.guild.voiceAdapterCreator,

});                                                                                                                                         console.log("joined voice channel");

const player = createAudioPlayer();

let resource = createAudioResource("https://streams.ilovemusic.de/iloveradio2.mp3", { inlineVolume: true,

  inputType: StreamType.Arbitrary});

resource.volume.setVolume(1)

connection.subscribe(player);

player.play(resource);

});

client.login(config.token);

它上个月运行得很好,本月试图运行它,流媒体上听不到任何声音,但本地音频文件运行得很好.

预期:URL应该播放,因为discorde createAudioResource支持URL.

主要的问题是本地文件播放,而远程URL不播放.虽然没有错误,所以我对如何调试它感到困惑.

推荐答案

这应该是一个ffmpeg安装的问题,try 在一台新机器上运行脚本(在安装ffmpeg之后),它工作得很好.

Javascript相关问答推荐

如何在不使用类型化数组的情况下将32位浮点数按位转换为整值?

如何避免使用ajax在Vue 3合成API中重定向

在JavaScript中,如何将请求的回调函数的结果合并到运行的代码中?

vanillajs-datepicker未设置输入值,日期单击时未触发更改事件

如何避免移动设备中出现虚假调整大小事件?

深嵌套的ng-container元素仍然可以在Angular 布局组件中正确渲染内容吗?

从WooCommerce Checkout Country字段重新排序国家,保持国家同步

将2D数组转换为图形

Angular 17—每当一个布尔变量变为真时触发循环轮询,只要它保持为真

colored颜色 检测JS,平均图像 colored颜色 检测JS

在观察框架中搜索CSV数据

当作为表达式调用时,如何解析方法decorator 的签名?

屏幕右侧屏障上的产卵点""

使用原型判断对象是否为类的实例

Reaction Native中的范围滑块

在WordPress中使用带有WPCode的Java代码片段时出现意外令牌错误

是什么导致了这种奇怪的水平间距错误(?)当通过JavaScript将列表项元素追加到无序列表时,是否在按钮之间?

将对象推送到数组会导致复制

当标题被点击时,如何使内容出现在另一个div上?

如何在AG-Grid文本字段中创建占位符