mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
Migrate Post to new Plugin structure
This commit is contained in:
parent
ebcb28261b
commit
5c070643a3
15 changed files with 752 additions and 0 deletions
25
backend/src/plugins/Post/commands/SchedluedPostsDeleteCmd.ts
Normal file
25
backend/src/plugins/Post/commands/SchedluedPostsDeleteCmd.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
import { postCmd } from "../types";
|
||||
import { sorter } from "src/utils";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "src/pluginUtils";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
|
||||
export const ScheduledPostsDeleteCmd = postCmd({
|
||||
trigger: ["scheduled_posts delete", "scheduled_posts d"],
|
||||
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");
|
||||
}
|
||||
|
||||
await pluginData.state.scheduledPosts.delete(post.id);
|
||||
sendSuccessMessage(pluginData, msg.channel, "Scheduled post deleted!");
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue