Adding code comments

Introduction

Comments are parts of the code that don't get executed.

Why do I need comments?

Comments come in handy in a few situations:

  • Annotating - they can describe what a specific part of the code does
  • Testing - you can temporarily disable a single section to test a different part
  • Documenting - comments can act as a code documentation e.g explain custom functions

With our syntax it's pretty easy to add comments:

// Single Line Comment 

/* Multiple
Lines
Comments
*/

Single line Comment

The first comment type, is a single line one. It can be achieved by placing to slashes on the beginning of the line:

Code

Let's create a code and describe it with a short comment

// this part sums 2 numbers
$let[num1;5]
$let[num2;10]
Result is $sum[$num1;$num2]

Output

Now it's time to check if the comment worked fine

Custom Command Bot 07/05/2024
Result is 15

As you see the comment at line 1 didn't appear in the result

Multiple Lines Comment

In some cases you may want to comment out more then one line, or just a specific part of it. You can do that by wrapping the comment with a combination of slashes and asterisks /* Comment */

Code

Let's extend our previous comment with some extra lines:

/* This part
Sums two numbers
num1 and num2
and it send the result 
*/
$let[num1;5]
$let[num2;10]
result is $sum[$num1;$num2]

Output

Here's what the bot returns:

Custom Command Bot 07/05/2024
Result is 15

As you can see it didn't add any extra content despite adding more lines.

Keystroke

When using the dashboard editor, you can hit ctrl + / to automatically comment out selected line(s)