📚
YAGPDB
  • YAGPDB Coding System - Documentation
  • Getting Started
  • Useful Functions
  • Primary Level
    • The Dot and Variables
      • User
      • Guild / Server
      • Member
      • Channel
      • Message
      • Reaction
      • Time
    • Custom Types
    • Functions
      • Type Conversion
      • String Manipulation
      • Math Functions
      • Message Functions
      • Mentions
      • Role Functions
      • Current User
      • Miscellaneous
      • ExecCC
    • Conditional Branching
  • Intermediate Level
  • Database
  • Range Action
  • With Action
  • Custom Embeds
  • Advanced Level
    • Using RegEx
  • Custom Commands Examples
    • Texas Hold'em
Powered by GitBook
On this page
  • Preface
  • Function

Was this helpful?

  1. Primary Level
  2. Functions

Message Functions

After edit the string, you can send a message

Preface

There are many functions about the message, some of which are similar, while others are completely different. For instance, what is the difference between sendMessage and sendMessageNoEscape; what is the difference between addReactions, addResponseReactions, and addMessageReactions?

sendMessage and sendMessageNoEscape are completely different, whereas addReactions, addResponseReactions, and addMessageReactions are almost the same. In conclusion, you need to pay more attention to what features the specific function has and what conditions the specific function need, for once you use the wrong function, all of your codes may be an error, which is very annoying when you are writing complex codes.

Take sendMessage and sendMessageNoEscape for example, {{sendMessage nil "<@&694927266563620913>"}} will not mention the "Teacher" role in the server but will show the mention of it, and {{sendMessage nil "<@&694927266563620913>"}} will mention the Teacher role. If you don't want to be mentioned but you want to see the mention type of the role, consider {{sendMessage}}; otherwise, consider {{sendMessageNoEscape}}.

Function

Function

Description

addMessageReactions channel messageID reactions

addReactions "👍" "👎" ...

Adds each emoji as a reaction to the message that triggered the command (recognizes Unicode emojis and emojiName:emojiID).

addResponseReactions "👍" "👎" ...

Adds each emoji as a reaction to the response message (recognizes Unicode emojis and emojiName:emojiID).

complexMessage "content" args "embed" args "file" args

complexMessageEdit "content" args "embed" args

deleteAllMessageReactions channel messageID

Deletes all reactions pointed message has. channel can be ID, "name" or nil.

deleteMessageReaction channel messageID userID emojis

deleteMessage channel messageID (delay)

deleteResponse (delay)

Deletes the response after a certain time from optional delay argument (max 86400 seconds = 1 day). Defaults to 10 seconds.

deleteTrigger (delay)

Deletes the trigger after a certain time from optional delay argument (max 86400 seconds = 1 day). Defaults to 10 seconds.

editMessage channel messageID newMessageContent

editMessageNoEscape channel messageID newMessageContent

Edits the message in channel and has same logic in escaping characters as sendMessageNoEscape.

getMessage channelID messageID

sendDM "message here"

Sends the user a direct message, only one DM can be sent per custom command (accepts embed objects). YAG will only DM triggering user.

sendMessage channel message

Sends message (string or embed) in channel, channel can be either nil, the channel ID or the channel's "name".

sendMessageNoEscape channel message

Sends message (string or embed) in channel, channel can be either nil, the channel ID or the channel "name". Doesn't escape mentions (e.g. role mentions or @here/@everyone).

sendMessageRetID channel message

sendMessageNoEscapeRetID channel message

Same as sendMessageNoEscape, but also returns messageID to assigned variable for later use.

Example:

  • Sends message to current channel nil and gets messageID to variable $x. Also adds reactions to this message. After 5 seconds, deletes that message. >

    {{$x := sendMessageRetID nil "Hello there!"}} {{addMessageReactions nil $x "👍" "👎"}} {{deleteMessage nil $x 5}}

  • To demonstrate sleep and slightly also editMessage functions. > {{$x := sendMessageRetID nil "Hello"}} {{sleep 3}} {{editMessage nil $x "There"}} {{sleep 3}} {{sendMessage nil "We all know, that"}} {{sleep 3}} YAGPDB rules!

  • To demonstrate usage of complexMessage with sendMessage. {{sendMessage nil (complexMessage "content" "Who rules?" "embed" (cembed "description" "YAGPDB of course!" "color" 0x89aa00) "file" "Here we print something nice - you all are doing awesome!")}}

  • To demonstrate usage of complexMessageEdit with editMessage. {{$mID := sendMessageRetID nil (complexMessage "content" "You know what is..." "embed" (cembed "title" "FUN!?" "color" 0xaa8900))}} {{sleep 3}} {{editMessage nil $mID (complexMessageEdit "embed" (cembed "title" "YAGPDB!" "color" 0x89aa00) "content" "Yes, it's always working with...")}}{{sleep 3}}{{editMessage nil $mID (complexMessageEdit "embed" nil "content" "Embed deleted, goodbye YAG!")}}{{deleteMessage nil $mID 3}}

PreviousMath FunctionsNextMentions

Last updated 5 years ago

Was this helpful?

Same as addReactions or addResponseReactions, but can be used on any messages using its ID. channel can be either nil, channel's ID or its name. Example .

complexMessage creates a so-called bundle of different message fields for sendMessage... functions to send them out all together. Its arguments need to be preceded by predefined keys "content" for regular text, "embed" for embed arguments created by cembed or sdict, "file" for printing out content as a file (max 100 000 characters ~100kB). Example .

Special case for editMessage function - either if complexMessage is involved or works even with regular message. Has two parameters "content" and "embed" to edit regular text part or embed part. If "embed" is set to nil, it deletes whole embed. Example .

Deletes reaction(s) from a message. channel can be ID, "name" or nil. emojis argument can be up to 10 emojis, syntax is emojiName for Unicode/Discord's default emojis and emojiName:emojiID for custom emotes. Example: {{deleteMessageReaction nil (index .Args 1) .User.ID "👍" "👎"}} will delete current user's reactions with thumbsUp/Down emotes from current running channel's message which ID is given to command as first argument (index .Args 1). Also usable with .

Deletes message with given messageID from channel. Channel can be either nil, channel's ID or its name. (delay) is optional and like following two delete functions, it defaults to 10 seconds, max being 1 day or 86400 seconds. Example .

Edits the message in channel, channel can be either nil, channel's ID or "name". Light example .

Returns a object.

Same as sendMessage, but also returns messageID to assigned variable for later use. Example .

here
here
here
here
here
here
Message
Reaction trigger