Hi, so first thing first I am trying to add a command called !tocm, It basically turns 'inches' 'miles' 'yards' 'foot' into cm and i will be giving the codes in following sections.
It works like this: !tocm <number> <inches> and it responds in santimeters. The thing is i don't know how to add the command in chat, how do i do?
!addcom !tocm $(urlfetch json https://pastebin.com/raw/MmzRtwSA) doesnt work. How do i just collect the codes in one section and make it work?
Appreciate any help, thanks.
Codes:
$(eval
const input = $(query);
const validUnits = ["inch", "inches", "foot", "feet", "yard", "yards", "mile", "miles"];
const unit = input.match(/[a-zA-Z]+/);
const value = parseFloat(input);
if (isNaN(value) !unit !validUnits.includes(unit[0].toLowerCase())) {
"Lütfen geçerli bir uzunluk girişi yapın. Örneğin: !tocm 5 inches";
} else {
const cmValue = (() => {
switch (unit[0].toLowerCase()) {
case "inch":
case "inches":
return value * 2.54;
case "foot":
case "feet":
return value * 30.48;
case "yard":
case "yards":
return value * 91.44;
case "mile":
case "miles":
return value * 160934.4;
}
})();
const kmValue = cmValue / 100000;`${value} ${unit[0]} = ${cmValue} cm = ${kmValue} km`;
}
)