@qq-guild-sdk/core
TypeScript icon, indicating that this package has built-in type declarations

2.2.2 • Public • Published

QQ Guild SDK core

qq 频道 SDK 核心库,目前还在开发中,如有问题 issue 汇报。

安装

yarn add qq-guild-sdk@core
# or
npm install qq-guild-sdk@core

使用

import { Bot } from 'qq-guild-sdk@core'
// or
const { Bot } = require('qq-guild-sdk@core')

// 创建 bot
const bot = new Bot({
  app: {
    // 在机器人管理端的 app id
    id: '',
    // 在机器人管理端的 app secret
    key: '',
    // 在机器人管理端的 app token
    token: ''
  }
})

;(async () => {
  // api 请求
  // 获取当前机器人加入的频道列表
  const guilds = await bot.guilds
  console.log(guilds)
  // 启动 wss 连接服务,并设置本次连接权限
  await bot.startClient(Bot.Intents.PUBLIC_GUILD_MESSAGES | Bot.Intents.GUILDS)
  bot.on('ready', () => {
    console.log('Bot is ready.')
  })
  bot.on('message', async (msg) => {
    console.log(msg)
  })
})()

特点

  • 自适应扩展请求 api ,只需要扩展接口即可
declare module '@qq-guild-sdk/core' {
  interface Api {
    newApi(id: string): Promise<Entity>
  }
}
// 用户可随意扩展该接口
bot.newApi('123')

Readme

Keywords

none

Package Sidebar

Install

npm i @qq-guild-sdk/core

Weekly Downloads

7

Version

2.2.2

License

MIT

Unpacked Size

213 kB

Total Files

13

Last publish

Collaborators

  • shigma
  • yijie4188