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')
2024-08-05 18:56:27 +01:00
local client = discordia.Client {
gatewayIntents = 3276541,
}
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)
2024-08-05 18:59:14 +01:00
if message.content == prefix .. 'ping' and message.author.id == client.owner.id then
2022-11-03 20:15:23 +00:00
message.channel:send({embed = {title = "Ping?",description = "Pong!",color = 0x00FFFF}})
end
2024-08-05 21:04:22 +01:00
if message.guild.id == "1209971237770498088" and string.find(message.content:lower(), "sako") and string.find(message.content:lower(), "lovely") and message.author.id ~= client.user.id then
2024-08-05 18:39:12 +01:00
local counter = load("counter.txt")
counter = tonumber(counter)
2024-08-05 18:45:42 +01:00
message:addReaction("1")
2024-08-05 18:39:12 +01:00
counter = counter + 1
write("counter.txt", tostring(counter))
2022-11-03 20:15:23 +00:00
end
2024-08-05 18:59:14 +01:00
if message.content == prefix .. 'sacounter' and message.author.id ~= "1152611181601759326" then
2024-08-05 18:39:12 +01:00
local counter = load("counter.txt")
2024-08-05 21:04:22 +01:00
message.channel:send("**we have said that sako is lovely ".. 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()
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"))