I recently found a npm package called syntax-checker (https://www.npmjs.com/package/syntax-checker)
And i would like to integrate this into my js script. I'm using a Discord chat bot which checks the message for a code block and the coding language. As the description of Syntax checker says, it supports Ruby, PHP, Perl, Lua, C/CPP, Bash, Javascript and Python. How would i integrate this into the bot? I currently use for js checking this script
if (message.content.includes("```js"))
{
let code = message.content.substring('```js '.length);
var codebegin = code.split("```js").pop();
var n = codebegin.indexOf('```');
var codeend = codebegin.substring(0, n != -1 ? n : codebegin.length);
var check = require('syntax-error');
var err = check(codeend);
if (err)
{
message.reply("Your code contains errors! ```" + err + "```");
}
else
{
message.reply("No Errors!");
}
}
via Select
No comments:
Post a Comment