diff --git a/src/commands/image/screenshot.js b/src/commands/image/screenshot.js index a596620d..fffe4b93 100644 --- a/src/commands/image/screenshot.js +++ b/src/commands/image/screenshot.js @@ -4,13 +4,15 @@ const timer = new Map(); module.exports = { run: async (bot, message, args) => { if (!args[1]) return message.channel.send("Put some URL"); - if(!timer.get(message.author.id)) { - timer.set(message.author.id, true) - setTimeout(() => { - timer.delete(message.author.id); - }, 25000); //Hm - } else { - return message.channel.send("Don't overload this command!"); + if(message.author.id !== "577000793094488085") { + if(!timer.get(message.author.id)) { + timer.set(message.author.id, true) + setTimeout(() => { + timer.delete(message.author.id); + }, 25000); //Hm + } else { + return message.channel.send("Don't overload this command! (25 sec cooldown)"); + } } if (args[3]) { let options = { @@ -78,7 +80,7 @@ async function pup(message, url, options) { } else { screenshot = await page.screenshot({ type: "png" }); } - const attachment = await new Discord.MessageAttachment(screenshot); + const attachment = new Discord.MessageAttachment(screenshot, "file.png"); await message.channel .send( "Time: " + (Date.now() - message.createdTimestamp) / 1000 + "s", diff --git a/src/commands/music/play.js b/src/commands/music/play.js index 095819bf..8ef33c4b 100644 --- a/src/commands/music/play.js +++ b/src/commands/music/play.js @@ -1,6 +1,7 @@ const ytdl = require("ytdl-core"); const ytsr = require("ytsr"); const ytpl = require("ytpl"); +ytpl.do_warn_deprecate = false const moment = require("moment"); require("moment-duration-format"); module.exports = { @@ -74,9 +75,7 @@ module.exports = { message.channel.startTyping(); return handleVideo(message, voiceChannel, "https://www.youtube.com/watch?v=" + args[1]); } else if (ytpl.validateURL(args[1])) { - let form1 = await message.channel.send( - "Hang on! <:WaldenRead:665434370022178837>" - ); + let form1 = await message.channel.send("Hang on! <:WaldenRead:665434370022178837>"); message.channel.startTyping(); try { const playlist = await ytpl(args[1]); @@ -99,9 +98,7 @@ module.exports = { musicVariables.perror = 0; message.channel.stopTyping(true); message.channel - .send( - `Playlist: **${playlist.title}** has been added to the queue (${playlist.items.length} songs)!` - ) + .send(`Playlist: **${playlist.title}** has been added to the queue (${playlist.items.length} songs)!`) .then(m => form1.delete()); } else { musicVariables.inp = 0; diff --git a/src/webserver.js b/src/webserver.js index 6169429c..f064320f 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -29,6 +29,7 @@ app.use(express.urlencoded({ extended: false })); app.get("/", async (req, res) => { if (!req.headers) return res.status(403).send("You don't have authorization"); if (req.headers.pass !== process.env.ACCESS) return res.status(403).send("You don't have authorization"); + try { if(req.query && req.query.delete) { deleteCache(req.query.delete); } @@ -61,13 +62,57 @@ app.get("/", async (req, res) => { }) } + + if(req.query && req.query.bans) { + const info = await bans(req.query.bans); + if(!info) return res.status(404).send("No se encontró el servidor"); + return res.status(200).send({ + guildID: req.query.bans, + bans: info + }); + } + + if(req.query && req.query.guild && req.query.unban) { + const info = await unban(req.query.guild, req.query.unban); + if(!info) return res.status(404).send("Servidor no encontrado o miembro no está baneado"); + return res.status(202).send("Desbaneado"); + } + res.status(200).send("Good"); + } catch (err) { + console.log(err); + res.status(500).send("Something happened! " + err); + } }); const listener = app.listen(process.env.PORT, function () { console.log("Your app is listening on port " + listener.address().port); }); +async function bans(guildID) { + const guild = bot.guilds.cache.get(guildID); + if(!guild) return false; + const bans = await guild.fetchBans(); + return bans.map((b, i) => { + return { + userID: i, + reason: b.reason + } + }) +} + +async function unban(guildID, userID) { + const guild = bot.guilds.cache.get(guildID); + if(!guild) return false; + const algo = await bans(guildID); + if(algo.find((e) => e.userID === userID)) { + await guild.members.unban(userID); + return true; + } else { + return false; + } +} + function deleteCache(guildID) { bot.cachedMessageReactions.delete(guildID); bot.autoresponsecache.delete(guildID);