qq-official-bot
Version:
89 lines (88 loc) • 2.39 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ThreadService = void 0;
class ThreadService {
constructor(bot) {
this.bot = bot;
}
/**
* 获取频道帖子列表
*/
async getChannelThreads(channelId) {
try {
const { data } = await this.bot.request.get(`/channels/${channelId}/threads`);
return { success: true, data };
}
catch (error) {
return {
success: false,
error: {
code: error.status || 500,
message: error.message
}
};
}
}
/**
* 获取频道帖子详情
*/
async getChannelThreadInfo(channelId, threadId) {
try {
const { data } = await this.bot.request.get(`/channels/${channelId}/threads/${threadId}`);
return { success: true, data };
}
catch (error) {
return {
success: false,
error: {
code: error.status || 500,
message: error.message
}
};
}
}
/**
* 创建频道帖子
*/
async publishThread(channelId, title, content, format = 3) {
try {
const { data } = await this.bot.request.post(`/channels/${channelId}/threads`, {
title,
content,
format
});
return { success: true, data };
}
catch (error) {
return {
success: false,
error: {
code: error.status || 500,
message: error.message
}
};
}
}
/**
* 删除频道帖子
*/
async deleteThread(channelId, threadId) {
try {
const result = await this.bot.request.delete(`/channels/${channelId}/threads/${threadId}`);
return {
success: true,
data: result.status === 204
};
}
catch (error) {
return {
success: false,
error: {
code: error.status || 500,
message: error.message
}
};
}
}
}
exports.ThreadService = ThreadService;