Try   HackMD

Discord 動態語音機器人

tags: Python 動態語音

written by 莊智皓 @zhihao



壹-概述

一、介紹

本款Discord 動態語音機器人可讓使用者自行開設語音頻道,緩解伺服器內語音頻道不足的問題。

二、除錯環境

語言:Python 3.9.6 64-bit

編輯器:Visual Studio Code 1.57.1

系統:Windows 10 Pro 21H1

Pip版本:21.1.3

函式庫版本:discord.py 1.7.3

三、發布版本

版本:Release 3.0.0

資料夾大小:21.9MB

運行系統:Windows

貳-部署教學

一、創建一個Discord Bot

1.前往Discord Developer PortalLink

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
他可能會要求你登入Discord,登入後會導向Discord,需要再點擊一次連結前往。

2.點擊右上方的"New Application"創建一個新的應用。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

3.輸入名稱並按下"Create"。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

4.點擊左列的"Bot"選項。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

5.點擊右邊的"Add Bot"。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

6.點及"Yes, do it!"。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

7.在"Build-A-Bot"中可以修改Bot的名稱及頭像,Bot的Token也會在這裡。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
Bot的Token非常重要,有了這串Token就相當於有了Bot的完整控制權限,請務必妥善保管,不可外流,若不慎外流可按下"Regenerate"重新產生一串新的Token。
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

二、邀請Discord Bot至伺服器中

1.前往Discord Developer PortalLink

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
他可能會要求你登入Discord,登入後會導向Discord,需要再點擊一次連結前往。

2.點擊左列的"OAuth2"選項。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

3.向下滑至"OAuth2 URL Generator"

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

4.在"Scopes"中勾選"bot"選項。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

5.在下方"Bot Permissions"選取Bot所需的權限,若不知道要選什麼,則選擇"Administrator"即可。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

6.回到上方的"Scopes"中複製產生出來的網址,並於一個新的頁籤中貼上。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

7.點擊授權並通過驗證後即可在伺服器中看到Bot已加入。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

三、配置文件並啟動

1.下載並解壓縮後,資料夾中會有一個CCH Discord Dynamic Voice Channel Bot.exe,雙擊執行。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

2.執行後會出現配置引導,依照指示輸入即可。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

3.配置完成後若欲更改設置,可修改或直接刪除資料夾內的config.json

※設定嵌入訊息顏色時請將HEX色碼(16進制)轉為DECIMAL色碼(10進制),如00ff40應轉為65344

{ "admin_id": "&859363530419470356", "check_time": 10, "command_channel_id": "", "embed_color": 65344, "embed_icon": "https://cdn.logojoy.com/wp-content/uploads/20210422095037/discord-mascot.png", "log_channel_id": "", "origin_channel_id": 859361082073546755, "prefix": "!", "token": "" }

四、其他說明

1.配置說明

Token:2-1-7所取得的Token。
頻道ID:將"Discord個人設定>進階>開發者模式"開啟後,對著頻道按右鍵就會出現"複製ID"。
身分組ID:將開發者模式打開後,在"伺服器設定>身分組",對著身分組按右鍵也會出現"複製ID"。

2.指令說明

在指令頻道輸入<你設定的前綴> + help(例:!help)會顯示所有指令。

參-下載

一、發布版下載

二、源代碼下載

肆-聯絡開發者及其他

Discord:ΥΕΕ#1899

Mail:xd0931021@gmail.com

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
請將信件標註為重要郵件我才看得到。

開發日誌:

Release 3.0.0
設置更改:
-移除不必要的設置
其他更改:
-將介面改為GUI

Release 2.1.1
其他更改:
-修復已知的錯誤

Release 2.1.0
新增功能:
-對特定使用者隱藏文字頻道
-對特定使用者取消隱藏文字頻道
設置更改:
-help指令的嵌入訊息圖標可於設置檔中更改(預設為Discord圖案)
-help指令的嵌入訊息顏色可於設置檔中更改(預設為65344)
其他更改:
-修復已知的錯誤

Release 2.0.0
新增功能:
-創建語音頻道將附帶文字頻道
程式更改:
-減少發送請求的次數
-減少全域變數
設置更改:
-若有設置缺失,僅會補足缺失的設置項目
-頻道檢查頻率可於設置檔中更改(預設60秒/次)
其他更改:
-修復已知的錯誤

Release 1.2.0
設置更改:
-紀錄頻道ID改為非必要
-指令頻道ID改為非必要
-管理員身分組ID改為非必要
-新增管理員ID,無管理員身分組ID時為必填
後台輸出更改:
-新增自動創建頻道紀錄
-新增自動刪除頻道紀錄
-新增使用者刪除頻道紀錄

Release 1.1.0
程式更改:
-簡化踢出使用者的方法

Release 1.0.0
檔案類型更改:
-將封裝更換為.exe封裝
-設置檔案改為.json

Beta 0.1.0
新增功能:
-幫助清單
-更改頻道名稱
-更改頻道人數上限
-將頻道隱藏
-將頻道取消隱藏
-將頻道上鎖
-將頻道解鎖
-踢出頻道內的使用者
-驅逐頻道內的使用者
-解除驅逐頻道內的使用者
-給予使用者管理權限
-收回使用者的管理權限
-列出該頻道內具有管理權限的使用者
-在所有管理員離開後,要求成為新的管理員
-刪除該頻道
-使用者操作紀錄功能
-系統操作紀錄功能
-系統開機紀錄功能
-系統開機提醒功能
後台輸出更改:
-新增使用者操作紀錄
-新增系統開機紀錄

2021/6/29 17:03
開啟專案

最後編輯:2021/7/16 下午02:12莊智皓