3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-23 01:25:02 +00:00
zeppelin/backend/src/plugins/Post/commands/ScheduledPostsShowCmd.ts
2020-10-01 01:43:38 +03:00

26 lines
902 B
TypeScript

import { postCmd } from "../types";
import { sorter } from "../../../utils";
import { sendErrorMessage } from "../../../pluginUtils";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { postMessage } from "../util/postMessage";
import { TextChannel } from "eris";
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) {
return sendErrorMessage(pluginData, msg.channel, "Scheduled post not found");
}
postMessage(pluginData, msg.channel as TextChannel, post.content, post.attachments, post.enable_mentions);
},
});