# YT訂閱數通知Discord機器人      [](https://hackmd.io/kLes1yobSLyIWwWQo2JH5A) ## 演示預覽 ### 查看訂閱數,及設定通知頻道  ### 訂閱數通知 當Call Youtube Data API v3 後訂閱數有更新時,會在通知頻道顯示以下訊息  ## 目錄 - [YT訂閱數通知Discord機器人](#yt訂閱數通知discord機器人) - [演示預覽](#演示預覽) - [查看訂閱數,及設定通知頻道](#查看訂閱數及設定通知頻道) - [訂閱數通知](#訂閱數通知) - [目錄](#目錄) - [安裝](#安裝) - [安裝方法](#安裝方法) - [配置檔案](#配置檔案) - [獲取機器人token](#獲取機器人token) - [獲取Google API Key](#獲取google-api-key) - [Prefix 自訂義](#prefix-自訂義) - [欲查詢頻道設置](#欲查詢頻道設置) - [邀請機器人](#邀請機器人) - [啟動機器人](#啟動機器人) - [LICENSE: GNU General Public License v3.0](#license-gnu-general-public-license-v30) ## 安裝 Node.js v16.11 UP - https://nodejs.org/en/ Git - https://git-scm.com/downloads ### 安裝方法 ``` git init git clone https://github.com/Yue030/discord-yt-sub-count.git ``` OR 點選 Code -> Download ZIP  ### 配置檔案 config.json ```json { "token": "", "prefix": "", "google-api": "https://www.googleapis.com/youtube/v3/channels?part=statistics&part=snippet&id={id}&key={key}", "google-api-key": "", "yt-channel-id": "" } ``` **token** > Discord機器人token **prefix** > 指令前綴 **google-api** > Youtube Data API v3 網址 (建議不要去動) > > {id} 將會在執行的時候,自動帶入成 yt-channel-id 屬性 > > {key} 將會在執行的時候,自動帶入成 google-api-key 屬性 **google-api-key** > Google API 金鑰 **yt-channel-id** > 欲查詢訂閱數的頻道 ### 獲取機器人token 請開啟 [Discord Developer Portal](https://discord.com/developers/) 並點選右上角的New Application  輸入Application名稱 (不影響機器人名稱),並點選Create  點選左側Bot  並按下Add Bot  進入到此頁面,你可以在這個時候更改機器人的頭貼及名稱  點選 Token 區塊的 Copy  將複製下來的token在config.json的token屬性的""中貼上 ### 獲取Google API Key 到 [Google Cloud Platform](https://console.developers.google.com/?hl=zh-tw) 建立一個專案  建立過後,打開左邊的選單 找到API和服務,並點選憑證  點選上方 **建立憑證** - **API金鑰**  將獲取到的API金鑰複製起來  將複製下來的金鑰在config.json的google-api-key屬性的""中貼上 #### Prefix 自訂義 更改config.json的prefix屬性 若設置為 "!" 輸入指令時必須輸入 ``` !count !set #(頻道名稱) ``` 才會有效果 若設置為 "M$" 則輸入指令格式為輸入 ``` M$count M$set #(頻道名稱) ``` ### 欲查詢頻道設置 請打開您這個DD仔推的Vtuber的頻道 並在網址處複製頻道ID > 若顯示的是頻道名稱 > > 請點一部影片,再點頭像,才可以看到ID  將複製下來的頻道ID在config.json的yt-channel-id屬性的""中貼上 由於目前設定關係,不好意思 **我們只支援單推** 若您堅持DD,請另外設置機器人,並重複上述所有操作 > 貼心提醒: Google API Key 不可重複使用 ### 邀請機器人 回到 [Discord Developer Portal](https://discord.com/developers/) 並點選剛剛創建的Application 點擊OAuth2  到OAuth2 URL Generator區塊,並點選bot選項  並在下方的BOT PERMISSIONS開啟Adminstrator權限  複製下方連結  並在瀏覽器貼上此連結,選取伺服器後,按下繼續  按下授權  機器人將會進到指定的群組 ## 啟動機器人 開啟命令提示字元(cmd)並切換到機器人檔案的資料夾 輸入 ``` npm install npm start ``` 即可執行 ## LICENSE: [GNU General Public License v3.0](https://opensource.org/licenses/GPL-3.0)
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up