In this session of Inventor University, we will go over how to use the Discord Audit Log and it’s related fields then how to listen for only the type(s) of entries we want and perform a different action from there. In this lesson, we will be learning how to use the Send Network Request
and Parse JSON
blocks in relation to the Discord Audit Log
Minimum requirements
Inventor bot with:
- At least 2 free component spaces (4 recommended)
- At least 50 unused storage crates
This is a multi-part tutorial, so you may need to click View the discussion on this topic below to see the full instructions.
Message deleted flow
1) Add a Lookup by Values
block and use the database mentioned in the setup
2) Add an Advanced Conditional
set to any
with Lookup by Values
equals (case insensitive) (leave this blank) and Lookup by Values
equals (case insensitive) “Disabled
”
2.1) Exit flow
3) Get User
and use the Message Edited - Author ID
([[ 0.Author ID ]]
) as the User ID
4) Get Channel
with the Message Edited - Channel ID
([[ 0.Channel ID ]]
) as the ID of the channel to get
5) Create Local Variable
and set the value to the message to display when a user deletes their own message
6) Create a folder. (This is where the Audit Logging API will take place)
6.1) Get Token
block
6.2) Get Current Date and Time
block
6.3) Send Network Request
, type is “GET
” (More info at bottom of this instruction panel)
6.4) Parse JSON
block with the JSON String
being the Response Body from step 5.3 and the Parse Value being: “audit_log_entries[0].id
”
6.5) Parse JSON
block with the JSON String
being the Response Body from step 5.3 and the Parse Value being: “audit_log_entries[0].type
”
6.6) Parse JSON
block with the JSON String
being the Response Body from step 5.3 and the Parse Value being: “audit_log_entries[0].target_id
”
6.7) Parse JSON
block with the JSON String
being the Response Body from step 5.3 and the Parse Value being: “audit_log_entries[0].user_id
”
6.8) Get Snowflake Timestamp
6.9) Math Operations
. Value 1: Get Current Date and Time
, Operation: - (subtraction)
, Value 2: Get Snowflake Timestamp
. Use unix for all
6.10) Advanced Conditional
set to All of the following
6.10.1) Message Deleted - Author ID
equals step 6.6
6.10.2) Step 6.5 equals, 72
6.10.3) Step 6.7 does not equal Message Deleted - Author ID
6.10.4) Step 6.9 less than or equal to 2
If all conditions are met: Update local variable to the message when a mod deletes a message
7) Add a Embed Field Builder
block and set Field 1 as
7.1) Name: Message Content
7.2) Value: Message Deleted - Previous Message Content
([[ 0.Previous Message Content ]]
)
8) Add a Send or Edit Embed Message
and set the channel to the message logging channel from the database and add the Field builder from step 7 into the slot labelled “Field Builder Data
” with the Body of the message being the Local Variable created in step 5
Message Deleted Flow - Step 6.3
Type: GET
URL https://discord.com/api/v10/guilds/[[ 0.Server ID ]]/audit-logs?limit=1
Request Headers User-Agent=Inventor (https://inventor.gg, V1) Authorization=Bot {Get Token - Token}
Replace the {Get Token - Token}
with the value from the Get Token block labelled in step 6.1