1
0
Fork 0
forked from threeoh6000/joltik
This repository has been archived on 2024-08-05. You can view files and clone it, but cannot push or open issues or pull requests.
sako-counter/bot.lua

75 lines
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')
2024-08-05 18:39:12 +01:00
local prefix = ","
2022-11-03 21:08:59 +00:00
math.randomseed(os.time())
2022-11-03 20:15:23 +00:00
--- https://stackoverflow.com/a/22843701
string.startswith = function(self, str)
return self:find('^' .. str) ~= nil
end
2022-11-03 18:55:00 +00:00
2022-11-04 17:20:29 +00:00
function load(filename)
local f = io.open(filename, "r")
if not f then return false end
local token = f:read("*a")
f:close()
return token:gsub("\n","")
end
function write(filename, inp)
local f = io.open(filename, "w")
if not f then return false end
local token = f:write(inp)
f:close()
return true
end
2022-11-03 21:08:59 +00:00
function getnick(str, guild)
if guild ~= nil then
local b = str:gsub("<@",""):gsub(">","")
local user = guild:getMember(b)
if user.nickname == nil then
return user.name
else
return user.nickname
end
2022-11-03 21:08:59 +00:00
else
local b = str:gsub("<@",""):gsub(">","")
local user = client:getUser(b)
return user.name
2022-11-03 21:08:59 +00:00
end
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
2024-08-05 18:39:12 +01:00
if string.find(message.content:lower(), "sako") and ((string.find(message.content:lower(), "shut")) and string.find(message.content:lower(), "up") or (string.find(message.content:lower(), "stfu")) or (string.find(message.content:lower(),"quiet"))) then
local counter = load("counter.txt")
counter = tonumber(counter)
message:addReaction(":star:")
counter = counter + 1
write("counter.txt", tostring(counter))
2022-11-03 20:15:23 +00:00
end
2024-08-05 18:39:12 +01:00
if message.content == prefix .. 'sacounter' then
local counter = load("counter.txt")
message.channel:send("**we have told sako to shut up ** ".. counter .. " ** times**)
2022-11-04 17:20:29 +00:00
end
2022-11-03 20:15:23 +00:00
if message.content == prefix .. 'shutdown' then
if message.author.id == "867901290336223242" then
2024-08-05 18:39:12 +01:00
message.channel:send("aight byte")
2022-11-03 20:15:23 +00:00
client:stop()
else
2024-08-05 18:39:12 +01:00
message.channel:send("ayo the pizza here")
2022-11-03 20:15:23 +00:00
end
2022-11-03 18:55:00 +00:00
end
end)
2022-11-04 17:20:29 +00:00
client:run('Bot ' .. load("token.txt"))