Closed utterances-bot closed 3 years ago
您好,不知道為何我輸入的!!join後,機器人完全都沒反應,不會加入頻道。
請問 !!join 機器人加進來後,按 !!play 加上網址 沒有跑出提示訊息及播放歌曲
@thisiskk 檢查一下:
如果上述兩點都有做到,看看 terminal 有沒有錯誤訊息,可以貼上來我看看是什麼問題~
@kurega 我更新了程式碼和套件版本,可以再測試看看能不能正常播放
可以了
請問我在撥放音樂時沒反應 而後台跑出:
Error: No video id found: https://www.youtube.com/watch?v=lg1N-4jJJrk&ab_channel=TrapNation
at Object.exports.getVideoID (C:\Users\10user\Desktop\音樂機器人\node_modules\ytdl-core\lib\url-utils.js:66:11)
at Function.exports.
請問這是什麼意思
@CatTW
問題出在這行的 musicURL 字串沒處理乾淨,前面多了一個空格
const musicURL = msg.content.replace(`${prefix}play`, '');
改為這樣應該就正常了:
const musicURL = msg.content.replace(`${prefix}play`, '').trim();
感謝回報~ Github Repo 也更新了
npm install @discordjs/opus 用不了阿~~
@RockKingdom 剛剛測試可以正常安裝。有什麼錯誤訊息嗎?
跑出一堆err
npm ERR! code 1
npm ERR! path C:\Users\USER\Desktop\HappyMusic\node_modules\@discordjs\opus
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node-pre-gyp install --fallback-to-build
npm ERR! Failed to execute 'F:\node.exe F:\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\Users\USER\Desktop\HappyMusic\node_modules\@discordjs\opus\prebuild\node-v88-napi-v3-win32-x64-unknown-unknown\opus.node --module_name=opus --module_path=C:\Users\USER\Desktop\HappyMusic\node_modules\@discordjs\opus\prebuild\node-v88-napi-v3-win32-x64-unknown-unknown --napi_version=7 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using node-pre-gyp@0.2.0
npm ERR! node-pre-gyp info using node@15.8.0 | win32 | x64
npm ERR! node-pre-gyp WARN Using needle for node-pre-gyp https download
npm ERR! node-pre-gyp info check checked for "C:\Users\USER\Desktop\HappyMusic\node_modules\@discordjs\opus\prebuild\node-v88-napi-v3-win32-x64-unknown-unknown\opus.node" (not found)
npm ERR! node-pre-gyp http GET https://github.com/discordjs/opus/releases/download/v0.4.0/opus-v0.4.0-node-v88-napi-v3-win32-x64-unknown-unknown.tar.gz
npm ERR! node-pre-gyp http 404 https://github.com/discordjs/opus/releases/download/v0.4.0/opus-v0.4.0-node-v88-napi-v3-win32-x64-unknown-unknown.tar.gz
npm ERR! node-pre-gyp WARN Tried to download(404): https://github.com/discordjs/opus/releases/download/v0.4.0/opus-v0.4.0-node-v88-napi-v3-win32-x64-unknown-unknown.tar.gz
npm ERR! node-pre-gyp WARN Pre-built binaries not found for @discordjs/opus@0.4.0 and node@15.8.0 (node-v88 ABI, unknown) (falling back to source compile with node-gyp)
npm ERR! node-pre-gyp http 404 status code downloading tarball https://github.com/discordjs/opus/releases/download/v0.4.0/opus-v0.4.0-node-v88-napi-v3-win32-x64-unknown-unknown.tar.gz
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@15.8.0 | win32 | x64
npm ERR! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@15.8.0 | win32 | x64
npm ERR! gyp info find Python using Python version 3.9.0 found at "F:\python.exe"
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS msvs_version not set from command line or npm config
npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
npm ERR! gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details
npm ERR! gyp ERR! find VS looking for Visual Studio 2015
npm ERR! gyp ERR! find VS - not found
npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS **
npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload.
npm ERR! gyp ERR! find VS For more information consult the documentation at:
npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
npm ERR! gyp ERR! find VS **
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use
npm ERR! gyp ERR! stack at VisualStudioFinder.fail (F:\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
npm ERR! gyp ERR! stack at F:\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16
npm ERR! gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (F:\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
npm ERR! gyp ERR! stack at F:\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14
npm ERR! gyp ERR! stack at F:\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:372:16
npm ERR! gyp ERR! stack at F:\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
npm ERR! gyp ERR! stack at F:\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
npm ERR! gyp ERR! stack at ChildProcess.exithandler (node:child_process:334:5)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:378:20)
npm ERR! gyp ERR! stack at maybeClose (node:internal/child_process:1067:16)
npm ERR! gyp ERR! System Windows_NT 10.0.19041
npm ERR! gyp ERR! command "F:\node.exe" "F:\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "configure" "--fallback-to-build" "--module=C:\Users\USER\Desktop\HappyMusic\node_modules\@discordjs\opus\prebuild\node-v88-napi-v3-win32-x64-unknown-unknown\opus.node" "--module_name=opus" "--module_path=C:\Users\USER\Desktop\HappyMusic\node_modules\@discordjs\opus\prebuild\node-v88-napi-v3-win32-x64-unknown-unknown" "--napi_version=7" "--node_abi_napi=napi" "--napi_build_version=3" "--node_napi_label=napi-v3"
npm ERR! gyp ERR! cwd C:\Users\USER\Desktop\HappyMusic\node_modules\@discordjs\opus
npm ERR! gyp ERR! node -v v15.8.0
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok
npm ERR! node-pre-gyp ERR! build error
npm ERR! node-pre-gyp ERR! stack Error: Failed to execute 'F:\node.exe F:\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\Users\USER\Desktop\HappyMusic\node_modules\@discordjs\opus\prebuild\node-v88-napi-v3-win32-x64-unknown-unknown\opus.node --module_name=opus --module_path=C:\Users\USER\Desktop\HappyMusic\node_modules\@discordjs\opus\prebuild\node-v88-napi-v3-win32-x64-unknown-unknown --napi_version=7 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
npm ERR! node-pre-gyp ERR! stack at ChildProcess.
npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\USER\AppData\Local\npm-cache_logs\2021-02-05T11_33_12_104Z-debug.log
@RockKingdom 安裝不了可以試試用這個" npm install opusscript ", 我自己也是裝不了" npm install @discordjs/opus " 改裝另一個就可以
" npm install ffmpeg-static " 在ubuntu20.04會一直安裝失敗, 用這個網站的安裝方法(https://www.vultr.com/docs/how-to-install-the-latest-static-build-of-ffmpeg) 下去安裝有成功, 但音樂播到一半(約3分鐘)就不會繼續了
// 把音量降 50%,不然第一次容易被機器人的音量嚇到 QQ this.dispatcher[guildID].setVolume(0.2);
可以使用其他指令 但是音量設定沒有成功耶
@hmes98318 之前我也遇過這樣的情況,音樂播起來很卡,而且超過一定時間就會停止播放 後來用同樣的程式碼測試,突然就正常了。播放很順暢,也不會突然停止 猜測可能跟當下的網路環境有關,換個網路試試看
@a25814740 setVolume() 這個方法不是調整機器人的使用者音量,而是播放的音量~ 也就是說從 DC 的使用者介面是看不出來有調整過的 如果用 setVolume(0.1) 和 setVolume(1) 下去比較的話,就可以感覺出差別
$ node discord.js C:\Users\user\Desktop\disocrd bot\discord.js:21 const { token } = require('./token.json'); ^
SyntaxError: Identifier 'token' has already been declared ?[90m at wrapSafe (internal/modules/cjs/loader.js:979:16)?[39m ?[90m at Module._compile (internal/modules/cjs/loader.js:1027:27)?[39m ?[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:1 0)?[39m ?[90m at Module.load (internal/modules/cjs/loader.js:928:32)?[39m ?[90m at Function.Module._load (internal/modules/cjs/loader.js:769:14)?[39m ?[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_ma in.js:72:12)?[39m ?[90m at internal/main/run_main_module.js:17:47?[39m
@white887 看起來是 token 被重複宣告了,檢查一下程式碼吧~
放歌的時候完全沒有聲音呢@@
@arbius1008
程式碼有修改過嗎?
有錯誤訊息嗎?
如果都沒有的話,檢查一下機器人的使用者音量看看
會撥到下一首的時候,撥放清單就完全被清掉了
發現在套件完全沒有更新的情況下,會遇到放歌沒有聲音的問題 正在找尋問題和解法 Q__Q 有新進度會再上來更新
想請問一下如果中文顯示部分變亂碼要怎麼改善?
@EKoublier 是指機器人在DC發言出現亂碼嗎?
@B-l-u-e-b-e-r-r-y 是的不好意思,沒有把問題講清楚;是在 Discord機器人於指令接收後,反饋在文字頻道中會出現亂碼問題。
@EKoublier 試試看用記事本打開 discord.js 檔案,看右下角是不是 UTF-8 的格式 如果是不是 UTF-8,就另存為 UTF-8 的格式,再試著運行看看 不過我不是很確定是不是編碼問題,因為沒有遇到過 Orz
請問以下代碼是發生什麽事了QAQ
node:internal/modules/cjs/loader:1154 throw err; ^
SyntaxError: c:\Users\macyc\new\config.json: Unexpected end of JSON input
at parse (
@macychan1
config.json 語法錯誤
你有修改過 config.json 檔嗎?
有的話,注意引號要用 "
而不是 '
沒有的話檢查檔案是否為下面內容
{
"prefix": "!!"
}
請問大大,播放音樂一定要用網址嗎?可不可以直接搜尋
請問這個錯誤碼是發生甚麼事? playMusic(msg, guildID, musicInfo) ;{ ^
ReferenceError: playMusic is not defined
at Object.
請問大大 有沒有辦法讓這機器人在幾個地方同時播放歌呢?🙏
Albert@MacBook-Pro-2014 codes % node discord1.js node:internal/modules/cjs/loader:944 throw err; ^
Error: Cannot find module '/Users/Albert/codes/discord1.js' at Function.Module._resolveFilename (node:internal/modules/cjs/loader:941:15) at Function.Module._load (node:internal/modules/cjs/loader:774:27) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12) at node:internal/main/run_main_module:17:47 { code: 'MODULE_NOT_FOUND', requireStack: [] } 請問這是怎麼回事?
@Chestnut5113 就只要在要播放的群組加入就行了 但是越多地方同時放歌會越當喔(除非你電腦好)
@Linecat0305 A群先放機器人進去 能播歌 不過再在B群放機器人就顯示 歌曲加入隊列🤔 而且也沒有在A群播完後才開始播
🤔🤔這我就不清楚了,你可能得諮詢更專業人員QQ
@RainWolf0603 以目前安裝的模組來說沒辦法,你可以再加入 node-ytsr 這個模組試著寫看看
@dfewyfhcvjdsye 看起來是這邊多一個分號導致的錯誤,去掉應該就 OK
playMusic(msg, guildID, musicInfo) ";" {
@Chestnut5113 本來是預計有這個功能,但沒有特別去測試,看到你的留言才發現我有個地方寫錯 Orz 已經把更新後的程式碼修改在文中和 Github Repo 了~
@Linecat0305
看起來是執行指令的目錄沒有 discord1.js 檔案
要先切換到你放程式碼的目錄才可以~
cd C:\程式碼目錄
@B-l-u-e-b-e-r-r-y 感謝大大~
還有一個問題,就是當歌沒播完就DC機器人,下次再!!play他的話會是 歌曲加入隊列🤔
@B-l-u-e-b-e-r-r-y 一切正常但是沒聲音 音量也確認過了
C:\Users\Sean su\Desktop\can you tm work\node_modules\discord.js\src\client\voice\VoiceConnection.js:296 this.emit('failed', new Error(reason)); ^
Error [VOICE_CONNECTION_TIMEOUT]: Connection not established within 15 seconds.
at VoiceConnection.authenticateFailed (C:\Users\Sean su\Desktop\can you tm work\node_modules\discord.js\src\client\voice\VoiceConnection.js:296:27)
at C:\Users\Sean su\Desktop\can you tm work\node_modules\discord.js\src\client\voice\VoiceConnection.js:324:61
at Timeout.
}
後台
請問一下 我貼上連結後跑出錯誤 可以麻煩幫我看一下嗎
MinigetError: Status code: 404
at ClientRequest.
讓機器人上限的時候出現了這個 internal/modules/cjs/loader.js:905 throw err; ^
Error: Cannot find module 'discord.js' Require stack:
@SodaSean12 @su3cl3
Hi,可能是因為 Youtube 更新了 API,導致 node-ytdl-core 已經不起作用
可以參考這個 issue MinigetError: input stream: Status code: 404
目前只能等他們發布新版本
一旦他們發布新版本,就試著更新套件(指令:npm install ytdl-core@latest
)看看能不能正常運作
@Chestnut5113 Hi,是指歌還沒播完的時候就停止程式嗎? 有點看不太懂 XD
@lance6666
Hi,看起來是因為沒有安裝 discord.js 套件
npm i discord.js
請問為什麼他一直說我的token無效
@han-han030 token 是要在OAuth2 >Client Secret 按click to reveal🤔
【用 JS 寫一個 Discord Bot!】02 音樂機器人 - 一顆藍莓
前端工程師與她的筆記們
https://b-l-u-e-b-e-r-r-y.github.io/post/DiscordBot02/