mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-12 04:55:01 +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
30
backend/src/plugins/Post/commands/EditCmd.ts
Normal file
30
backend/src/plugins/Post/commands/EditCmd.ts
Normal file
|
@ -0,0 +1,30 @@
|
|||
import { postCmd } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "src/pluginUtils";
|
||||
import { formatContent } from "../util/formatContent";
|
||||
|
||||
export const EditCmd = postCmd({
|
||||
trigger: "edit",
|
||||
permission: "can_post",
|
||||
|
||||
signature: {
|
||||
messageId: ct.string(),
|
||||
content: ct.string({ catchAll: true }),
|
||||
},
|
||||
|
||||
async run({ message: msg, args, pluginData }) {
|
||||
const savedMessage = await pluginData.state.savedMessages.find(args.messageId);
|
||||
if (!savedMessage) {
|
||||
sendErrorMessage(pluginData, msg.channel, "Unknown message");
|
||||
return;
|
||||
}
|
||||
|
||||
if (savedMessage.user_id !== pluginData.client.user.id) {
|
||||
sendErrorMessage(pluginData, msg.channel, "Message wasn't posted by me");
|
||||
return;
|
||||
}
|
||||
|
||||
await pluginData.client.editMessage(savedMessage.channel_id, savedMessage.id, formatContent(args.content));
|
||||
sendSuccessMessage(pluginData, msg.channel, "Message edited");
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue