Music functionality without the correct package discord.js

爱⌒轻易说出口 提交于 2021-02-10 14:16:32

问题


I started making a Discord Bot without thinking I would like to add music/voice functionality. I would now like to add this, but as the docs state you need to install:

Without voice support: npm install discord.js

With voice support (@discordjs/opus): npm install discord.js @discordjs/opus

With voice support (opusscript): npm install discord.js opusscript

I installed the one without voice support when I began, can I just install the voice support ones over or will that mess it up. If so, what are my other options? Thanks :)


回答1:


If you've already installed discord.js and you now want voice support, all you have to do is npm install <voice support module> (where the voice support module is either @discordjs/opus or opusscript).

What's really happening when you do npm install discord.js @discordjs/opus is you're asking npm to install discord.js and to install @discordjs/opus. You're just installing two different modules, and doing it conveniently in one command. That's all. It would also work if you did npm install discord.js and then did npm install @discordjs/opus. Your code doesn't care when you installed those modules, and it doesn't care if you installed them at the same time or not. Your code just needs them both to be installed in order to provide voice support.

On the docs and other websites, the command is listed as npm install discord.js @discordjs/opus just for the sake of convenience, so you can install both with one line instead of having to type out two separate commands for it. So if you already have one installed and not the other, just install the one you're missing and everything works fine. Of course, simply doing npm install discord.js @discordjs/opus even though you already have discord.js installed will still also work, as it will simply reinstall discord.js for a second time. So really as long as you are installing the voice support modules in some way, shape, or form, it will work.




回答2:


I've never tried that out, but you could definitely give it a go. I'm fairly certain it won't crash your computer. I've certainly tested the waters by copying certain files and then simply re-installing the different file requirements on my terminal multiple times since the terminal requires that, just not with voice functionality.

As for the alternate option, you can simply just copy the main files onto a different directory, and then just re-install the requirements, replacing npm install discord.js with npm install discord.js @discordjs/opus or npm install discord.js opusscript instead (though it seems like the @discordjs/opus option is the more preferable option).



来源:https://stackoverflow.com/questions/65973582/music-functionality-without-the-correct-package-discord-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!