iT邦幫忙

2025 iThome 鐵人賽

DAY 10
0

如果我們訓練好了一個機器人(利用 OpenAI 的 API key),接下來的問題是:要怎麼跟他對話?
我們可以選擇 —— 透過 Discord,把機器人加入到我們的伺服器,直接在頻道裡互動!

(絕對不是因為今天時間不夠寫其他內容才選這題的)


1. 建立應用程式

  1. 前往 👉 Discord Developer Portal
  2. 點擊右上角 New Application
  3. 輸入名稱
  4. 點擊 Create

2. 建立 Bot

  1. 在左側選單點選 Bot
  2. 點擊 Reset Token 重新產生一個新的 Token
    https://ithelp.ithome.com.tw/upload/images/20250923/20178773xIPwY008so.jpg
    https://ithelp.ithome.com.tw/upload/images/20250923/201787731isf7U7rbr.jpg

3. 產生 Bot 邀請連結

  1. 在 左側的OAuth2
    找到 SCOPES 勾選:

    • bot
    • applications.commands (這樣能用 slash 指令 /https://ithelp.ithome.com.tw/upload/images/20250923/2017877363FmhI3hil.jpg
  2. 往下拉到 Bot Permissions 區塊,勾選需要的權限,例如:

    • Send Messages
    • Read Message History
    • Use Slash Commands
      https://ithelp.ithome.com.tw/upload/images/20250923/20178773ZZ7S4T5xL1.jpg
  3. 頁面最下方會自動產生一個 Invite URL,複製並打開,就能把 Bot 加進你的 Discord 伺服器。
    https://ithelp.ithome.com.tw/upload/images/20250923/20178773RopCutpTBL.jpg


4. 啟用 Privileged Gateway Intents

要讓機器人能正確讀取訊息,還需要額外啟用:

  1. 前往 Discord Developer Portal

  2. 選擇你的應用程式 → 點左邊的 Bot

  3. Privileged Gateway Intents 區塊,勾選這三個:

    • Presence Intent(可選)
    • Server Members Intent(可選)
    • Message Content Intent(⚠️ 必須勾!)
      https://ithelp.ithome.com.tw/upload/images/20250923/20178773t8Kp5woTR3.jpg
  4. Save Changes

點擊第三步產生的連結即可讓機器人加入頻道
這樣就能正式進入 Discord 頻道,開始跟大家互動了!
https://ithelp.ithome.com.tw/upload/images/20250923/20178773J81KbZ2CTE.jpg


上一篇
[Day9]Super Claude 初探
系列文
生成式 AI 輔助程式設計:探索 Vibe Coding、Claude 與 Cursor 的新世代開發體驗10
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言