Original Message concept & how it works

Original messages can be quite hard to understand at first glance, though, once you get it, you get it! This page is dedicated to explain how it works, and what are the expected behaviors.

Types of Original Messages

In fact, there are two types of original messages, the "original trigger" and the "original response".

What does that mean?

Original Trigger Message

The original trigger is the message sent, that will trigger a response from your application, it is mostly the one the user sends to interact with your app.

Original Response Message

The original response is the first response to a trigger message, it is the original response to a user interacting with your app, making it trigger that "original response".

What can I do with that?

It is a powerful feature that enables you to get and interact both the trigger message and the original response, or sometimes one of them, or both aren't available.

For example, you're making an interaction that uses multiple messages, you can get with the latest message sent the original response, and get, edit or delete it accordingly.

But you can also get the trigger message if you have the original response.

This ease of access enables you to get components that you wouldn't be able to get, to optimize your program and also, to gain a considerable amount of time while making it easier to read.

Methods

Here are the methods you can use that uses this concept:

  • getOriginal -> Get the response (prioritized) or the trigger. (you can still choose specifically which one to get)

  • getOriginals -> Get both, trigger and response.

  • editOriginal -> Edit the original message (only original response can be edited)

  • deleteOriginal -> Delete the original message (response prioritized, can be changed)

Properties & Getters

Here are the properties that makes this concept what it is:

  • isOriginal -> Getter that returns either "trigger", "response" or the boolean state "false".

  • originals.responseID -> ID of the original response.

  • originals.triggerID -> ID of the original trigger message.

Behavior

The behavior is the following:

  • User Message -> getOriginal() -> Error

  • Original response -> getOriginal() -> User Message

  • Response message -> getOriginal() -> Original Response

Example

// Context: Message#content = "User Message"
client.on('messageCreate', async message => {
  if ((await userMessage.member)?.app) return;
  const originalRes = await userMessage.createMessage({ content: "Original Response" });
  const responseMessage = await userMessage.createFollowup({ content: "Response Message" });
  
  // Access Hierarchy:
  // #1 -- User Message
  // #2 --- Original Response
  // #2 ----- Response Message
  // The access is always the parent.
  
  // Behavior:
  console.log(await userMessage.getOriginal()) // Error (no parent original)
  console.log(await originalRes.getOriginal()); // User Message
  console.log(await responseMessage.getOriginal()); // Original Response
  
  // You can also use other methods that are using Original
  // to perform various actions on the original such as editing it, or deleting it
})

Last updated