mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 14:11:50 +00:00
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 humanizeDuration from "humanize-duration";
|
||||||
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
import { ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||||
import { renderTemplate } from "../templateFormatter";
|
import { renderTemplate } from "../templateFormatter";
|
||||||
|
import { escapeBacktickString } from "jest-snapshot/build/utils";
|
||||||
|
import { GuildArchives } from "../data/GuildArchives";
|
||||||
|
|
||||||
const TAG_FUNCTIONS = {
|
const TAG_FUNCTIONS = {
|
||||||
countdown(toDate) {
|
countdown(toDate) {
|
||||||
|
@ -33,6 +35,7 @@ interface ITagsPluginPermissions {
|
||||||
export class TagsPlugin extends ZeppelinPlugin<ITagsPluginConfig, ITagsPluginPermissions> {
|
export class TagsPlugin extends ZeppelinPlugin<ITagsPluginConfig, ITagsPluginPermissions> {
|
||||||
public static pluginName = "tags";
|
public static pluginName = "tags";
|
||||||
|
|
||||||
|
protected archives: GuildArchives;
|
||||||
protected tags: GuildTags;
|
protected tags: GuildTags;
|
||||||
protected savedMessages: GuildSavedMessages;
|
protected savedMessages: GuildSavedMessages;
|
||||||
|
|
||||||
|
@ -65,6 +68,7 @@ export class TagsPlugin extends ZeppelinPlugin<ITagsPluginConfig, ITagsPluginPer
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoad() {
|
onLoad() {
|
||||||
|
this.archives = GuildArchives.getInstance(this.guildId);
|
||||||
this.tags = GuildTags.getInstance(this.guildId);
|
this.tags = GuildTags.getInstance(this.guildId);
|
||||||
this.savedMessages = GuildSavedMessages.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}\``));
|
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) {
|
async onMessageCreate(msg: SavedMessage) {
|
||||||
const member = this.guild.members.get(msg.user_id);
|
const member = this.guild.members.get(msg.user_id);
|
||||||
if (!this.hasPermission("use", { member, channelId: msg.channel_id })) return;
|
if (!this.hasPermission("use", { member, channelId: msg.channel_id })) return;
|
||||||
|
|
Loading…
Add table
Reference in a new issue