mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
tags: add !tag list command
This commit is contained in:
parent
b0cd8762f1
commit
435de37dc8
2 changed files with 25 additions and 1 deletions
|
@ -10,6 +10,14 @@ export class GuildTags extends BaseRepository {
|
||||||
this.tags = getRepository(Tag);
|
this.tags = getRepository(Tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async all(): Promise<Tag[]> {
|
||||||
|
return this.tags.find({
|
||||||
|
where: {
|
||||||
|
guild_id: this.guildId
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async find(tag): Promise<Tag> {
|
async find(tag): Promise<Tag> {
|
||||||
return this.tags.findOne({
|
return this.tags.findOne({
|
||||||
where: {
|
where: {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { errorMessage, successMessage } from "../utils";
|
||||||
import { GuildTags } from "../data/GuildTags";
|
import { GuildTags } from "../data/GuildTags";
|
||||||
|
|
||||||
export class TagsPlugin extends Plugin {
|
export class TagsPlugin extends Plugin {
|
||||||
public static pluginName = 'tags';
|
public static pluginName = "tags";
|
||||||
|
|
||||||
protected tags: GuildTags;
|
protected tags: GuildTags;
|
||||||
|
|
||||||
|
@ -34,6 +34,22 @@ export class TagsPlugin extends Plugin {
|
||||||
this.tags = GuildTags.getInstance(this.guildId);
|
this.tags = GuildTags.getInstance(this.guildId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@d.command("tag list")
|
||||||
|
@d.permission("create")
|
||||||
|
async tagListCmd(msg: Message) {
|
||||||
|
const tags = await this.tags.all();
|
||||||
|
if (tags.length === 0) {
|
||||||
|
msg.channel.createMessage(`No tags created yet! Use \`tag create\` command to create one.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const prefix = this.configValueForMsg(msg, "prefix");
|
||||||
|
const tagNames = tags.map(t => t.tag).sort();
|
||||||
|
msg.channel.createMessage(`
|
||||||
|
Available tags (use with ${prefix}tag): \`\`\`${tagNames.join(", ")}\`\`\`
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
|
||||||
@d.command("tag delete", "<tag:string>")
|
@d.command("tag delete", "<tag:string>")
|
||||||
@d.permission("create")
|
@d.permission("create")
|
||||||
async deleteTagCmd(msg: Message, args: { tag: string }) {
|
async deleteTagCmd(msg: Message, args: { tag: string }) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue