S
S
Sergey Stadnik2020-05-22 04:58:45
In contact with
Sergey Stadnik, 2020-05-22 04:58:45

How to make code that will copy itself on command?

I have a lot of monotonous code
How to make a command that will copy a certain part of the code, change the given parameters and paste it in a certain place, for example:

Command:
Add text1 text2 Code

will be added to main.js

updates.hear(/текст1/i,(context) => {

return context.send(`текст2`)
})

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Robur, 2020-05-22
@nuriboy

Take some template engine and generate it, work in the same way as with any text file.
But of course, in order to engage in code generation, you need to understand what you are doing. Intuition suggests that there is another case.
In your example, most likely you need an external config in json, where you will add your parameters, and not generate code.

H
HemulGM, 2020-05-22
@HemulGM

The idea is nonsense and idiocy. Excuse me for being direct. Monotonous code is brought under the template, they make a common method and use it once. And you want to nagovnokodit and ask us "How?".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question