久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用 djs v13 播放本地音樂文件

Play local music files using djs v13(使用 djs v13 播放本地音樂文件)
本文介紹了使用 djs v13 播放本地音樂文件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我知道很多人已經問過如何在 discord 語音頻道中播放來自 youtube 的音樂,但我找不到任何關于在 djs 版本 13.2.0 上播放本地文件的信息!我嘗試使用此代碼:

I know a lot of people already asked how to play music from youtube in discord voice channel, but I can't find anything about playing local files on djs version 13.2.0! I tried using this code:

const { createReadStream } = require('fs');
const { join } = require('path');
const { createAudioResource, StreamType, createAudioPlayer, joinVoiceChannel } = require('@discordjs/voice'); 
joinVoiceChannel({
            channelId: message.member.voice.channel.id,
            guildId: message.guild.id,
            adapterCreator: message.guild.voiceAdapterCreator
        }); 
message.guild.me.voice.setRequestToSpeak(true);
let resource = createAudioResource(join(../music/audio.mp3, 'audio.mp3')); 
const player = createAudioPlayer(); 

player.play(resource);

當我嘗試 eval() 時 - 我的機器人加入頻道(舞臺頻道)并說一切正常,但它沒有播放任何東西!如何讓我的機器人在舞臺頻道播放本地音樂文件?

When I try to eval() it - my bot joins the channel (stage channel) and says everything worked, but it's not playing anything! How can I make my bot play local music files in stage channel?

推薦答案

這里有2個問題.

首先,路徑完全錯誤.它不是字符串,即使您嘗試將其更改為字符串,它也會無效,因為第一個參數以 audio.mp3 結尾,第二個參數是 audio.mp3.請改用此路徑:

Firstly, the path is completely wrong. It is not a string and even if you try to change it to a string it will be invalid as the first argument ends with audio.mp3, and the second one is audio.mp3. Use this path instead:

let resource = createAudioResource(join('..', 'music', 'audio.mp3')); 

其次,您在播放器中播放音頻,而不是語音連接.您必須訂閱音頻播放器.

Secondly, you are playing audio in the player, but not the voice connection. You must subscribe to the audio player.

這應該是最終代碼:

const player = createAudioPlayer()
joinVoiceChannel({
    channelId: message.member.voice.channel.id,
    guildId: message.guild.id,
    adapterCreator: message.guild.voiceAdapterCreator
}).subscribe(player)
message.guild.me.voice.setRequestToSpeak(true);
let resource = createAudioResource(join('..', 'music', 'audio.mp3'));

player.play(resource)

這篇關于使用 djs v13 播放本地音樂文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 頻道中的消息?)
how to make my bot mention the person who gave that bot command(如何讓我的機器人提及發出該機器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復必須使用導入來加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來自特定服務器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務器時的歡迎消息)
主站蜘蛛池模板: 国产伦精品一区二区三毛 | 免费视频一区二区 | 在线观看中文字幕 | 一区二区电影网 | 精品国产乱码久久久久久中文 | 97视频人人澡人人爽 | 中文字幕综合 | 超碰97人人人人人蜜桃 | 91日韩 | 成人在线看片 | 亚洲视频一区 | 久久涩涩 | 亚洲一区二区视频 | 欧美国产视频 | 99re66在线观看精品热 | 国产在线视频一区二区董小宛性色 | 国外成人在线视频 | 久久精品小视频 | 天天玩天天干天天操 | 北条麻妃99精品青青久久 | 日韩一区二区不卡 | 福利av在线 | 91视频网 | 成人区一区二区三区 | 免费一二区 | 五月综合激情婷婷 | 国产一区二区不卡 | 成人欧美一区二区 | 国产成人精品久久 | 欧美日韩精品久久久免费观看 | 欧美福利视频一区 | 日本黄色片免费在线观看 | 国产精品中文字幕在线 | 视频一二三区 | 亚洲啪啪| 日日摸夜夜添夜夜添精品视频 | 欧美成人手机在线 | 99久久免费精品 | 日韩欧美精品 | 秋霞电影一区二区 | 狠狠草视频 |