Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parser #509

Closed
wants to merge 16 commits into from
424 changes: 215 additions & 209 deletions src/classes/AoiError.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/classes/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const parsers = require("../handler/parsers.js");

class Util {
static constants = Constants;
static parsers = parsers;
static parsers = { ...parsers.parsers, parsers.errorHandler };

static async getUser(d, id) {
let user = d.client.users.cache.get(id);
Expand Down
26 changes: 15 additions & 11 deletions src/functions/event/interactionEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,31 @@ module.exports = async d => {

let [content = "", embeds = "", components = "", files = "", allowedMentions = "all"] = data.inside.splits;

embeds = await d.util.parsers.EmbedParser(embeds);
const Checker = (theparts, name) => theparts.includes("{" + name + ":");

components = await d.util.parsers.ComponentParser(components, d.client);
embeds = await d.util.parsers.EmbedParser.code(d, { part: embeds, Checker });

files = await d.util.parsers.FileParser(files);
components = await d.util.parsers.ComponentParser.code(d, { part: components, Checker });

allowedMentions = allowedMentions === "all" ? [ "everyone", "users", "roles" ] : (allowedMentions ? allowedMentions?.split(",") : []);
files = await d.util.parsers.FileParser.code(d, { part: files, Checker });

allowedMentions = allowedMentions === "all" ? ["everyone", "users", "roles"] : allowedMentions?.split(",") || [];

await d.data.interaction?.editReply({
content: content.trim() === "" ? " " : content.addBrackets(),
embeds: embeds,
components: components,
files,
allowedMentions: {
parse: allowedMentions
content: content.trim() === "" ? " " : content.addBrackets(),
embeds: embeds,
components: components,
files,
allowedMentions: {
parse: allowedMentions
}
}
}).catch(e => {
).catch(e => {
d.aoiError.fnError(d, 'custom', {}, 'Failed To Reply With Reason: ' + e)
});

return {
code: d.util.setCode(data)
}

}
10 changes: 6 additions & 4 deletions src/functions/event/interactionFollowUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ module.exports = async d => {

let [content = "", embeds = "", components = "", files = "", ephemeral = "false"] = data.inside.splits

embeds = await d.util.parsers.EmbedParser(embeds);
const Checker = (theparts, name) => theparts.includes("{" + name + ":");

components = await d.util.parsers.ComponentParser(components, d.client);
embeds = await d.util.parsers.EmbedParser.code(d, { part: embeds, Checker });

files = await d.util.parsers.FileParser(files);
components = await d.util.parsers.ComponentParser.code(d, { part: components, Checker });

files = await d.util.parsers.FileParser.code(d, { part: files, Checker });

await d.data.interaction?.followUp({
content: content.trim() === "" ? " " : content.addBrackets(),
Expand All @@ -23,4 +25,4 @@ module.exports = async d => {
return {
code: d.util.setCode(data)
}
}
}
14 changes: 8 additions & 6 deletions src/functions/event/interactionReply.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ module.exports = async d => {
const data = d.util.aoiFunc(d);
if (data.err) return d.error(data.err);

let [content = "", embeds = "", components = "", files = "", allowedMentions = "all", ephemeral = "false"] = data.inside.splits
let [content = "", embeds = "", components = "", files = "", allowedMentions = "all", ephemeral = "false"] = data.inside.splits;

embeds = await d.util.parsers.EmbedParser(embeds);
const Checker = (theparts, name) => theparts.includes("{" + name + ":");

components = await d.util.parsers.ComponentParser(components, d.client);
embeds = await d.util.parsers.EmbedParser.code(d, { part: embeds, Checker });

files = await d.util.parsers.FileParser(files);
components = await d.util.parsers.ComponentParser.code(d, { part: components, Checker });

allowedMentions = allowedMentions === "all" ? [ "everyone", "users", "roles" ] : (allowedMentions ? allowedMentions?.split(",") : []);
files = await d.util.parsers.FileParser.code(d, { part: files, Checker });

allowedMentions = allowedMentions === "all" ? [ "everyone", "users", "roles" ] : allowedMentions?.split( "," ) || [];

await d.data.interaction?.reply({
content: content.trim() === "" ? " " : content.addBrackets(),
Expand All @@ -26,4 +28,4 @@ module.exports = async d => {
return {
code: d.util.setCode(data)
}
}
}
13 changes: 7 additions & 6 deletions src/functions/event/interactionUpdate.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@

module.exports = async d => {
const data = d.util.aoiFunc(d);
if (data.err) return d.error(data.err);

let [content = "", embeds = "", components = "", files = ""] = data.inside.splits
let [content = "", embeds = "", components = "", files = ""] = data.inside.splits;

const Checker = (theparts, name) => theparts.includes("{" + name + ":");

embeds = await d.util.parsers.EmbedParser(embeds);
embeds = await d.util.parsers.EmbedParser.code(d, { part: embeds, Checker });

components = await d.util.parsers.ComponentParser(components, d.client);
components = await d.util.parsers.ComponentParser.code(d, { part: components, Checker });

files = await d.util.parsers.FileParser(files);
files = await d.util.parsers.FileParser.code(d, { part: files, Checker });

await d.data.interaction?.update({
content: content.trim() === "" ? " " : content.addBrackets(),
Expand All @@ -23,4 +24,4 @@ module.exports = async d => {
return {
code: d.util.setCode(data)
}
}
}
4 changes: 2 additions & 2 deletions src/functions/interaction/interactionModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = async (d) => {

const [title, customID, components] = data.inside.splits;

const parsedComponents = await d.util.parsers.ComponentParser(components, d.client);
const parsedComponents = await d.util.parsers.ComponentParser.code(d, { part: components, Checker: (theparts, name) => theparts.includes("{"+name+":") });

await d.data.interaction
.showModal({
Expand All @@ -24,4 +24,4 @@ module.exports = async (d) => {
return {
code: d.util.setCode(data),
};
};
};
Loading
Loading