UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

45 lines • 2.19 kB
// ========= Copyright 2026 @ Strukto.AI All Rights Reserved. ========= // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // ========= Copyright 2026 @ Strukto.AI All Rights Reserved. ========= export async function sendMessage(accessor, channelId, text, messageReferenceId, file) { const body = { content: text }; if (messageReferenceId !== undefined && messageReferenceId !== '') { body.message_reference = { message_id: messageReferenceId }; } const endpoint = `/channels/${channelId}/messages`; if (file === undefined) return accessor.transport.call('POST', endpoint, undefined, body); if (accessor.transport.postFiles === undefined) { throw new Error('discord transport does not support file uploads'); } return accessor.transport.postFiles(endpoint, body, [file]); } export async function editMessage(accessor, channelId, messageId, text) { return accessor.transport.call('PATCH', `/channels/${channelId}/messages/${messageId}`, undefined, { content: text, }); } export async function deleteMessage(accessor, channelId, messageId) { await accessor.transport.call('DELETE', `/channels/${channelId}/messages/${messageId}`); } export async function sendPoll(accessor, channelId, question, answers, durationHours = 24, multiselect = false) { return accessor.transport.call('POST', `/channels/${channelId}/messages`, undefined, { poll: { question: { text: question }, answers: answers.map((answer) => ({ poll_media: { text: answer } })), duration: durationHours, allow_multiselect: multiselect, }, }); } //# sourceMappingURL=post.js.map