mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
Add !source utility command
This commit is contained in:
parent
429653c66d
commit
95cded4d2b
1 changed files with 25 additions and 3 deletions
|
@ -39,7 +39,8 @@ export class UtilityPlugin extends ZeppelinPlugin {
|
|||
server: false,
|
||||
reload_guild: false,
|
||||
nickname: false,
|
||||
ping: false
|
||||
ping: false,
|
||||
source: false
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
|
@ -58,7 +59,8 @@ export class UtilityPlugin extends ZeppelinPlugin {
|
|||
level: ">=100",
|
||||
permissions: {
|
||||
reload_guild: true,
|
||||
ping: true
|
||||
ping: true,
|
||||
source: true
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -165,7 +167,7 @@ export class UtilityPlugin extends ZeppelinPlugin {
|
|||
|
||||
// Create an archive
|
||||
const archiveId = await this.archives.createFromSavedMessages(savedMessages, this.guild);
|
||||
const archiveUrl = `${this.knub.getGlobalConfig().url}/archives/${archiveId}`;
|
||||
const archiveUrl = this.archives.getUrl(this.knub.getGlobalConfig().url, archiveId);
|
||||
|
||||
this.logs.log(LogType.CLEAN, {
|
||||
mod: stripObjectToScalars(mod),
|
||||
|
@ -463,6 +465,26 @@ export class UtilityPlugin extends ZeppelinPlugin {
|
|||
this.bot.deleteMessages(messages[0].channel.id, messages.map(m => m.id)).catch(noop);
|
||||
}
|
||||
|
||||
@d.command("source", "<messageId:string>")
|
||||
@d.permission("source")
|
||||
@d.nonBlocking()
|
||||
async sourceCmd(msg: Message, args: { messageId: string }) {
|
||||
const savedMessage = await this.savedMessages.find(args.messageId);
|
||||
if (!savedMessage) {
|
||||
msg.channel.createMessage(errorMessage("Unknown message"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!savedMessage.data.content) {
|
||||
msg.channel.createMessage(errorMessage("Message content is empty"));
|
||||
return;
|
||||
}
|
||||
|
||||
const archiveId = await this.archives.create(savedMessage.data.content, moment().add(1, "hour"));
|
||||
const url = this.archives.getUrl(this.knub.getGlobalConfig().url, archiveId);
|
||||
msg.channel.createMessage(`Message source: ${url}`);
|
||||
}
|
||||
|
||||
@d.command("reload_guild")
|
||||
@d.permission("reload_guild")
|
||||
reloadGuildCmd(msg: Message) {
|
||||
|
|
Loading…
Add table
Reference in a new issue