Mercurial Hosting > disearch
comparison src/delete_server.js.luan @ 14:80105b716a62
start bot
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 31 Oct 2023 23:56:48 -0600 |
parents | af2b95854072 |
children | d0b8e1a8fc69 |
comparison
equal
deleted
inserted
replaced
13:af2b95854072 | 14:80105b716a62 |
---|---|
1 local Luan = require "luan:Luan.luan" | 1 local Luan = require "luan:Luan.luan" |
2 local error = Luan.error | 2 local error = Luan.error |
3 local stringify = Luan.stringify or error() | |
3 local Io = require "luan:Io.luan" | 4 local Io = require "luan:Io.luan" |
5 local uri = Io.uri or error() | |
4 local Http = require "luan:http/Http.luan" | 6 local Http = require "luan:http/Http.luan" |
5 local Server = require "site:/lib/Server.luan" | 7 local Server = require "site:/lib/Server.luan" |
6 local Utils = require "site:/lib/Utils.luan" | 8 local Utils = require "site:/lib/Utils.luan" |
7 local get_user = Utils.get_user or error() | 9 local get_user = Utils.get_user or error() |
10 local Config = require "site:/lib/Config.luan" | |
11 local Logging = require "luan:logging/Logging.luan" | |
12 local logger = Logging.logger "delete_server.js" | |
8 | 13 |
9 | 14 |
10 return function() | 15 return function() |
11 local server_id = Http.request.parameters.server or error() | 16 local server_id = Http.request.parameters.server or error() |
12 local server = Server.get_by_id(server_id) | 17 local server = Server.get_by_id(server_id) |
13 server.owner_discord_id == get_user() or error() | 18 server.owner_discord_id == get_user() or error() |
19 | |
20 local url = "https://discord.com/api/users/@me/guilds/"..server.discord_id | |
21 local config = Config.get() | |
22 local options = { | |
23 method = "DELETE" | |
24 headers = { | |
25 ["User-Agent"] = "fuck you" -- for retarded Cloudflare | |
26 Authorization = "Bot "..config.discord.bot_token | |
27 } | |
28 } | |
29 try | |
30 local result = uri(url,options).read_text() | |
31 catch e | |
32 -- logger.info(stringify(e)) | |
33 e.response_code == 404 or e.throw() | |
34 end | |
35 | |
14 server.delete() | 36 server.delete() |
15 Io.stdout = Http.response.text_writer() | 37 Io.stdout = Http.response.text_writer() |
16 %> | 38 %> |
17 location.reload(); | 39 location.reload(); |
18 <% | 40 <% |