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
2024-08-05 18:59:14 +01:00

74 lines
2.1 KiB
Lua
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

local discordia = require('discordia')
local client = discordia.Client {
gatewayIntents = 3276541,
}
local http = require("simple-http")
local json = require('json')
local prefix = ","
math.randomseed(os.time())
--- https://stackoverflow.com/a/22843701
string.startswith = function(self, str)
return self:find('^' .. str) ~= nil
end
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
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
else
local b = str:gsub("<@",""):gsub(">","")
local user = client:getUser(b)
return user.name
end
end
client:on('ready', function()
print('Logged in as '.. client.user.username)
end)
client:on('messageCreate', function(message)
if message.content == prefix .. 'ping' and message.author.id == client.owner.id then
message.channel:send({embed = {title = "Ping?",description = "Pong!",color = 0x00FFFF}})
end
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"))) and message.author.id ~= client.user.id then
local counter = load("counter.txt")
counter = tonumber(counter)
message:addReaction("1")
counter = counter + 1
write("counter.txt", tostring(counter))
end
if message.content == prefix .. 'sacounter' and message.author.id ~= "1152611181601759326" then
local counter = load("counter.txt")
message.channel:send("**we have told sako to shut up ".. counter .. " times**")
end
if message.content == prefix .. 'shutdown' then
if message.author.id == "867901290336223242" then
message.channel:send("aight byte")
client:stop()
end
end
end)
client:run('Bot ' .. load("token.txt"))