Mercurial Hosting > disearch
diff src/delete_server.js.luan @ 13:af2b95854072
add server records
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 30 Oct 2023 21:32:42 -0600 |
parents | |
children | 80105b716a62 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/delete_server.js.luan Mon Oct 30 21:32:42 2023 -0600 @@ -0,0 +1,19 @@ +local Luan = require "luan:Luan.luan" +local error = Luan.error +local Io = require "luan:Io.luan" +local Http = require "luan:http/Http.luan" +local Server = require "site:/lib/Server.luan" +local Utils = require "site:/lib/Utils.luan" +local get_user = Utils.get_user or error() + + +return function() + local server_id = Http.request.parameters.server or error() + local server = Server.get_by_id(server_id) + server.owner_discord_id == get_user() or error() + server.delete() + Io.stdout = Http.response.text_writer() +%> + location.reload(); +<% +end