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

Bugs, Features etc. #513

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 6 additions & 25 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ body:
attributes:
value: |
Thanks for taking the time to fill out this bug report! Fill in the blanks by following the steps. 🙌

Please **ensure the following** before reporting a bug:

- ✅ I am using the latest version of aoi.js (v6.6.1).
- ✅ I am using a version of NodeJS (v20.5.1 or newer).

- type: dropdown
id: type
Expand Down Expand Up @@ -39,31 +44,7 @@ body:
}
validations:
required: true

- type: dropdown
id: aoijs-version
attributes:
label: Version of aoi.js
description: What version of aoi.js are you using?
options:
- v6.5.0
- v6.4.0
- v6.3.0
validations:
required: true

- type: dropdown
id: node-version
attributes:
label: Version of Node.js
description: Also, what version of Node.js are you using?
options:
- v16.11.0 (Lowest)
- v18.17.1 (LTS)
- v20.5.1 (Current)
validations:
required: true


- type: textarea
id: excepted
attributes:
Expand Down
25 changes: 9 additions & 16 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
Client:
- any: ['src/structures/Client.ts', 'src/functions/discord/client/*']

Classes:
- src/structures/*

Manager:
- src/manager/*

Core:
- src/core/**/*
# See https://github.com/actions/labeler

Functions:Discord:
- src/functions/discord/**/*

