Quick lookup

Reference Logic Script

All the tables in one place. No explanations — just the names, parameters, and types you need to look up.

Full documentation Open editor
📖 Esta página tem uma nova versão, com uma página dedicada para cada função, classe e evento: acesse a nova documentação em /docs →

Eventos on

EventParametersFires when
messageCreatemessageMessage sent
messageDeletemessageMessage deleted
messageEditmessageMessage edited
memberJoinmemberMember joined
memberLeavememberMember left
memberUpdatememberMember updated
buttonClickinteractionButton clicked
selectMenuinteractionMenu selected
command"nome", message, argsPrefix command
reactionAddemoji, user, messageReaction added
reactionRemoveemoji, user, messageReaction removed
voiceJoinmemberJoined voice channel
voiceLeavememberLeft voice channel
banAdduserUser banned
banRemoveuserBan removed
channelCreatechannelChannel created
channelDeletechannelChannel deleted
💬

Message

getUser() · messageCreate · sendMessage()
Property / MethodTypeDescription
.idstringMessage ID
.contentstringMessage text
.authorobjectAuthor — id, username, isBot…
.channelstringChannel ID
.reply(texto, opts?)functionReplies to the message. opts.embed, opts.components
.edit(texto, opts?)functionEdits the message
.delete()functionDeletes the message
.react(emoji)functionAdds a reaction. E.g.: "👋"
.pin()functionPins the message
.unpin()functionUnpins the message
👤

User

getUser() · message.author
Property / MethodTypeDescription
.idstringUser ID
.usernamestringUsername
.nicknamestringServer nickname
.avatarstringAvatar URL
.rolesarrayRole IDs
.createdAtstringAccount creation date (ISO)
.joinedAtstringServer join date (ISO)
.isBotboolWhether it's a bot
.permissionsstringPermissions bitfield
.send(texto, opts?)functionSends a DM
.addRole(id)functionAdds a role
.removeRole(id)functionRemoves a role
.timeout(ms)functionApplies a timeout in milliseconds
.removeTimeout()functionRemoves timeout
.ban(motivo?)functionBans the user
.kick()functionKicks from the server
📢

Channel

getChannel(id?)
Property / MethodTypeDescription
.idstringChannel ID
.namestringChannel name
.typenumberType (0=text, 2=voice, 5=announcement…)
.categorystringParent category ID
.send(texto, opts?)functionSends a message in the channel
.rename(nome)functionRenames the channel
.lock()functionLocks sending for @everyone
.unlock()functionUnlocks the channel
🏠

Guild

getGuild()
PropertyTypeDescription
.idstringServer ID
.namestringServer name
.memberCountnumberTotal members
.ownerstringOwner's ID
.rolesarrayIDs of all roles
.channelsarrayIDs of all channels
🖱️

Interaction

getInteraction() · buttonClick · selectMenu
Property / MethodTypeDescription
.customIdstringID of the clicked component
.valuesarraySelected values (SelectMenu)
.userIdstringID of whoever triggered the interaction
.user()functionReturns the full User object of whoever triggered the interaction (async)
.reply(texto, opts?)functionReplies. opts.ephemeral, opts.embed, opts.components
.update(texto, opts?)functionUpdates the component's own message (same opts as .reply()) — only works in response to a not-yet-answered buttonClick/selectMenu
.defer(ephemeral?)functionDefers the reply (shows loading)
.edit(texto, opts?)functionEdits the original reply
.followUp(texto, opts?)functionSends a follow-up message
.showModal(modal)ModalOpens a popup form — see the Modal section
🎨

EmbedBuilder

new EmbedBuilder() · Embed()
MethodParameterDescription
.setTitle(v)stringEmbed title
.setDescription(v)stringDescription
.setColor(v)string | numberColor. E.g.: "#A9D6FF", "Blurple", 0x5865F2
.setURL(v)stringTitle URL
.setTimestamp(v?)string | nilTimestamp. nil = now
.setThumbnail(url)stringSmall image (top-right)
.setImage(url)stringLarge image (bottom)
.setAuthor(opts)object{ name, url?, iconURL? }
.setFooter(opts)object{ text, iconURL? }
.addFields(...fields)object[]{ name, value, inline? } — multiple
.setFields(...fields)object[]Replaces all fields
Color names available in setColor()
Default White Aqua Green Blue Yellow Purple LuminousVividPink Fuchsia Gold Orange Red Grey Navy DarkGold DarkOrange Blurple Greyple DarkButNotBlack NotQuiteBlack DarkGreen DarkBlue DarkRed DarkGrey DarkerGrey LightGrey DarkNavy Random
🔘

