Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lc-cn/ts-disc-bot
Discord 机器人开发SDK
https://github.com/lc-cn/ts-disc-bot
Last synced: 2 days ago
JSON representation
Discord 机器人开发SDK
- Host: GitHub
- URL: https://github.com/lc-cn/ts-disc-bot
- Owner: lc-cn
- License: mit
- Created: 2023-12-14T09:28:12.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2024-01-05T02:35:07.000Z (11 months ago)
- Last Synced: 2024-10-14T03:50:10.374Z (about 1 month ago)
- Language: TypeScript
- Size: 305 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# ts-disc-bot
Discord 机器人开发SDK
## prepare
1. 前往 `Discord 开发者平台`([https://discord.com/developers/applications](https://discord.com/developers/applications)) 创建应用
2. 进入刚刚创建的应用,切换到 `OAuth2` 选项卡下的 `URL Generator` 勾选如下权限 ![img_1.png](img_1.png)
3. 复制生成的授权Url,在浏览器打开,将机器人加入到你的频道
4. 切换 `Bot` 选项卡,点击`Reset Token`,并记录下获取到的`Bot Token`![img.png](img.png)
5. 为机器人开启 `PRESENCE INTENT`、`SERVER MEMBERS INTENT`、`MESSAGE CONTENT INTENT`![img_2.png](img_2.png)## install
```shell
npm i ts-disc-bot
```
## usage
```javascript
const {Bot, Intents}=require('ts-disc-bot')
const bot=new Bot({
token:'', // prepare 第四步获取到的 Bot Token
intents:Intends.GUILDS|
Intends.GUILD_MEMBERS|
Intends.GUILD_MESSAGES|
Intends.MESSAGE_CONTENT|
Intends.DIRECT_MESSAGE,
proxy:{ // 本地代理,国外用户忽略
host:'127.0.0.1',
port:7890
}
})
bot.on('message.guild',(e)=>{
e.reply('hello world')
})
bot.on('message.direct',(e)=>{
e.reply('hi world')
})
bot.start()
```