Report command

Here's a step-by-step instruction on how to create a simple report command.

1. Setting trigger

Users are meant to report using a word command !report, so let's set a corresponding trigger

!report trigger

2. Getting user ID

Let's begin by loading the ID of provided user. For that we will use a combination of two functions:

and save them in a $let variable.

// $message[1] returns the first parameter
// $findMember[...;no] returns user id or undefined 
$let[reportedUser;$findMember[$message[1];no]]

3. Loading reason

Users should be able to describe what behavior they want to report, let's save the rest of parameters to a new variable.

$let[reason;$message[2+]]

4. Send report

As we have all data stored and ready, we will procceed to sending the report. For that we will use:

$let[reportsChannel;$channelID[reports]]
$channelSendMessage[$reportsChannel;$mention has reported <@!$reportedUser>, for: $reason.
]

5. Confirmation message

So far, the command is sending a correct message to a different channel. Let's also send a message to the reporting user.

$mention you report has been submitted, thank you for keeping our community safe.

Result

Member05/28/2024
!report @fajfaj breaking server rule #5
Custom Command Bot 05/28/2024
@Member your report has been submitted, thank you for keeping our community safe.

Meanwhile in #reports

Custom Command Bot 05/28/2024
@Member has reported @fajfaj, for breaking server rule #5

🎉 Congrats!

You've passed the course with grade A!