ts-disc-bot
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

ts-disc-bot

Discord 机器人开发SDK

prepare

  1. 前往 Discord 开发者平台(https://discord.com/developers/applications) 创建应用
  2. 进入刚刚创建的应用,切换到 OAuth2 选项卡下的 URL Generator 勾选如下权限 img_1.png
  3. 复制生成的授权Url,在浏览器打开,将机器人加入到你的频道
  4. 切换 Bot 选项卡,点击Reset Token,并记录下获取到的Bot Tokenimg.png
  5. 为机器人开启 PRESENCE INTENTSERVER MEMBERS INTENTMESSAGE CONTENT INTENTimg_2.png

install

npm i ts-disc-bot

usage

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()

Readme

Keywords

Package Sidebar

Install

npm i ts-disc-bot

Weekly Downloads

2

Version

1.0.2

License

MIT

Unpacked Size

84 kB

Total Files

16

Last publish

Collaborators

  • lc_cn