comparison src/bump.js.luan @ 16:552d6f944acb

add bump
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 01 Nov 2023 17:34:15 -0600
parents
children
comparison
equal deleted inserted replaced
15:d0b8e1a8fc69 16:552d6f944acb
1 local Luan = require "luan:Luan.luan"
2 local error = Luan.error
3 local Time = require "luan:Time.luan"
4 local time_now = Time.now or error()
5 local Io = require "luan:Io.luan"
6 local Http = require "luan:http/Http.luan"
7 local Server = require "site:/lib/Server.luan"
8 local Utils = require "site:/lib/Utils.luan"
9 local get_user = Utils.get_user or error()
10 local Db = require "site:/lib/Db.luan"
11 local run_in_transaction = Db.run_in_transaction or error()
12
13
14 return function()
15 local server_id = Http.request.parameters.server or error()
16 run_in_transaction( function()
17 local server = Server.get_by_id(server_id) or error()
18 server.owner_discord_id == get_user() or error()
19 server.bumped = time_now()
20 server.save()
21 end )
22 Io.stdout = Http.response.text_writer()
23 %>
24 location.reload();
25 <%
26 end