Button

Button()
MethodParameterDescription
.setLabel(v)stringButton text
.setStyle(v)stringprimary · secondary · success · danger · link
.setCustomId(v)stringPermanent. A fixed ID you choose. Never expires — capture it with on(buttonClick, i => { if (i.customId == "v") ... }). Keeps working even after Ayami restarts.
.onClick(fn, opts?)functionTemporary. Registers the click directly, without needing on(buttonClick). Expires on its own (10min by default). opts: { user: true|"id", ttl: ms }user: true restricts it to the command's author.
.setEmoji(e)stringEmoji. E.g.: "🎉"
.setDisabled(v)boolDisables the button
.setURL(v)stringURL (only with style link)
primary secondary success danger link 🔗
Permanent vs. temporary: use setCustomId for buttons that need to survive restarts (e.g. a fixed panel). Use onClick for single-use buttons tied to a command (e.g. confirm/cancel), with no separate handler needed.
📋

SelectMenu

SelectMenu()
MethodParameterDescription
.setCustomId(v)stringPermanent. A fixed ID — capture it with on(selectMenu, i => { if (i.customId == "v") ... }).
.onClick(fn, opts?)functionTemporary. Registers the selection directly, without on(selectMenu). fn receives the interaction with .values filled in. Expires on its own (10min by default). opts: { user: true|"id", ttl: ms }.
.setPlaceholder(v)stringPlaceholder text
.setMinValues(n)numberMinimum selections
.setMaxValues(n)numberMaximum selections
.addOptions(...opts)object[]{ label, value, description?, emoji? }
📝

Modal

Modal()
MethodParameterDescription
.setTitle(v)stringForm title (max. 45 characters)
.addTextInput(customId, label, opts?)string, string, object?Adds a text field. opts: { style: "short"|"long", placeholder, required, minLength, maxLength, value }
.onSubmit(fn, opts?)function, object?Registers the form submission. fn(interaction, fields)fields holds each field's value by customId. opts: { user: true|"id", ttl: ms }
On the interaction objectParameterDescription
interaction.showModal(modal)ModalOpens the form. modal must have already gone through .onSubmit(fn)
Discord limitation: a Modal only opens in response to an existing interaction (inside on(buttonClick) or on(selectMenu), or in the temporary .onClick() of a Button/SelectMenu) — never from on(command), which is a plain message with no interaction token behind it.
on command("feedback", message, args)
  let btn = Button()
    .setLabel("Dar feedback")
    .onClick(function(interaction)
      let modal = Modal()
        .setTitle("Feedback")
        .addTextInput("nota", "Nota de 1 a 5", { style: "short" })
        .addTextInput("comentario", "Comentário", { style: "long", required: false })
        .onSubmit(function(interaction, fields)
          interaction.reply("Recebido! Nota: " .. fields.nota .. " — " .. fields.comentario)
        end)

      interaction.showModal(modal)
    end)

  message.reply("Clica pra dar feedback:", { components: [btn] })
end
🗄️

db — Global

Scope: server
MethodParametersReturns
db.set(chave, valor)string, any
db.get(chave)stringany | nil
db.has(chave)stringbool
db.delete(chave)string
👤

db.user(user)

Scope: user per server
MethodParametersReturns
.set(chave, valor)string, any
.get(chave)stringany | nil
.has(chave)stringbool
.add(chave, n)string, numbernumber (novo valor)
.sub(chave, n)string, numbernumber (novo valor)
🏠

db.guild()

Scope: server metadata
MethodParametersReturns
.set(chave, valor)string, any
.get(chave)stringany | nil
🔤

Funções de String

FunctionParametersReturns
length(s)stringnumber
contains(s, sub)string, stringbool
replace(s, de, para)string, string, stringstring
split(s, sep)string, stringarray
join(arr, sep)array, stringstring
lower(s)stringstring
upper(s)stringstring
trim(s)stringstring
tostring(v)anystring
tonumber(s)stringnumber
type(v)anystring
🔢

Funções Matemáticas

FunctionParametersReturns
random(min, max)number, numbernumber — integer between min and max
random()number — decimal between 0 and 1
round(n)numbernumber
floor(n)numbernumber
ceil(n)numbernumber
abs(n)numbernumber
max(a, b, …)...numbernumber
min(a, b, …)...numbernumber
📋

Funções de Array & Object

FunctionParametersReturns
push(arr, v)array, anyarray
pop(arr)arrayany — last element
insert(arr, i, v)array, number, anyarray
remove(arr, i)array, numberarray
size(v)array | objectnumber
keys(obj)objectarray of strings
values(obj)objectarray of values
📦

json

