13
|
1 local Luan = require "luan:Luan.luan"
|
|
2 local error = Luan.error
|
14
|
3 local stringify = Luan.stringify or error()
|
13
|
4 local Io = require "luan:Io.luan"
|
14
|
5 local uri = Io.uri or error()
|
13
|
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()
|
14
|
10 local Config = require "site:/lib/Config.luan"
|
|
11 local Logging = require "luan:logging/Logging.luan"
|
|
12 local logger = Logging.logger "delete_server.js"
|
13
|
13
|
|
14
|
|
15 return function()
|
|
16 local server_id = Http.request.parameters.server or error()
|
|
17 local server = Server.get_by_id(server_id)
|
|
18 server.owner_discord_id == get_user() or error()
|
14
|
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
|
13
|
36 server.delete()
|
|
37 Io.stdout = Http.response.text_writer()
|
|
38 %>
|
|
39 location.reload();
|
|
40 <%
|
|
41 end
|