mcp-discord-agent-comm
Version:
An MCP server enabling async communication between AI agents and users via Discord - perfect for long-running tasks requiring remote interaction
35 lines • 1.07 kB
JavaScript
export async function getChannel(discord, channelId, defaultChannelId) {
const id = channelId || defaultChannelId;
if (!id) {
throw new Error("No channel ID provided and no default channel configured");
}
const channel = await discord.channels.fetch(id);
if (!channel || !channel.isTextBased()) {
throw new Error(`Channel ${id} not found or is not a text channel`);
}
return channel;
}
export function createSuccessResponse(data) {
return {
content: [
{
type: "text",
text: JSON.stringify({ success: true, ...data }),
},
],
};
}
export function createErrorResponse(error) {
const errorMessage = error?.message === "Timeout"
? "No response received within timeout"
: error?.message || "Unknown error";
return {
content: [
{
type: "text",
text: JSON.stringify({ success: false, error: errorMessage }),
},
],
};
}
//# sourceMappingURL=utils.js.map