Compare commits

...

2 Commits

Author SHA1 Message Date
Yessiest f4b84df7a3 Fixed alias description system 2022-07-12 15:26:32 +04:00
Yessiest 22d1b74787 Fixed prefix persistence on aliases 2022-07-03 13:50:14 +04:00
2 changed files with 11 additions and 7 deletions

View File

@ -123,7 +123,7 @@ air.parse = function(string,argmatch,client,guild_id)
for k,v in pairs(tokens) do
if v:match("^%-%-%w+=$") then
local optname = table.remove(tokens,k):match("^%-%-(%w+)=$")
local value = tokens[k]
local value = tokens[k]:match("^[\"']?(.-)[\"']?$")
opts[optname] = value
elseif v:match("^%-%-%w+$") then
local optname = v:match("^%-%-(%w+)$")

View File

@ -22,12 +22,16 @@ for k,v in pairs(command_handler:get_prefixes()) do
end
local function add_alias(name,comm,prefix,description)
local helpmsg = "Alias for ``"..comm.."``"
if description then
helpmsg = helpmsg.."\n"..description
end
if (not aliases[name]) then
log("ALIAS","Adding alias \""..name.."\" for \""..comm.."\"")
config.aliases[name] = {comm = comm,prefix = (prefix == nil)}
config.aliases[name] = {comm = comm,prefix = prefix,description = description}
aliases[name] = command(name,{
help = "Alias for ``"..comm.."``",
usage = ((prefix and globals.prefix) or "")..name,
help = helpmsg,
usage = name,
category = "Aliases",
exec = function(msg,args2,opts)
local str = msg.content:gsub("^%S+ ?","")
@ -42,7 +46,7 @@ local function add_alias(name,comm,prefix,description)
}))
end,
options = {
prefix = (prefix == nil),
prefix = config.aliases[name].prefix,
custom = true
}
})
@ -69,7 +73,7 @@ for k,v in pairs(config.aliases) do
if type(v) == "string" then --legacy format conversion
commdata = {comm = v, prefix = false}
end
add_alias(k,commdata.comm,commdata.prefix)
add_alias(k,commdata.comm,commdata.prefix,commdata.description)
end
local prefix = command("prefix",{
@ -120,7 +124,7 @@ local c_alias = command("alias", {
},
category = "Automation",
exec = function(msg,args,opts)
if add_alias(args[1],args[2],(opts["prefix"] or opts["p"]),opts["description"]) then
if add_alias(args[1],args[2],not (opts["prefix"] or opts["p"]),opts["description"]) then
msg:reply("Bound ``"..args[1].."`` as an alias to ``"..args[2].."``")
else
msg:reply("``"..args[1].."`` is already bound")