PostPlugin: don't require channel id for !edit
This commit is contained in:
parent
2f341d97d8
commit
cfc36be127
1 changed files with 8 additions and 8 deletions
|
@ -48,22 +48,22 @@ export class PostPlugin extends Plugin {
|
||||||
/**
|
/**
|
||||||
* Edit the specified message posted by the bot
|
* Edit the specified message posted by the bot
|
||||||
*/
|
*/
|
||||||
@d.command("edit", "<channel:channel> <messageId:string> <content:string$>")
|
@d.command("edit", "<messageId:string> <content:string$>")
|
||||||
@d.permission("edit")
|
@d.permission("edit")
|
||||||
async editCmd(msg, args) {
|
async editCmd(msg, args: { messageId: string; content: string }) {
|
||||||
const message = await this.bot.getMessage(args.channel.id, args.messageId);
|
const savedMessage = await this.savedMessages.find(args.messageId);
|
||||||
|
|
||||||
if (!message) {
|
if (!savedMessage) {
|
||||||
args.channel.createMessage(errorMessage("Unknown message"));
|
msg.channel.createMessage(errorMessage("Unknown message"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.author.id !== this.bot.user.id) {
|
if (savedMessage.user_id !== this.bot.user.id) {
|
||||||
args.channel.createMessage(errorMessage("Message wasn't posted by me"));
|
msg.channel.createMessage(errorMessage("Message wasn't posted by me"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const edited = await message.edit(args.content);
|
const edited = await this.bot.editMessage(savedMessage.channel_id, savedMessage.id, args.content);
|
||||||
await this.savedMessages.saveEditFromMsg(edited);
|
await this.savedMessages.saveEditFromMsg(edited);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue