view src/private/tools/config_save.txt.luan @ 23:e5c77f8d506d default tip

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 15 Sep 2024 10:45:43 -0600
parents 552d6f944acb
children
line wrap: on
line source

local Luan = require "luan:Luan.luan"
local error = Luan.error
local stringify = Luan.stringify or error()
local Parsers = require "luan:Parsers.luan"
local json_string = Parsers.json_string or error()
local Io = require "luan:Io.luan"
local uri = Io.uri or error()
local Http = require "luan:http/Http.luan"
local Config = require "site:/lib/Config.luan"
local Logging = require "luan:logging/Logging.luan"
local logger = Logging.logger "config_save.txt"


local function set_cmd()
	local config = Config.get()
	local url = "https://discord.com/api/applications/"..config.discord.client_id.."/commands"
	local options = {
		method = "POST"
		headers = {
			["User-Agent"] = "Disearch"  -- for retarded Cloudflare
			Authorization = "Bot "..config.discord.bot_token
			["Content-Type"] = "application/json"
		}
		content = json_string{
			type = 1
			name = "dbump"
			description = "Bump this server in Disearch."
		}
	}
	local result = uri(url,options).read_text()
	logger.info(result)
end

return function()
	local config = Http.request.parameters.config or error()
	Config.set(config)
	-- set_cmd()  don't do this
	Io.stdout = Http.response.text_writer()
	%>saved<%
end