Refactored code for new detection system, now supports sub-files for commands!
parent
0327db322f
commit
c3be53ce45
@ -1,3 +1,5 @@
|
||||
discordia.log
|
||||
gateway.json
|
||||
token.lua
|
||||
launch.json
|
||||
.vscode
|
||||
|
@ -1,27 +0,0 @@
|
||||
local basicCommands = {}
|
||||
|
||||
--Hello World!
|
||||
function basicCommands.helloWorld()
|
||||
return("Hello world!")
|
||||
end
|
||||
|
||||
--Executes Figlet on the host machine.
|
||||
function basicCommands.figlet(string)
|
||||
local figleted = io.popen("figlet ".. string)
|
||||
local result = figleted:read("*all")
|
||||
return result
|
||||
end
|
||||
|
||||
--Executes Cowsay on the host machine.
|
||||
function basicCommands.cowsay(string)
|
||||
local cowsaid = io.popen("cowsay ".. string)
|
||||
local result = cowsaid:read("*all")
|
||||
return result
|
||||
end
|
||||
|
||||
--Takes input and makes it output. GIGO.
|
||||
function basicCommands.echo(string)
|
||||
return string
|
||||
end
|
||||
|
||||
return basicCommands
|
@ -0,0 +1,51 @@
|
||||
local tools = require("./tools.lua")
|
||||
local rng = require("./rng.lua")
|
||||
local complexCommands = {}
|
||||
|
||||
local prefix = 'test!'
|
||||
|
||||
local commands = { -- Define commands its a table that will contain our commands
|
||||
[prefix..'helpme'] = { -- Dumps docs/help to chat, took me forever to figure out.
|
||||
exec = function (message)
|
||||
message.channel:send(tools.printFile("docs/help"))
|
||||
end
|
||||
};
|
||||
[prefix..'roll'] = { -- Rolls a d20, check RNG for more info.
|
||||
exec = function (message)
|
||||
message.channel:send(rng.d20())
|
||||
end
|
||||
};
|
||||
[prefix..'figlet'] = { -- Parrots input to figlet, then echos it to the same channel you are in.
|
||||
exec = function (message)
|
||||
local prefixLength = string.len(prefix)
|
||||
local figletthis = string.sub(message.content, 7+prefixLength)
|
||||
local figlet = tools.figlet(figletthis)
|
||||
local result = "```fix" .. "\n" .. figlet .. "```"
|
||||
message.channel:send(result)
|
||||
end
|
||||
};
|
||||
[prefix..'cowsay'] = { -- Parrots input to cowsay, then echos it to the same channel you are in.
|
||||
exec = function (message)
|
||||
local prefixLength = string.len(prefix)
|
||||
local cowsay = string.sub(message.content, 7+prefixLength)
|
||||
local cowsaid = tools.cowsay(cowsay)
|
||||
local result = "```fix" .. "\n" .. cowsaid .. "```"
|
||||
message.channel:send(result)
|
||||
end
|
||||
};
|
||||
[prefix..'echo'] = { -- Echo's what you said back out, in a fix codeblock. Could be against TOS.
|
||||
exec = function (message)
|
||||
local prefixLength = string.len(prefix)
|
||||
local echo = string.sub(message.content, 5+prefixLength)
|
||||
local echoed = tools.echo(echo)
|
||||
local result = "```fix" .. "\n" .. echoed .. "```"
|
||||
message.channel:send(result)
|
||||
message:delete()
|
||||
end
|
||||
};
|
||||
}
|
||||
|
||||
function complexCommands.initialize()
|
||||
return commands
|
||||
end
|
||||
return complexCommands
|
@ -0,0 +1,48 @@
|
||||
local basicCommands = {}
|
||||
local prefix = "test!"
|
||||
local commands = { -- Define commands its a table that will contain our commands
|
||||
[prefix..'lenny'] = { -- Creates a lenny face
|
||||
exec = function (message)
|
||||
message.channel:send('( ͡° ͜ʖ ͡°)')
|
||||
end
|
||||
};
|
||||
[prefix..'glomp'] = { -- Posts an image of glomping, may add RNG later.
|
||||
exec = function (message)
|
||||
message.channel:send('https://tenor.com/view/tv-shows-television-tackle-hug-hug-glomping-gif-14859564')
|
||||
end
|
||||
};
|
||||
[prefix..'ping'] = { -- Ping Pong function, generally just to see if its on or not without triggering a more complex function. Also tests if its really borked.
|
||||
exec = function (message)
|
||||
message.channel:send("Pong!")
|
||||
end
|
||||
};
|
||||
[prefix..'fire'] = { -- Places elmo on fire in chat.
|
||||
exec = function (message)
|
||||
message.channel:send("https://tenor.com/view/elmo-fire-burn-flame-gif-5042503")
|
||||
end
|
||||
};
|
||||
|
||||
[prefix..'time'] = { -- Posts time to channel, stuck in military time, perhaps use a io.popen() to get actual system time in a more human readable format?
|
||||
exec = function (message)
|
||||
message.channel:send('The current time in military time is ' .. os.date() .. ' atleast in Chicago!')
|
||||
end
|
||||
};
|
||||
[prefix..'analyze'] = { -- Prints contents and attachments to console.
|
||||
exec = function (message)
|
||||
p(message.content)
|
||||
p(message.attachments)
|
||||
end
|
||||
};
|
||||
[prefix..'welsh'] = { --
|
||||
exec = function (message)
|
||||
message.channel:send("https://cdn.discordapp.com/attachments/748713417489252503/770289379586867231/image0.gif")
|
||||
message:delete()
|
||||
end
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function basicCommands.initialize()
|
||||
return commands
|
||||
end
|
||||
return basicCommands
|
Loading…
Reference in New Issue