2022-06-02 00:22:39 +08:00
|
|
|
|
import { createOpenAPI, createWebsocket } from 'qq-guild-bot';
|
2022-06-01 01:55:47 +08:00
|
|
|
|
|
2022-06-02 00:22:39 +08:00
|
|
|
|
import message from './bin/message/index.js'
|
|
|
|
|
|
|
|
|
|
message.$emit("aaa")
|
2022-06-01 01:55:47 +08:00
|
|
|
|
const testConfig = {
|
|
|
|
|
appID: '102011802', // 申请机器人时获取到的机器人 BotAppID
|
|
|
|
|
token: 'YPwwxVTwbOy9ULfvsKpmax2PC4xXr74x', // 申请机器人时获取到的机器人 BotToken
|
|
|
|
|
intents: ['GUILD_MESSAGES','MESSAGE_AUDIT'], // 事件订阅,用于开启可接收的消息类型
|
|
|
|
|
sandbox: true, // 沙箱支持,可选,默认false. v2.7.0+
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 创建 client
|
|
|
|
|
const client = createOpenAPI(testConfig);
|
|
|
|
|
|
|
|
|
|
// 创建 websocket 连接
|
|
|
|
|
const ws = createWebsocket(testConfig);
|
|
|
|
|
// 消息监听
|
|
|
|
|
ws.on('READY', (wsdata) => {
|
|
|
|
|
console.log('[READY] 事件接收 :', wsdata);
|
|
|
|
|
});
|
|
|
|
|
ws.on('ERROR', (data) => {
|
|
|
|
|
console.log('[ERROR] 事件接收 :', data);
|
|
|
|
|
});
|
|
|
|
|
ws.on('GUILDS', (data) => {
|
|
|
|
|
console.log('[GUILDS] 事件接收 :', data);
|
|
|
|
|
});
|
|
|
|
|
ws.on('GUILD_MEMBERS', (data) => {
|
|
|
|
|
console.log('[GUILD_MEMBERS] 事件接收 :', data);
|
|
|
|
|
});
|
|
|
|
|
ws.on('GUILD_MESSAGES', (data) => {
|
|
|
|
|
console.log('[GUILD_MESSAGES] 事件接收 :', JSON.stringify(data));
|
|
|
|
|
client.messageApi.deleteMessage(data.msg.channel_id, data.msg.id, false ).then(({d})=>{
|
|
|
|
|
console.log(d)
|
|
|
|
|
}).catch((err)=>{
|
|
|
|
|
console.log(err)
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
ws.on('GUILD_MESSAGE_REACTIONS', (data) => {
|
|
|
|
|
console.log('[GUILD_MESSAGE_REACTIONS] 事件接收 :', data);
|
|
|
|
|
});
|
|
|
|
|
ws.on('DIRECT_MESSAGE', (data) => {
|
|
|
|
|
console.log('[DIRECT_MESSAGE] 事件接收 :', data);
|
|
|
|
|
});
|
|
|
|
|
ws.on('INTERACTION', (data) => {
|
|
|
|
|
console.log('[INTERACTION] 事件接收 :', data);
|
|
|
|
|
});
|
|
|
|
|
ws.on('MESSAGE_AUDIT', (data) => {
|
|
|
|
|
console.log('[MESSAGE_AUDIT] 事件接收 :', data);
|
|
|
|
|
});
|
|
|
|
|
ws.on('FORUMS_EVENT', (data) => {
|
|
|
|
|
console.log('[FORUMS_EVENT] 事件接收 :', data);
|
|
|
|
|
});
|
|
|
|
|
ws.on('AUDIO_ACTION', (data) => {
|
|
|
|
|
console.log('[AUDIO_ACTION] 事件接收 :', data);
|
|
|
|
|
});
|
|
|
|
|
ws.on('PUBLIC_GUILD_MESSAGES', (data) => {
|
|
|
|
|
console.log('[PUBLIC_GUILD_MESSAGES] 事件接收 :', data);
|
|
|
|
|
});
|