在herooku上用我的不和谐机器人播放流不工作



我想制作一个Bot,它可以播放在线广播的直播。我使用Discord JS v13。在Heroku上,我安装了以下构建包:

  • heroku/nodejs
  • https://github.com/jonathanong/heroku-buildpack-ffmpeg-latest.git
  • https://github.com/xrisk/heroku-opus.git
  • https://github.com/OnlyNoob/heroku-buildpack-libsodium.git

我的代码如下:

let voiceChn = message.member.voice.channel;
const connection = joinVoiceChannel({
channelId: message.member.voice.channel.id,
guildId: message.member.voice.channel.guildId,
adapterCreator: message.guild.voiceAdapterCreator,
selfDeaf: true
});
const player = createAudioPlayer();
let resource = createAudioResource(STREAM_URL);
connection.subscribe(player);
connection.on(VoiceConnectionStatus.Ready, () => {
player.play(resource);
});

它可以在我的电脑上运行,但它不能在Heroku上运行。这些是我已经安装的软件包:

  • "@discordjs/opus":"^ 0.5.3"
  • "@discordjs/rest":"^ 0.5.0"
  • "@discordjs/voice":"^ 0.10.0"
  • "discord-api-types"^ 0.36.0"
  • "discord.js"^ 13.8.1"
  • "ffmpeg-static"^ 4.4.1"
  • "libsodium-wrappers"^ 0.7.10"

我确实得到以下错误:玩家立即发出空闲事件并记录:

{
status: 'playing',
missedFrames: 0,
playbackDuration: 120,
resource: AudioResource {
playStream: OggDemuxer {
_readableState: [ReadableState],
_events: [Object: null prototype],
_eventsCount: 5,
_maxListeners: undefined,
_writableState: [WritableState],
allowHalfOpen: true,
_remainder: null,
_head: null,
_bitstream: null,
[Symbol(kCapture)]: false,
[Symbol(kCallback)]: null
},
edges: [ [Object], [Object] ],
metadata: null,
volume: undefined,
encoder: undefined,
audioPlayer: undefined,
playbackDuration: 0,
started: true,
silencePaddingFrames: 5,
silenceRemaining: 0
},
onStreamError: [Function: onStreamError]
}

不确定错误,但我相信我有同样的问题并修复了它。没有测试是否需要所有的更改,但是下面是:

  • 代替你的heroku-buildpack- lib钠包,我使用:https://github.com/Crazycatz00/heroku-buildpack-libopus

  • 将所有url 'https'更改为'http'

  • 使用DNS查找工具以IPV4形式更改域名

    'https://stream.skymedia.ee/live/NRJdnb' becomes 'http://185.31.240.229:8888/NRJdnb'

  • 在更改斜杠命令的代码后部署斜杠命令

相关内容

  • 没有找到相关文章

最新更新