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

Added support for names in Text Splitting functions. #500

Closed
wants to merge 0 commits into from

Conversation

Cyberghxst
Copy link
Contributor

Type

  • Functions: Text Split functions

Dependencies (Third Party Modules) needed: None

Want a credit? Discord tag or other social media link: @Cyberghxst

Referenced Issue: #NaN

Description

According to a suggestion on the Discord server, I added name support for text splitting functions that are NOT BREAKING due to the positioning of the new optional name.
Before submitting this pull request, I did some tests using the following code:

bot.awaitedCommand({
    name: 'venecia',
    code: `
        $log[hello fro venecia command: $message[1]]
    `
})
bot.awaitedCommand({
    name: 'colombo',
    code: `
        $log[hello FROMM colombo command: $message[1]]
    `
})
bot.awaitedCommand({
    name: 'list',
    code: `
        $log[hello FROMM LIST command: $message[1]]
    `
})

bot.readyCommand({
    code: `
        $textSplitMap[venecia;colombo;list;meals]
        $log[$joinSplitText[ - ;meals]]
        $removeTextSplitElement[Carne polaca;meals]
        $log[$joinSplitText[ - ;meals]]
        $removeSplitTextElement[Pizza;meals]
        $log[$joinSplitText[ - ;meals]]
        $editTextSplitElement[3;Patatas;meals]
        $log[$findTextSplitIndex[Papas;meals]]
        $log[$joinSplitText[ - ;meals]]
        $concatTextSplit[Hotdogs;Carne polaca;Pizza;meals]
        $log[$splitText[3;meals]]
        $log[$filterTextSplitElement[P;starts; -uwu- ;meals]]
        $log[$getTextSplitLength[meals]]
        $textSplit[Carne,Ensalada,Papas,Hamburguesa;,;meals]

        $log[\n\n\n]

        $textSplitMap[venecia;colombo;list]
        $log[$joinSplitText[ - ]]
        $removeTextSplitElement[Chango]
        $log[$joinSplitText[ - ]]
        $removeSplitTextElement[Zanate]
        $log[$joinSplitText[ - ]]
        $editTextSplitElement[3;Michu]
        $log[$findTextSplitIndex[Gato]]
        $log[$joinSplitText[ - ]]
        $concatTextSplit[Serpiente;Mono;Chango;Zanate]
        $log[$splitText[3]]
        $log[$filterTextSplitElement[P;starts; -uwu- ]]
        $log[$getTextSplitLength]
        $textSplit[Perro,Pato,Gato,Pájaro,Gusano;,]
    `
})

Getting the expected output:
SCR1
SCR2

I hope this gets accepted. If you have any comments or suggestions, feel free to tell me.

@github-actions github-actions bot added the type: core related to core of aoi.js label Nov 18, 2023
@@ -87,7 +87,7 @@ const Interpreter = async (
data.vars || {},
data.object || {},
["roles", "users", "everyone"],
data.array || [],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're changing into object, this doesn't make sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is since the data inside d.array will be arrays.

@@ -2,7 +2,7 @@ module.exports = async (d) => {
const data = d.util.aoiFunc(d);
if (data.err) return d.error(data.err);

let [index, text] = data.inside.splits;
let [index, text, name = 'main'] = data.inside.splits;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There shouldn't be default of main at all.

let elements = data.inside.splits, name = elements.length < 1 ? 'main' : elements.pop()

// If the split array is not found, returns the command name into the list.
if (!(name in d.array)) elements.push(name), name = 'main';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was fine how it was.

Copy link
Member

@Leref Leref left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: core related to core of aoi.js
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants