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
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 returns the first parameter // $findMember[...;no] returns user id or undefined $let[reportedUser;$findMember[$message;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.
4. Send report
As we have all data stored and ready, we will procceed to sending the report. For that we will use:
- $channelID - to change channel name to ID
- $channelSendMessage - to send a message to a different channel
$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.
Meanwhile in #reports
You've passed the course with grade A!