From b4c58854355670ec5e1792064a53a26c2e7da5e2 Mon Sep 17 00:00:00 2001 From: murm Date: Fri, 17 Mar 2023 01:00:59 -0400 Subject: [PATCH] tweak tags cmd, try and fail to fix natives --- commands/tags/tags.js | 55 ++++++++++++++++++++++--------------------- natives/explode.cc | 2 +- natives/reddit.cc | 2 +- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/commands/tags/tags.js b/commands/tags/tags.js index aaae49a..f9d6364 100644 --- a/commands/tags/tags.js +++ b/commands/tags/tags.js @@ -8,7 +8,6 @@ class TagsCommand extends Command { // todo: attempt to not make this file the worst thing that human eyes have ever seen async run() { this.success = false; - if (!this.guild) return "This command only works in servers!"; const cmd = this.type === "classic" ? (this.args[0] ?? "").toLowerCase() : this.optionsArray[0].name; if (!cmd || !cmd.trim()) return "You need to provide the name of the tag you want to view!"; const tagName = this.type === "classic" ? this.args.slice(1)[0] : (this.optionsArray[0].options[0] ?? {}).value; @@ -16,7 +15,7 @@ class TagsCommand extends Command { if (cmd === "create" || cmd === "add") { if (!tagName || !tagName.trim()) return "You need to provide the name of the tag you want to add!"; if (blacklist.includes(tagName)) return "You can't make a tag with that name!"; - const getResult = await database.getTag(this.guild.id, tagName); + const getResult = await database.getTag(this.channel, tagName); if (getResult) return "This tag already exists!"; const result = await database.setTag(tagName, { content: this.type === "classic" ? this.args.slice(2).join(" ") : this.optionsArray[0].options[1].value, author: this.member.id }, this.guild); this.success = true; @@ -24,25 +23,25 @@ class TagsCommand extends Command { return `The tag \`${tagName}\` has been added!`; } else if (cmd === "delete" || cmd === "remove") { if (!tagName || !tagName.trim()) return "You need to provide the name of the tag you want to delete!"; - const getResult = await database.getTag(this.guild.id, tagName); + const getResult = await database.getTag(this.channel, tagName); if (!getResult) return "This tag doesn't exist!"; const owners = process.env.OWNER.split(","); - if (getResult.author !== this.author && !this.member.permissions.has("MANAGE_MESSAGES") && !owners.includes(this.author)) return "You don't own this tag!"; + if (getResult.author !== this.author && !owners.includes(this.author)) return "You don't own this tag!"; await database.removeTag(tagName, this.guild); this.success = true; return `The tag \`${tagName}\` has been deleted!`; } else if (cmd === "edit") { if (!tagName || !tagName.trim()) return "You need to provide the name of the tag you want to edit!"; - const getResult = await database.getTag(this.guild.id, tagName); + const getResult = await database.getTag(this.channel, tagName); if (!getResult) return "This tag doesn't exist!"; const owners = process.env.OWNER.split(","); - if (getResult.author !== this.author && !this.member.permissions.has("MANAGE_MESSAGES") && !owners.includes(this.author)) return "You don't own this tag!"; + if (getResult.author !== this.author && !owners.includes(this.author)) return "You don't own this tag!"; await database.editTag(tagName, { content: this.type === "classic" ? this.args.slice(2).join(" ") : this.optionsArray[0].options[1].value, author: this.member.id }, this.guild); this.success = true; return `The tag \`${tagName}\` has been edited!`; } else if (cmd === "own" || cmd === "owner") { if (!tagName || !tagName.trim()) return "You need to provide the name of the tag you want to check the owner of!"; - const getResult = await database.getTag(this.guild.id, tagName); + const getResult = await database.getTag(this.channel, tagName); if (!getResult) return "This tag doesn't exist!"; const user = this.client.users.get(getResult.author); this.success = true; @@ -58,39 +57,41 @@ class TagsCommand extends Command { } } else if (cmd === "list") { if (!this.channel.permissionsOf(this.client.user.id.toString()).has("EMBED_LINKS")) return "I don't have the `Embed Links` permission!"; - const tagList = await database.getTags(this.guild.id); + const tagList = await database.getTags(this.channel); const embeds = []; const groups = Object.keys(tagList).map((item, index) => { return index % 15 === 0 ? Object.keys(tagList).slice(index, index + 15) : null; }).filter((item) => { return item; }); - for (const [i, value] of groups.entries()) { - embeds.push({ - embeds: [{ - title: "Tag List", - color: 16711680, - footer: { - text: `Page ${i + 1} of ${groups.length}` - }, - description: value.join("\n"), - author: { - name: this.author.username, - iconURL: this.author.avatarURL() - } - }] - }); - } + let output = JSON.stringify(groups.entries()); + // for (const [i, value] of groups.entries()) { + // // embeds.push({ + // // embeds: [{ + // // title: "Tag List", + // // color: 16711680, + // // footer: { + // // text: `Page ${i + 1} of ${groups.length}` + // // }, + // // description: value.join("\n"), + // // author: { + // // name: this.author.username, + // // iconURL: this.author.avatarURL() + // // } + // // }] + // // }); + // } if (embeds.length === 0) return "I couldn't find any tags!"; this.success = true; - return paginator(this.client, { type: this.type, message: this.message, interaction: this.interaction, channel: this.channel, author: this.author }, embeds); + return output; + // return paginator(this.client, { type: this.type, message: this.message, interaction: this.interaction, channel: this.channel, author: this.author }, embeds); } else { let getResult; if (cmd === "random") { - const tagList = await database.getTags(this.guild.id); + const tagList = await database.getTags(this.channel); getResult = tagList[random(Object.keys(tagList))]; } else { - getResult = await database.getTag(this.guild.id, this.type === "classic" ? cmd : tagName); + getResult = await database.getTag(this.channel, this.type === "classic" ? cmd : tagName); } if (!getResult) return "This tag doesn't exist!"; this.success = true; diff --git a/natives/explode.cc b/natives/explode.cc index ae9ba41..2df37e9 100644 --- a/natives/explode.cc +++ b/natives/explode.cc @@ -7,7 +7,7 @@ using namespace vips; char *Explode(string type, string *outType, char *BufferData, size_t BufferLength, ArgumentMap Arguments, size_t *DataSize) { - bool implode = GetArgument(Arguments, "implode"); + bool implode = GetArgumentWithFallback(Arguments, "implode", false); string basePath = GetArgument(Arguments, "basePath"); VOption *options = VImage::option(); diff --git a/natives/reddit.cc b/natives/reddit.cc index 805492c..a09027f 100644 --- a/natives/reddit.cc +++ b/natives/reddit.cc @@ -7,7 +7,7 @@ using namespace vips; char *Reddit(string type, string *outType, char *BufferData, size_t BufferLength, ArgumentMap Arguments, size_t *DataSize) { - string text = GetArgument(Arguments, "text"); + string text = GetArgumentWithFallback(Arguments, "text", ""); string basePath = GetArgument(Arguments, "basePath"); VOption *options = VImage::option()->set("access", "sequential");