local discordia = require('discordia') local client = discordia.Client() 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' 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"))) then local counter = load("counter.txt") counter = tonumber(counter) message:addReaction(":star:") counter = counter + 1 write("counter.txt", tostring(counter)) end if message.content == prefix .. 'sacounter' 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() else message.channel:send("ayo the pizza here") end end end) client:run('Bot ' .. load("token.txt"))