惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Blog — PlanetScale
Blog — PlanetScale
Y
Y Combinator Blog
G
Google Developers Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
L
LangChain Blog
S
SegmentFault 最新的问题
J
Java Code Geeks
V
Visual Studio Blog
H
Help Net Security
Stack Overflow Blog
Stack Overflow Blog
aimingoo的专栏
aimingoo的专栏
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
Tailwind CSS Blog
Microsoft Azure Blog
Microsoft Azure Blog
博客园_首页
H
Hackread – Cybersecurity News, Data Breaches, AI and More
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - Franky
B
Blog RSS Feed
The Cloudflare Blog
MyScale Blog
MyScale Blog
月光博客
月光博客
Microsoft Security Blog
Microsoft Security Blog
美团技术团队

wuxinhua.com Blog | RSS Feed

写作者与不写作者:AI 时代的思考分水岭 - wuxinhua.com 一文搞懂 Prompt Engineering - wuxinhua.com #30 AI 颠覆我对传统创业团队的认知 - wuxinhua.com 前端面试系列 - 手写代码 - wuxinhua.com #29 微软与 OpenAI 合作内幕 - wuxinhua.com #28 离 30 岁越来越远 - wuxinhua.com Add AI Chatbox to your VitePress document site - wuxinhua.com Building a Blog Subscription and Pusher with AirCode and Resend - wuxinhua.com #27 创始人是公司灵魂的守护者 - wuxinhua.com 快速上手 Midjourney AI 做图 - wuxinhua.com ChatGPT 机器人系列 - 用 JavaScript,五分钟将 Siri 接入 ChatGPT - wuxinhua.com ChatGPT 机器人系列 - 用 JavaScript 五分钟开发一个飞书 ChatGPT 机器人 - wuxinhua.com ChatGPT 机器人系列 - 用 JavaScript 开发企业微信 ChatGPT 聊天应用 - wuxinhua.com #26 SVB 硅谷银行为什么倒闭 - wuxinhua.com #25 人人都可以成为 AI 工程师 - wuxinhua.com #24 关注你身体的变化 - wuxinhua.com #23 Be positive - wuxinhua.com 前端面试系列 - 前端八股文 - wuxinhua.com #22 AI 在殖民,社交媒体在衰退 - wuxinhua.com #21 我了解到的新冠后遗症 - wuxinhua.com #20 关于死亡和告别 - wuxinhua.com #19 永远无法准备好 - wuxinhua.com macOS 前端开发环境配置 - wuxinhua.com 我的 Newsletter 321来信 - wuxinhua.com Node.js 包管理及 npm 依赖安装机制 - wuxinhua.com 知识的碎片(2021) - wuxinhua.com 放弃 newsfeed 拥抱 newsletter - wuxinhua.com 混迹于 Clubhouse 两周后的一些想法🤔 - wuxinhua.com 认识Docker - wuxinhua.com 知识的碎片(2020) - wuxinhua.com
Building your first Discord ChatGPT Bot - wuxinhua.com
Step 2: Setting Scope and Authorization · 2023-05-18 · via wuxinhua.com Blog | RSS Feed

What we'll be building

In this tutorial, I will guide you through building your initial Discord app using JavaScript to interact with ChatGPT via slash commands.

Here's what the finished Discord ChatGPT Bot will look like:

Resources used in this guide

Step 1: Creating an App and Bot

First, you'll need to create an app in the developer portal if you don't have one already:

  1. Go to Discord Developer Portal. (login using your discord account if required). Click on the "New Application" button at the top right. Give your application a name and click "Create"

  1. Copy your Public Key and Application ID, and put them somewhere locally (we'll need these later)

  1. Click on the "Bot" tab on the left side of the screen.Click on the "Add Bot" button on the right. After the bot is created, Reset the token for your bot, and store it somewhere safe as a secret.(we'll need these later)

Once the application and bot is created, Here, you can customize them by adding an icon, description, etc.

Click on OAuth2 in the left sidebar, then select URL Generator.

Add two scopes:

  • applications.commands which allows your app to create commands. bot which adds your bot user.
  • After you select bot, you can also select different permissions for your bot. For now, just check Send Messages.

Copy the GENERATED URL from above, and paste it into your browser. You'll be guided through the installation flow, where you should make sure you're installing your app on a server where you can develop and test it.

After authorized your app, you can head over to your server and see that -> GPT hopped into the server. ✨

Step 3: Get a copy and Deploy

This guide uses AirCode to host code, Before we get a copy, make sure you have a AirCode account.

  1. Go to this Discord ChatGPT Bot Demo. Click on the "Get a copy" button.

  1. You'll be redirected to the Create app page, use the default name or type your own app name, then click "Create".

Paste the Bot token、OpenAI Key、Public Key、Application ID、earlier save from platform into the Environment variables. Make sure they are in the right key value place.

Click on the "Deploy" button to deploy all files, the env changes will take effect online after deployment.

Step 4: Register Command

The project contains a register command script you can use to install the commands, which is defined in register-command.js.

Select register-command.js file, you will find a invoke url as following, Copy the URL and paste it into your browser URL address.

You will register /chatgpt slash command into server.

Step 5: Handling Interactivity

To enable your app to receive slash command requests (and other interactions), Discord needs a public URL to send them.

Select interactions.js file, you will find a invoke URL as following, copy the link.

Back to Discord Applications, on your app's General Information page, there's an Interactive Endpoint URL option, where you can paste your interactions URL copied from AirCode.

Make sure the save is successful.

Test your ChatGPT bot by typing the command "/chatgpt".

Feedback

Join our Discord server for help and discussion.