diff --git a/app.js b/app.js index 7c03ed8..5bde57e 100644 --- a/app.js +++ b/app.js @@ -42,7 +42,10 @@ const master = new Master(`Bot ${process.env.TOKEN}`, "/shard.js", { "guildMessageReactions", "directMessages", "directMessageReactions" - ] + ], + stats: { + requestTimeout: 30000 + } } }); diff --git a/commands/fun/cat.js b/commands/fun/cat.js index 234349a..b64e780 100644 --- a/commands/fun/cat.js +++ b/commands/fun/cat.js @@ -17,7 +17,6 @@ class CatCommand extends Command { static description = "Gets a random cat picture"; static aliases = ["kitters", "kitties", "kitty", "cattos", "catto", "cats", "cta"]; - static requires = ["cat"]; } module.exports = CatCommand; \ No newline at end of file diff --git a/commands/general/image.js b/commands/general/image.js index 6cd3339..91e0ef0 100644 --- a/commands/general/image.js +++ b/commands/general/image.js @@ -11,8 +11,7 @@ class ImageSearchCommand extends Command { if (this.args.length === 0) return "You need to provide something to search for!"; await this.message.channel.sendTyping(); const embeds = []; - const images = await fetch(`${random(searx)}/search?format=json&safesearch=1&categories=images&disabled_engines=flickr__images,ccengine__images,library of congress__images,deviantart__images,bing images__images&q=${encodeURIComponent(this.args.join(" "))}`).then(res => res.json()); - //if (images.error && images.error.code === 403) return "The daily search quota has been exceeded. Check back later."; + const images = await fetch(`${random(searx)}/search?format=json&safesearch=1&categories=images&q=!goi%20!bii%20!ddi%20${encodeURIComponent(this.args.join(" "))}`).then(res => res.json()); if (images.results.length === 0) return "I couldn't find any results!"; for (const [i, value] of images.results.entries()) { embeds.push({ diff --git a/commands/general/stats.js b/commands/general/stats.js index ea5b40e..d00df01 100644 --- a/commands/general/stats.js +++ b/commands/general/stats.js @@ -57,6 +57,10 @@ class StatsCommand extends Command { { "name": "Shard", "value": this.message.channel.guild ? this.client.guildShardMap[this.message.channel.guild.id] : "N/A", + }, + { + "name": "Cluster", + "value": this.cluster, "inline": true } ] diff --git a/commands/general/youtube.js b/commands/general/youtube.js index 81565e0..7ec4984 100644 --- a/commands/general/youtube.js +++ b/commands/general/youtube.js @@ -1,5 +1,6 @@ const fetch = require("node-fetch"); -const { decodeEntities } = require("../../utils/misc.js"); +const { searx } = require("../../servers.json"); +const { random } = require("../../utils/misc.js"); const paginator = require("../../utils/pagination/pagination.js"); const Command = require("../../classes/command.js"); @@ -8,17 +9,10 @@ class YouTubeCommand extends Command { if (this.args.length === 0) return "You need to provide something to search for!"; this.client.sendChannelTyping(this.message.channel.id); const messages = []; - const request = await fetch(`https://www.googleapis.com/youtube/v3/search?part=snippet&q=${encodeURIComponent(this.args.join(" "))}&key=${process.env.GOOGLE}&maxResults=50`); - const result = await request.json(); - if (result.error && result.error.code === 403) return "I've exceeded my YouTube API search quota for the day. Check back later."; - for (const [i, value] of result.items.entries()) { - if (value.id.kind === "youtube#channel") { - messages.push({ content: `Page ${i + 1} of ${result.items.length}\n<:youtube:637020823005167626> **${decodeEntities(value.snippet.title).replaceAll("*", "\\*")}**\nhttps://youtube.com/channel/${value.id.channelId}` }); - } else if (value.id.kind === "youtube#playlist") { - messages.push({ content: `Page ${i + 1} of ${result.items.length}\n<:youtube:637020823005167626> **${decodeEntities(value.snippet.title).replaceAll("*", "\\*")}**\nCreated by **${decodeEntities(value.snippet.channelTitle).replaceAll("*", "\\*")}**\nhttps://youtube.com/playlist?list=${value.id.playlistId}` }); - } else { - messages.push({ content: `Page ${i + 1} of ${result.items.length}\n<:youtube:637020823005167626> **${decodeEntities(value.snippet.title).replaceAll("*", "\\*")}**\nUploaded by **${decodeEntities(value.snippet.channelTitle).replaceAll("*", "\\*")}** on **${value.snippet.publishedAt.split("T")[0]}**\nhttps://youtube.com/watch?v=${value.id.videoId}` }); - } + const videos = await fetch(`${random(searx)}/search?format=json&safesearch=1&categories=videos&q=!youtube%20${encodeURIComponent(this.args.join(" "))}`).then(res => res.json()); + if (videos.results.length === 0) return "I couldn't find any results!"; + for (const [i, value] of videos.results.entries()) { + messages.push({ content: `Page ${i + 1} of ${videos.results.length}\n<:youtube:637020823005167626> **${value.title.replaceAll("*", "\\*")}**\nUploaded by **${value.author.replaceAll("*", "\\*")}**\n${value.url}` }); } return paginator(this.client, this.message, messages); } @@ -26,7 +20,6 @@ class YouTubeCommand extends Command { static description = "Searches YouTube"; static aliases = ["yt", "video", "ytsearch"]; static arguments = ["[query]"]; - static requires = "google"; } module.exports = YouTubeCommand; \ No newline at end of file diff --git a/utils/database.js b/utils/database.js index 3664297..cb9e677 100644 --- a/utils/database.js +++ b/utils/database.js @@ -1,3 +1,3 @@ // wrapper for the database drivers in ./database/ -module.exports = require(`./database/${process.env.DB.split("://")[0]}.js`); \ No newline at end of file +module.exports = require(`./database/${process.env.DB ? process.env.DB.split("://")[0] : "dummy"}.js`); \ No newline at end of file diff --git a/utils/database/dummy.js b/utils/database/dummy.js index b8b27a1..544dcb2 100644 --- a/utils/database/dummy.js +++ b/utils/database/dummy.js @@ -1,5 +1,8 @@ // dummy (no-op) database handler const misc = require("../misc.js"); +const logger = require("../logger.js"); + +logger.warn("Using dummy database adapter. If this isn't what you wanted, check your DB variable."); exports.setup = async () => {}; exports.stop = async () => {}; diff --git a/utils/handler.js b/utils/handler.js index 6acde7c..1f104c7 100644 --- a/utils/handler.js +++ b/utils/handler.js @@ -4,8 +4,6 @@ const logger = require("./logger.js"); // load command into memory exports.load = async (command, soundStatus) => { const props = require(`../${command}`); - if (props.requires.includes("google") && process.env.GOOGLE === "") return logger.log("warn", `Google info not provided in config, skipped loading command ${command}...`); - if (props.requires.includes("cat") && process.env.CAT === "") return logger.log("warn", `Cat API info not provided in config, skipped loading command ${command}...`); if (props.requires.includes("mashape") && process.env.MASHAPE === "") return logger.log("warn", `Mashape/RapidAPI info not provided in config, skipped loading command ${command}...`); if (props.requires.includes("sound") && soundStatus) return logger.log("warn", `Failed to connect to some Lavalink nodes, skipped loading command ${command}...`); const commandArray = command.split("/");