Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/AndreMor955/gidget
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreMor8 committed Aug 9, 2020
2 parents 6522134 + 124464a commit 427526b
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 14 deletions.
18 changes: 10 additions & 8 deletions src/commands/image/screenshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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",
Expand Down
9 changes: 3 additions & 6 deletions src/commands/music/play.js
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -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]);
Expand All @@ -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;
Expand Down
45 changes: 45 additions & 0 deletions src/webserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 427526b

Please sign in to comment.