kaiheila
v1.1.6
Published
开黑啦机器人v3 API的收发SDK,基于ECMAScript
Downloads
12
Readme
Kaiheila WebSocket 以及 V3 API 请求收发接口集合
使用示例:
安装:
npm i kaiheila
WebSocket (Bot):
import { KaiheilaWS } from 'kaiheila'
let kaiheiws = new KaiheilaWS({
type: "Bot",
Bot: {
token: ""
},
retry: true
})
kaiheiws.on("Message", r => { console.log(r) })
kaiheiws.connect()
WebSocket (User):
import { KaiheilaWS } from 'kaiheila'
let kaiheiws = new KaiheilaWS({
type: "User",
User: {
auth: ""
},
retry: true
})
kaiheiws.on("Message", r => { console.log(r) })
kaiheiws.connect()
发送消息:
kaiheiws.sendmsg("Hell yeah!", "8815380044828253")
接收机器人自身信息:
kaiheiws.getme().then(r=>{console.log(r)})
接收机器人已加入的服务器:
kaiheiws.getGuilds().then(r=>{console.log(r)})
给予、移除用户对应的角色:
// 给予角色
kaiheiws.setrole("7430659266664661", "3543259271", 40956, "Grant").then(r=>{console.log(r)})
// 移除角色
kaiheiws.setrole("7430659266664661", "3543259271", 40956, "Revoke").then(r=>{console.log(r)})