2020-07-23 21:26:22 +02:00
|
|
|
import { postCmd } from "../types";
|
2020-10-01 01:43:38 +03:00
|
|
|
import { sorter } from "../../../utils";
|
|
|
|
import { sendErrorMessage } from "../../../pluginUtils";
|
2020-07-23 21:26:22 +02:00
|
|
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
|
|
|
import { postMessage } from "../util/postMessage";
|
|
|
|
|
|
|
|
export const ScheduledPostsShowCmd = postCmd({
|
|
|
|
trigger: ["scheduled_posts", "scheduled_posts show"],
|
|
|
|
permission: "can_post",
|
|
|
|
|
|
|
|
signature: {
|
|
|
|
num: ct.number(),
|
|
|
|
},
|
|
|
|
|
|
|
|
async run({ message: msg, args, pluginData }) {
|
|
|
|
const scheduledPosts = await pluginData.state.scheduledPosts.all();
|
|
|
|
scheduledPosts.sort(sorter("post_at"));
|
|
|
|
const post = scheduledPosts[args.num - 1];
|
|
|
|
if (!post) {
|
2021-01-17 21:21:18 +02:00
|
|
|
sendErrorMessage(pluginData, msg.channel, "Scheduled post not found");
|
|
|
|
return;
|
2020-07-23 21:26:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
postMessage(pluginData, msg.channel as TextChannel, post.content, post.attachments, post.enable_mentions);
|
|
|
|
},
|
|
|
|
});
|