Points
Documentation

Luau Reference

Everything Points adds to Luau, including inputs, triggers, members, the bank, messages and storage, with arguments and return values.

Amounts are always whole numbers. IDs for members, roles and channels are strings, like "123456789012345678". Anything that takes a member also accepts a member object.

Inputs

points.input.<type>(name, label, options?)

Declares a value each server fills in when it installs the automation. Call these at the top level.

FunctionValue in points.inputs
points.input.channelChannel ID
points.input.roleRole ID
points.input.memberMember object
points.input.numberNumber
points.input.integerWhole number
points.input.textString
points.input.booleantrue or false
points.input.choiceThe chosen string
OptionApplies toMeaning
requiredallDefaults to true. An install missing a required input doesn't run.
defaultallThe value used until a server changes it
min, maxnumber, integerAllowed range
maxLengthtextLongest allowed text
choiceschoiceA list of up to 25 strings. Required.

Names follow the usual rules: 1 to 32 lowercase letters, numbers, - and _. Labels can be up to 100 characters.

points.input.channel("announcements", "Where to post results")
points.input.number("rate", "Tax rate in percent", { default = 5, min = 0, max = 100 })
points.input.role("taxed", "Who pays the tax", { required = false })

points.inputs

A read-only table of the install's values, by input name. Optional inputs a server left empty are nil.

local filter = points.inputs.taxed and { role = points.inputs.taxed } or {}

Triggers

points.schedule(name, config, handler)

Runs handler(ctx) at the times in config.cron.

FieldMeaning
cronA five-part cron expression. See Schedules.
timezoneAn IANA timezone like "America/New_York". Defaults to "UTC".

ctx.name is the schedule's name, and ctx.scheduledFor is when the run was meant to happen.

A script can have up to 10 schedules.

points.command(definition, handler)

Adds a slash command to the server and runs handler(ctx) when someone uses it.

FieldMeaning
name1 to 32 lowercase letters, numbers, - and _
description1 to 100 characters
permission"everyone" (default), "moderator" or "admin"
cooldownSeconds each member must wait between uses, up to 86400. Defaults to 0.
optionsUp to 25 options, made with points.option

A script can have up to 10 commands.

The command's ctx has:

FieldMeaning
ctx.memberMember object for the person who used the command
ctx.channelIdID of the channel it was used in
ctx.optionsOption values by name. Member options are member objects, role and channel options are IDs. Optional options left empty are nil.
ctx:reply(message, options?)Replies to the member. Pass { ephemeral = true } to make it visible only to them.

points.option.<type>(name, description?, options?)

Makes a command option.

FunctionValue in ctx.options
points.option.userMember object
points.option.roleRole ID
points.option.channelChannel ID
points.option.integerWhole number
points.option.numberNumber
points.option.stringString
points.option.choiceThe chosen string

Options take required (default true), min and max for numbers, maxLength for strings, and choices for choice options (up to 25, each 1 to 100 characters).

points.option.integer("amount", "How much", { min = 1, max = 10000 })
points.option.choice("side", "Heads or tails", { choices = { "heads", "tails" } })

Members

points.getMember(id)

Returns a member object, or nil if the member isn't in the server.

Member objects

FieldMeaning
member.idThe member's ID
member.balanceTheir balance, kept up to date as the script changes it
member.rolesA list of their role IDs
MethodDoesReturns
member:add(amount)Adds pointsNew balance
member:subtract(amount)Takes points. Fails if they don't have enough.New balance
member:set(amount)Sets their balanceNew balance
member:pay(other, amount)Moves points to another member. Fails if they don't have enough, or if other is themselves.Their new balance
member:hasRole(roleId)Checks a roletrue or false
member:addRole(roleId)Gives a roleNothing
member:removeRole(roleId)Removes a roleNothing
member:items()Lists their shop itemsA list of { id, name, quantity }
member:giveItem(itemId, quantity?)Gives a shop item, up to 100 at once. Defaults to 1.Nothing
member:takeItem(itemId, quantity?)Takes a shop item. Fails if they don't have enough.Nothing

Roles with moderation or admin permissions, roles managed by an integration, and @everyone can't be given or removed.

To find a shop item's ID, add a Give an item block, pick the item, then switch to Code.

Groups of Members

points.members(filter?)

Returns a query for every member that matches the filter. Leave it out to match everyone.

FilterMatches members who
roleHave this role ID
minBalanceHave at least this many points
maxBalanceHave at most this many points
hasItemOwn this shop item ID

Bulk methods change every matching member in one go, with no limit on how many. They return { count, total }: how many members changed and how many points moved.

MethodDoesReturns
query:add(amount)Adds to each member{ count, total }
query:subtract(amount)Takes from each member, stopping at 0{ count, total }
query:set(amount)Sets each member's balance{ count, total }
query:tax(rate)Moves a share of each positive balance into the bank. rate is between 0 and 1, so 0.05 is 5%.{ count, total }
query:count()Counts the membersNumber
query:sum()Adds up their balancesNumber
query:list(limit?)Loads members, highest balance first. Defaults to 100.List of member objects
query:each(fn)Calls fn(member) for each member, highest balance first, up to 1,000Nothing
local result = points.members({ minBalance = 1000 }):tax(0.05)
print(`Taxed {result.count} members for {result.total} points`)

The Bank

FunctionDoesReturns
points.bank.balance()Reads the server bankNumber
points.bank.add(amount)Adds points to the bankNew bank balance
points.bank.subtract(amount)Removes points. Fails if the bank doesn't have enough.New bank balance
points.bank.pay(member, amount)Pays a member from the bank. Fails if the bank doesn't have enough.New bank balance

Messages

points.send(channelId, message, options?)

Posts in a channel of the server. Messages mention members but never roles, @everyone or @here. Pass { mentions = "roles" } to let role mentions ping too.

points.log(message)

Sends to the server's log channels that include the Automations log type. Does nothing if there aren't any.

Message format

A message can be a string, an embed table, or a table with content and embed.

points.send(channelId, "Plain text")

points.send(channelId, {
	title = "Season over",
	description = "Balances have been reset.",
	color = 0x0695F1,
	fields = {
		{ name = "Winner", value = "<@123456789012345678>", inline = true },
		{ name = "Prize", value = "5,000 points", inline = true },
	},
	footer = "See you next month",
})

points.send(channelId, { content = "<@123456789012345678>", embed = { title = "You won" } })
Embed fieldMeaning
titleTitle text
descriptionMain text
colorColor as a number, like 0x0695F1
fieldsA list of { name, value, inline? }
footerFooter text
imageURL of a large image
thumbnailURL of a small image

Use <@id> to mention a member, <@&id> for a role and <#id> for a channel. A run can send up to 5 messages, counting replies and log posts.

Storage

Storage keeps values between runs. Each install has its own storage, so two servers running the same automation don't share it.

FunctionDoesReturns
points.storage.get(key)Reads a valueThe value, or nil
points.storage.set(key, value)Saves a value: a string, number, boolean or table of thoseNothing
points.storage.increment(key, amount?)Adds to a whole number, starting from 0. Defaults to 1.The new value

Each value can be up to 16 KB, and an install can store up to 1,000 keys. Storage changes are undone if the run fails, like everything else.

Output

print(...) writes a line to the run's output, which appears in test results and run history. A run keeps up to 100 lines.

error(message) stops the run and undoes everything it changed.

Need help?