comparison src/private/tools/config_save.txt.luan @ 16:552d6f944acb

add bump
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 01 Nov 2023 17:34:15 -0600
parents 43814e9f5802
children
comparison
equal deleted inserted replaced
15:d0b8e1a8fc69 16:552d6f944acb
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 stringify = Luan.stringify or error()
4 local Parsers = require "luan:Parsers.luan"
5 local json_string = Parsers.json_string or error()
4 local Io = require "luan:Io.luan" 6 local Io = require "luan:Io.luan"
7 local uri = Io.uri or error()
5 local Http = require "luan:http/Http.luan" 8 local Http = require "luan:http/Http.luan"
6 local Config = require "site:/lib/Config.luan" 9 local Config = require "site:/lib/Config.luan"
10 local Logging = require "luan:logging/Logging.luan"
11 local logger = Logging.logger "config_save.txt"
7 12
13
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
8 33
9 return function() 34 return function()
10 local config = Http.request.parameters.config or error() 35 local config = Http.request.parameters.config or error()
11 Config.set(config) 36 Config.set(config)
37 -- set_cmd() don't do this
12 Io.stdout = Http.response.text_writer() 38 Io.stdout = Http.response.text_writer()
13 %>saved<% 39 %>saved<%
14 end 40 end