This repository has been archived on 2023-10-28. You can view files and clone it, but cannot push or open issues or pull requests.
joltik/bot.lua

57 lines
3.2 KiB
Lua
Raw Normal View History

2022-11-03 18:55:00 +00:00
local discordia = require('discordia')
local client = discordia.Client()
2022-11-03 20:15:23 +00:00
local http = require("simple-http")
local json = require('json')
local prefix = "."
--- https://stackoverflow.com/a/22843701
string.startswith = function(self, str)
return self:find('^' .. str) ~= nil
end
2022-11-03 18:55:00 +00:00
client:on('ready', function()
print('Logged in as '.. client.user.username)
end)
client:on('messageCreate', function(message)
2022-11-03 20:15:23 +00:00
if message.content == prefix .. 'ping' then
message.channel:send({embed = {title = "Ping?",description = "Pong!",color = 0x00FFFF}})
end
if message.content:startswith(prefix .. 'hug <@') then
local body, res = http.request("GET", "https://nekos.life/api/v2/img/hug")
message.channel:send({embed = {title = "Aww! " .. message.guild:getMember(message.author.id).username .. " hugged " .. message.guild:getMember(message.content:gsub(prefix .. 'hug <@', ''):gsub('>', '')).username .. "!",color = 0x00FFFF, image = {url = body.url, height = 0, width = 0}}})
end
if message.content:startswith(prefix .. 'cuddle <@') then
local body, res = http.request("GET", "https://nekos.life/api/v2/img/cuddle")
message.channel:send({embed = {title = "Aww! " .. message.guild:getMember(message.author.id).username .. " cuddled " .. message.guild:getMember(message.content:gsub(prefix .. 'cuddle <@', ''):gsub('>', '')).username .. "!",color = 0x00FFFF, image = {url = body.url, height = 0, width = 0}}})
end
if message.content:startswith(prefix .. 'kiss <@') then
local body, res = http.request("GET", "https://nekos.life/api/v2/img/kiss")
message.channel:send({embed = {title = "Aww! " .. message.guild:getMember(message.author.id).username .. " kissed " .. message.guild:getMember(message.content:gsub(prefix .. 'kiss <@', ''):gsub('>', '')).username .. "!",color = 0x00FFFF, image = {url = body.url, height = 0, width = 0}}})
end
if message.content:startswith(prefix .. 'slap <@') then
local body, res = http.request("GET", "https://nekos.life/api/v2/img/slap")
message.channel:send({embed = {title = "Aww! " .. message.guild:getMember(message.author.id).username .. " slapped " .. message.guild:getMember(message.content:gsub(prefix .. 'slap <@', ''):gsub('>', '')).username .. "!",color = 0x00FFFF, image = {url = body.url, height = 0, width = 0}}})
end
if message.content:startswith(prefix .. 'pat <@') then
local body, res = http.request("GET", "https://nekos.life/api/v2/img/pat")
message.channel:send({embed = {title = "Aww! " .. message.guild:getMember(message.author.id).username .. " patted " .. message.guild:getMember(message.content:gsub(prefix .. 'pat <@', ''):gsub('>', '')).username .. "!",color = 0x00FFFF, image = {url = body.url, height = 0, width = 0}}})
end
if message.content == prefix .. 'help' then
message.channel:send("**Need help? Refer to my handy dandy help sheet!**\n\n```diff\n+ Action\nhug kiss pat cuddle slap\n\n+ Info\nping help\n```")
end
if message.content == prefix .. 'shutdown' then
if message.author.id == "867901290336223242" then
message.channel:send("**Shutting down!** Good night mother! :heart:")
client:stop()
else
message.channel:send("You aren't my mother!")
end
2022-11-03 18:55:00 +00:00
end
end)
local f = io.open("token.txt", "r")
local token = f:read("*a")
f:close()
client:run('Bot ' .. token:gsub("\n",""))