Functions:JS:
- src/functions/js/**/*
'Core':
- src/core/**
- src/classes/**

'Function':
- src/functions/**

'Client':
- src/classes/AoiClient.js
19 changes: 11 additions & 8 deletions .github/workflows/add-feature-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ jobs:
uses: actions/checkout@v2
- name: Find new files in src directory
run: |
NEW_FILES=$(git diff --name-only HEAD^ HEAD)
CHANGED_FILES=()
for file in $NEW_FILES; do
if [[ $file == "src/"* ]]; then
CHANGED_FILES+=("$file")
fi
done
echo "::set-output name=changed_files::${CHANGED_FILES[*]}"
if [ $(git rev-list --count HEAD) -gt 1 ]
then
NEW_FILES=$(git diff --name-only HEAD^ HEAD)
CHANGED_FILES=()
for file in $NEW_FILES; do
if [[ $file == "src/"* ]]; then
CHANGED_FILES+=("$file")
fi
done
echo "::set-output name=changed_files::${CHANGED_FILES[*]}"
fi
id: find-files
- name: Add Feature label
if: ${{ steps.find-files.outputs.changed_files != '' }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install Node v16
- name: Install Node v20.5.1
uses: actions/setup-node@v2
with:
node-version: 16
node-version: 20.5.1
registry-url: https://registry.npmjs.org/

- name: Install dependencies
run: npm ci --ignore-scripts

- name: Deprecate old versions
run: npm deprecate aoi.js@"~6.1.0-dev" "This is no longer supported" || true
run: npm deprecate aoi.js@"~6.6.1-dev" "This is no longer supported" || true
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

Expand Down
6 changes: 3 additions & 3 deletions src/classes/AoiError.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ class AoiError {
if (typeof options === "object") {
options.content = options.content?.toString()?.trim() || " ";
if (options.embeds && typeof options.embeds === "string") {
options.embeds = await EmbedParser(options.embeds);
options.embeds = await EmbedParser(options.embeds, d);
}
if (options.files && typeof options.files === "string") {
options.files = FileParser(options.files);
options.files = FileParser(options.files, d);
}
if (options.components && typeof options.components === "string") {
options.components = await ComponentParser(options.components, client);
options.components = await ComponentParser(options.components, d);
}
} else {
options = {
Expand Down
21 changes: 16 additions & 5 deletions src/core/interpreter.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,17 +406,28 @@ const Interpreter = async (
);
if (client.aoiOptions.suppressAllErrors) {
if (client.aoiOptions.errorMessage) {
if (!message || !message.channel) {
const msg = message;
if (!msg || !msg.channel) {
console.error(client.aoiOptions.errorMessage.addBrackets());
} else {
const {
makeMessageError,
} = require("../classes/AoiError.js");
const message = await Util.errorParser(client.aoiOptions.errorMessage, d);
const { makeMessageError } = require("../classes/AoiError.js");

const result = await Interpreter(
client,
msg ?? data,
args ?? [],
{ name: "parser", code: client.aoiOptions.errorMessage },
client.db,
true,
msg.channel ?? [],
);

const message = await Util.errorParser(result.code ?? client.aoiOptions.errorMessage, d); // (?) support for parser and regular functions

if (!errorOccurred) {
await makeMessageError(client, channel, message.data ?? message, message.options, d);
}

errorOccurred = true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/functions/event/interactionEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ module.exports = async d => {

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

embeds = await d.util.parsers.EmbedParser(embeds);
embeds = await d.util.parsers.EmbedParser(embeds, d);

components = await d.util.parsers.ComponentParser(components, d.client);
components = await d.util.parsers.ComponentParser(components, d);

files = await d.util.parsers.FileParser(files);

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

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

embeds = await d.util.parsers.EmbedParser(embeds);
embeds = await d.util.parsers.EmbedParser(embeds, d);

components = await d.util.parsers.ComponentParser(components, d.client);
components = await d.util.parsers.ComponentParser(components, d);

files = await d.util.parsers.FileParser(files);

Expand Down
4 changes: 2 additions & 2 deletions src/functions/event/interactionReply.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ module.exports = async d => {

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

embeds = await d.util.parsers.EmbedParser(embeds);
embeds = await d.util.parsers.EmbedParser(embeds, d);

components = await d.util.parsers.ComponentParser(components, d.client);
components = await d.util.parsers.ComponentParser(components, d);

files = await d.util.parsers.FileParser(files);

Expand Down
4 changes: 2 additions & 2 deletions src/functions/event/interactionUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ module.exports = async d => {

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

embeds = await d.util.parsers.EmbedParser(embeds);
embeds = await d.util.parsers.EmbedParser(embeds, d);

components = await d.util.parsers.ComponentParser(components, d.client);
components = await d.util.parsers.ComponentParser(components, d);

files = await d.util.parsers.FileParser(files);

Expand Down
24 changes: 12 additions & 12 deletions src/functions/info/reactionCount.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ module.exports = async (d) => {
const [channelID, messageID, emojiResolver] = data.inside.splits;

const channel = await d.util.getChannel(d, channelID);
if (!channel)
return d.aoiError.fnError(d, "channel", {inside: data.inside});
if (!channel) return d.aoiError.fnError(d, "channel", { inside: data.inside });

const message = await d.util.getMessage(channel, messageID);
if (!message)
return d.aoiError.fnError(d, "message", {inside: data.inside});
if (!message) return d.aoiError.fnError(d, "message", { inside: data.inside });

const emoji = message.reactions.cache.find(
(x) =>
x.emoji.id === emojiResolver ||
x.emoji.toString().toLowerCase() ===
emojiResolver.addBrackets().toLowerCase(),
);
if (!emoji) return d.aoiError.fnError(d, "emoji", {inside: data.inside});
let emoji;

data.result = emoji.count;
try {
emoji = message.reactions.cache.find((x) => x.emoji.id === d.util.getEmoji(d, emojiResolver).id)?.count;
} catch {
emoji = message.reactions.cache.find((x) => x.emoji.toString().toLowerCase() === emojiResolver.toLowerCase())?.count;
} finally {
emoji = emoji ?? 0;
}

data.result = emoji;

return {
code: d.util.setCode(data),
Expand Down
70 changes: 41 additions & 29 deletions src/functions/interaction/addButton.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,43 @@
module.exports = async (d) => {
const {code} = d.command;
const inside = d.unpack();
const err = d.inside(inside);
if (err) return d.error(err);
let [index, label, style, custom, disabled = "false", emoji] = inside.splits;
if (isNaN(index) || Number(index) < 1)
d.aoiError.fnError(d, "custom", {inside}, "Invalid Index Provided In");
index = Number(index) - 1;
style = isNaN(style)
? d.util.constants.ButtonStyleOptions[style]
: Number(style);
disabled = disabled === "true";
if (!style || style > 5 || style < 1)
d.aoiError.fnError(d, "custom", {inside}, "Invalid Style Provided In");
if (!d.components[index]) d.components[index] = {type: 1, components: []};
const button = {
label,
type: 2,
style,
disabled,
emoji,
};
button[style === 5 ? "url" : "customId"] = custom;
d.components[index].components.push(button);
return {
code: d.util.setCode({function: d.func, inside, code, result: ""}),
data: { ...d.data, components: Object.assign({}, d.data.components, d.components) },
components: d.components,
};
const data = d.util.aoiFunc(d);
const { code } = d.command;
if (data.err) return d.error(data.err);

let [index, label, style, custom, disabled = "false", emoji] = data.inside.splits;

if (isNaN(index) || Number(index) < 1) return d.aoiError.fnError(d, "custom", { inside: data.inside }, "Index");

index = Number(index) - 1;
style = isNaN(style) ? d.util.constants.ButtonStyleOptions[style] : Number(style);
disabled = disabled === "true";

if (!style || style > 5 || style < 1) return d.aoiError.fnError(d, "custom", { inside: data.inside }, "Style");

try {
emoji = d.util.getEmoji(d, emoji.addBrackets()).id;
} catch {
emoji = emoji?.addBrackets() ?? undefined;
}

const button = {
label,
type: 2,
style,
disabled,
emoji,
};

button[style === 5 ? "url" : "customId"] = custom;

if (!d.components[index]) d.components[index] = { type: 1, components: [] };
d.components[index].components.push(button);

return {
code: d.util.setCode({ function: d.func, inside: data.inside, code }),
data: {
...d.data,
components: Object.assign({}, d.data.components, d.components),
},
components: d.components,
};
};
28 changes: 19 additions & 9 deletions src/functions/interaction/addClientReactions.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
module.exports = async (d) => {
const data = d.util.aoiFunc(d);
if (data.err) return d.error(data.err);
const data = d.util.aoiFunc(d);
if (data.err) return d.error(data.err);

let [...reactions] = data.inside.splits;
let [...reactions] = data.inside.splits;

reactions = reactions.map(x => x.addBrackets()).reverse();
reactions = reactions.map((x) => {
try {
let emoji = d.util.getEmoji(d, x.addBrackets());
x = emoji.id ? `:${emoji.name}:${emoji.id}` : emoji.name;
} catch {
x = x?.addBrackets() ?? undefined;
} finally {
if (x === undefined) return d.util.aoiError.fnError(d, "custom", { inside: data.inside }, "Emoji");
}
return x;
});

data.result = ""
data.result = "";

return {
code: d.util.setCode(data),
reactions,
};
return {
code: d.util.setCode(data),
reactions,
};
};
Loading
Loading