String Replacers

If the value fetched in the getValue method is a string, you should use an array to list the replacers you want to use. Say we have the message.json key value pair below. The replacer in the example will be REPLACER.

// ./message.json
{
"en": {
...defaultValues,
"SOME_VALUE": "This is a replacer value from message.json. Replace here -> {REPLACER}"
}
}

We can go ahead and fetch this value just like before, but instead of leaving an empty array as the last parameter, we can fill it out with the information needed to replace the value with a different value.

JavaScript
TypeScript
JavaScript
// ./commands/Ping.js
const { Command, Validator } = require("cdcommands");
module.exports = new Command({
...commandOptions,
run: ({ message, args, client, prefix, language }) => {
const message_json_response = client.defaultResponses.getValue(
"en",
"SOME_VALUE",
"",
[
{
key: "REPLACER",
replace: "This is the replaced value!",
},
],
);
return message.channel.send(message_json_response);
},
});
TypeScript
// ./commands/Ping.ts
import { Command, Validator } from "cdcommands";
export default new Command({
...commandOptions,
run: ({ message, args, client, prefix, language }) => {
const message_json_response = client.defaultResponses.getValue(
"en",
"SOME_VALUE",
"",
[
{
key: "REPLACER",
replace: "This is the replaced value!",
},
],
);
return message.channel.send(message_json_response);
},
});

The above snippet of code should respond with something along the lines of This is a replacer value from message.json. Replace here -> This is the replaced value!. You are allowed to include as many replacers as needed, but usually only one is needed. There are some provided replacers that intellisense will try to recommend to you, none of them are required to be used, you can use whatever replacer value you want to.