3
|
1 local Luan = require "luan:Luan.luan"
|
|
2 local error = Luan.error
|
|
3 local stringify = Luan.stringify or error()
|
16
|
4 local Parsers = require "luan:Parsers.luan"
|
|
5 local json_string = Parsers.json_string or error()
|
3
|
6 local Io = require "luan:Io.luan"
|
16
|
7 local uri = Io.uri or error()
|
3
|
8 local Http = require "luan:http/Http.luan"
|
|
9 local Config = require "site:/lib/Config.luan"
|
16
|
10 local Logging = require "luan:logging/Logging.luan"
|
|
11 local logger = Logging.logger "config_save.txt"
|
3
|
12
|
|
13
|
16
|
14 local function set_cmd()
|
|
15 local config = Config.get()
|
|
16 local url = "https://discord.com/api/applications/"..config.discord.client_id.."/commands"
|
|
17 local options = {
|
|
18 method = "POST"
|
|
19 headers = {
|
|
20 ["User-Agent"] = "Disearch" -- for retarded Cloudflare
|
|
21 Authorization = "Bot "..config.discord.bot_token
|
|
22 ["Content-Type"] = "application/json"
|
|
23 }
|
|
24 content = json_string{
|
|
25 type = 1
|
|
26 name = "dbump"
|
|
27 description = "Bump this server in Disearch."
|
|
28 }
|
|
29 }
|
|
30 local result = uri(url,options).read_text()
|
|
31 logger.info(result)
|
|
32 end
|
|
33
|
3
|
34 return function()
|
|
35 local config = Http.request.parameters.config or error()
|
|
36 Config.set(config)
|
16
|
37 -- set_cmd() don't do this
|
3
|
38 Io.stdout = Http.response.text_writer()
|
|
39 %>saved<%
|
|
40 end
|