FunctionParametersReturns
json.encode(v)anystring — JSON
json.decode(s)stringobject | nil
🛠️

Utilitários

FunctionParametersDescription
print(…)...anyPrints to the Dashboard console
wait(ms)numberWaits N ms. Accumulated max: 30,000ms per run
sendMessage(canal, texto, opts?)string|object, string, object?Sends a message. opts.embed, opts.components
sendDM(user, texto, opts?)string|object, string, object?Sends a direct DM
getUser()Returns the current context's user
getChannel(id?)string?Returns a channel (from context or by ID)
getGuild()Returns the current server
getInteraction()Returns the current interaction
getMessage()Returns the context's message
PREFIXstringConstant with the server's configured command prefix (e.g. "!") — not a function, it's a global variable
runFlow(flowId)string Runs a Logic Builder Flow by ID, sharing the current context's server/channel/user. 🌙 Lua Crescente+
🌐

http

🌙 Lua Crescente+

HTTP requests to outside Discord. Always go through the same security filter: response size limit, timeout, blocking of localhost/private IPs, and a request limit per script run.

FunctionParametersReturns
http.get(url, opts?)string, object?{ ok, status, headers, body, json, text }
http.post(url, body?, opts?)string, any?, object?
http.put(url, body?, opts?)string, any?, object?
http.patch(url, body?, opts?)string, any?, object?
http.delete(url, opts?)string, object?

opts.headers accepts a custom headers object in every method. On servers without this feature unlocked, calling any http method throws an error explaining which plan is required.

🪝

webhook

🌙 Lua Crescente+
FunctionParametersReturns
webhook.send(url, texto, opts?) string, string, object? { ok, status }

Sends a message via a Discord Webhook (external URL). opts.username, opts.avatarUrl, and opts.embed are optional.

⏱️

Tempo

Persisted — survives restarts

Every time parameter below accepts 3 formats: a number in milliseconds (60000), a duration as text ("1h", "30m", "10s", "2d"), or a fixed time in "HH:MM" format (e.g. "9:00") — in which case it runs the next time that time comes around.

FunctionParametersDescription
schedule(tempo, canal, texto, opts?) number|string, string|object, string, object? Schedules a message. Without opts.recurring, it runs once. With { recurring: true }: if time is a time of day ("9:00"), it repeats every day at that time; if it's a duration ("2h"), it repeats every that interval. Returns the schedule's id.
cancelSchedule(id)stringCancels a pending schedule by the id returned by schedule()
listSchedules()Lists this server's pending schedules: { id, channelId, texto, executeAt, recorrente }[]
cooldown(chave, tempo)string, number|stringReturns true if the current user can act now (and marks the cooldown); false if still on cooldown
cooldownRestante(chave)stringMilliseconds remaining on the cooldown with that key for the current user (0 if none)
on command("bomdia", message, args)
  schedule("9:00", message.channel, "☀️ Bom dia!", { recorrente: true })
  message.reply("Agendado pra todo dia às 9h.")
end

on command("lembrar", message, args)
  if not cooldown("lembrar", "1m") then
    message.reply("⏳ Espera um pouco antes de criar outro lembrete.")
    return
  end
  schedule("1h", message.channel, "⏰ Lembrete: " .. args._[0])
  message.reply("Beleza! Te lembro em 1 hora.")
end
⚙️

Operadores

Op.DescriptionExemplo
+Addition2 + 35
-Subtraction10 - 46
*Multiplication3 * 412
/Division10 / 25
%Modulo10 % 31
..Concatenation"Oi ".."Ayami"
Op.Description
==Equal
!=Not equal
<Less than
>Greater than
<=Less than or equal to
>=Greater than or equal to
andLogical AND
orLogical OR
notNegation
📝

Reserved keywords

let const function return if elseif else then end while for in do break continue on import export from and or not true false nil new
🔒

Sandbox Limits

LimitValue
Steps per run50 000
Recursion depth200 levels
Total wait() per run30 000ms
Concurrent scripts per server20
print() outputs per run200 lines
Log TTL7 days
🌌

.logic files per plan

See all plans at /premium
Plan.logic filesFunctions per fileHTTP / Webhook / runFlow/daily bonus
Free615❌ Locked
New Star1540❌ Locked1.5x
Crescent Moon35Unlimited✅ Unlocked2.5x
ConstellationUnlimitedUnlimited✅ Unlocked3.5x

"Functions per file" only counts function/export function declarations at the top level of the file (outside on(...) blocks). HTTP, Webhook, and runFlow() are unlocked from the Crescent Moon plan onward — calling them without the required plan throws an error explaining the minimum plan needed.