Skip to content

Scripting

shedaniel edited this page Oct 25, 2020 · 14 revisions

Linkie uses graaljs for JavaScript scripting, it is ECMAScript 2020 compliant.

Example Scripts

https://github.com/shedaniel/linkie-discord/tree/master/example-tricks

Contexts

Base Contexts

  • math: Math *DEPRECATED*: directly use the methods
  • system: System *DEPRECATED*: directly use the methods
  • typeof(obj): String << The type of the object
  • number(string): Double << Returns the number from a string
  • range(max): Array << Returns an array of ints from 0 (inclusive) to max (exclusive)
  • range(min, max): Array << Returns an array of ints from min (inclusive) to max (exclusive)
  • equals(obj1, obj2): Boolean
  • deepEquals(obj1, obj2): Boolean
  • copy(obj): Object
  • currentTimeMillis(): Double
  • nanoTime(): Double
  • random(): Double << Random double from 0-1
  • sqrt(number): Double
  • floor(number): Double << Round down
  • ceil(number): Double << Round up
  • pow(base, component): Double
  • abs(number): Double
  • sin(number): Double
  • cos(number): Double
  • tan(number): Double
  • min(number...): Double
  • max(number...): Double
  • any(boolean...): Boolean
  • all(boolean...): Boolean

Contexts via !eval

  • args: String Array
  • message: Message << The message triggering this evaluation
  • channel: Channel << The channel that the message is in

Message

  • delete(): Undefined << Deletes the message
  • author: User / Undefined << Author of the message, undefined if the author no longer exists
  • content: String
  • edit(content): Message << Edits the message and returns the new message
  • editAsEmbed(title, content): Message << Edits the message as embed and returns the new message
  • editAsEmbed(content): Message << Edits the message as embed and returns the new message
  • timestamp: Instant
  • mentionsEveryone: Boolean
  • isPinned: Boolean
  • isTts: Boolean
  • channelId: String
  • guildId: String / Undefined

Channel

  • sendEmbed(title, content): Message << Send an embedded message and returns the new message
  • sendEmbed(content): Message << Send an embedded message and returns the new message
  • sendMessage(content): Message << Send a message and returns the new message
  • id: String << The id of the channel
  • mention: String << A mention of the channel

User

  • username: String << The username of the user
  • discriminator: String << The discriminator of the user
  • discriminatedName: String << The discriminatedName of the user, for example, ApplePie#9999
  • mention: String << A mention of the user
  • id: String << The id of the user
  • isBot: Boolean
  • avatarUrl: Boolean
  • animatedAvatar: Boolean
  • nickname: String / Undefined (If not in guild)
  • joinTime: Instant / Undefined (If not in guild)
  • premiumTime: Instant / Undefined (If not in guild)
  • displayName: String << The username / nickname of the user
  • getPresence(): Presence / Undefined (If not in guild)
  • currentPartySize: Number / Undefined

Presence

  • status: String << The status of the user, could be online, dnd, idle, invisible, offline.
  • activity: Activity / Undefined

Activity

  • createdAt: Instant
  • name: String
  • type: String << The type of the activity, could be playing, streaming, listening, watching, custom.
  • details: String / Undefined
  • applicationId: String / Undefined

Math *DEPRECATED*: directly use the methods

  • random(): Double << Random double from 0-1
  • sqrt(number): Double
  • floor(number): Double << Round down
  • ceil(number): Double << Round up
  • pow(base, component): Double
  • abs(number): Double
  • sin(number): Double
  • cos(number): Double
  • tan(number): Double
  • min(number...): Double
  • max(number...): Double
  • any(boolean...): Boolean
  • all(boolean...): Boolean

System *DEPRECATED*: directly use the methods

  • currentTimeMillis(): Double
  • nanoTime(): Double
Clone this wiki locally