Tags: show tag source when doing just !tag shortcut
This commit is contained in:
parent
d914e8a717
commit
f7f08ffd3b
1 changed files with 18 additions and 0 deletions
|
@ -8,6 +8,8 @@ import moment from "moment-timezone";
|
|||
import humanizeDuration from "humanize-duration";
|
||||
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||
import { renderTemplate } from "../templateFormatter";
|
||||
import { escapeBacktickString } from "jest-snapshot/build/utils";
|
||||
import { GuildArchives } from "../data/GuildArchives";
|
||||
|
||||
const TAG_FUNCTIONS = {
|
||||
countdown(toDate) {
|
||||
|
@ -33,6 +35,7 @@ interface ITagsPluginPermissions {
|
|||
export class TagsPlugin extends ZeppelinPlugin<ITagsPluginConfig, ITagsPluginPermissions> {
|
||||
public static pluginName = "tags";
|
||||
|
||||
protected archives: GuildArchives;
|
||||
protected tags: GuildTags;
|
||||
protected savedMessages: GuildSavedMessages;
|
||||
|
||||
|
@ -65,6 +68,7 @@ export class TagsPlugin extends ZeppelinPlugin<ITagsPluginConfig, ITagsPluginPer
|
|||
}
|
||||
|
||||
onLoad() {
|
||||
this.archives = GuildArchives.getInstance(this.guildId);
|
||||
this.tags = GuildTags.getInstance(this.guildId);
|
||||
this.savedMessages = GuildSavedMessages.getInstance(this.guildId);
|
||||
|
||||
|
@ -120,6 +124,20 @@ export class TagsPlugin extends ZeppelinPlugin<ITagsPluginConfig, ITagsPluginPer
|
|||
msg.channel.createMessage(successMessage(`Tag set! Use it with: \`${prefix}${args.tag}\``));
|
||||
}
|
||||
|
||||
@d.command("tag", "<tag:string>")
|
||||
async tagSourceCmd(msg: Message, args: { tag: string }) {
|
||||
const tag = await this.tags.find(args.tag);
|
||||
if (!tag) {
|
||||
msg.channel.createMessage(errorMessage("No tag with that name"));
|
||||
return;
|
||||
}
|
||||
|
||||
const archiveId = await this.archives.create(tag.body, moment().add(10, "minutes"));
|
||||
const url = this.archives.getUrl(this.knub.getGlobalConfig().url, archiveId);
|
||||
|
||||
msg.channel.createMessage(`Tag source:\n${url}`);
|
||||
}
|
||||
|
||||
async onMessageCreate(msg: SavedMessage) {
|
||||
const member = this.guild.members.get(msg.user_id);
|
||||
if (!this.hasPermission("use", { member, channelId: msg.channel_id })) return;
|
||||
|
|
Loading…
Add table
Reference in a new issue