diff --git a/modules/DatabaseConnection.js b/modules/DatabaseConnection.js deleted file mode 100644 index 8528dae..0000000 --- a/modules/DatabaseConnection.js +++ /dev/null @@ -1,27 +0,0 @@ -const mongoose = require("mongoose"); - -/** - * Connects with the given DATABASE - * @param {string} mongourl - * @param {Client} client - */ -module.exports.connectDatabase = (mongourl, client) => { - const dbOptions = { - useNewUrlParser: true, - autoIndex: false, - connectTimeoutMS: 10000, - family: 4, - useUnifiedTopology: true, - }; - mongoose.connect(mongourl, dbOptions); - mongoose.Promise = global.Promise; - mongoose.connection.on("connected", () => { - client.logger("[DB] DATABASE CONNECTED"); - }); - mongoose.connection.on("err", (err) => { - client.logger(`Mongoose connection error: \n ${err.stack}`, "error"); - }); - mongoose.connection.on("disconnected", () => { - client.logger("Mongoose disconnected", "error"); - }); -}; diff --git a/modules/chunkString.js b/modules/chunkString.js deleted file mode 100644 index 4253555..0000000 --- a/modules/chunkString.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Chunks a single string into multiple multiple strings - * @param {String} str - * @param {Number} size - * @returns Array containing the chunked strings - */ - -module.exports.chunkSubstr = (str, size) => { - const numChunks = Math.ceil(str.length / size); - const chunks = new Array(numChunks); - - for (let i = 0, o = 0; i < numChunks; ++i, o += size) { - chunks[i] = str.substr(o, size); - } - - return chunks; -}; diff --git a/modules/get-anime-details.js b/modules/get-anime-details.js deleted file mode 100644 index b16ab1e..0000000 --- a/modules/get-anime-details.js +++ /dev/null @@ -1,39 +0,0 @@ -const jikanjs = require("jikanjs"); -const { logger } = require("./logger"); -jikanjs.settings.setBaseURL("https://api.jikan.moe/v3", 3); - -/** - * Searches for an Anime on the Jikan Database - * @param {String} animeName - * @param {String} type - * @returns Object - */ - -module.exports.getAnimeInfo = async (animeName, type = "anime") => { - try { - const getId = await jikanjs.search(type, animeName, [1]); - const animeId = getId.results[0].mal_id; - if (!animeId) throw new Error("No anime ID was found!"); - const getFullInfo = await jikanjs.loadAnime(animeId, "/"); - const genresArray = getFullInfo.genres.map((element) => element.name); - - return { - malid: getFullInfo.mal_id, - imageUrl: getFullInfo.image_url, - titlerom: getFullInfo.title, - titleeng: getFullInfo.title_english, - episodes: getFullInfo.episodes, - status: getFullInfo.status, - rating: getFullInfo.rating, - score: getFullInfo.score, - rank: getFullInfo.rank, - synopsis: getFullInfo.synopsis, - premiered: getFullInfo.premiered, - genres: genresArray, - aired: getFullInfo.aired.string, - }; - } catch (err) { - logger(err.message, "error"); - throw err; - } -}; diff --git a/modules/getMovieInfo.js b/modules/getMovieInfo.js deleted file mode 100644 index 61c6d26..0000000 --- a/modules/getMovieInfo.js +++ /dev/null @@ -1,40 +0,0 @@ -const fetch = require("node-fetch"); -const { TMDb } = require("../config.json"); - -/** - * Searches for the Movie and returns its ID - * @param {String} searchParam - * @param {String} year - * @returns Movie ID - */ -module.exports.getMovieID = async (searchParam, year) => { - try { - const apiCall = await fetch( - `https://api.themoviedb.org/3/search/movie?api_key=${TMDb}&language=en-US&query=${searchParam}&page=1&include_adult=false&year=${year}` - ); - const convertResponeToJson = await apiCall.json(); - if (!convertResponeToJson.total_results) - throw new Error(`${"Nothing found with this name!"}`); - - return convertResponeToJson.results[0].id; - } catch (err) { - throw err; - } -}; - -/** - * Gets Info about Movies based on an ID - * @param {String} id - * @returns Returns an Object containing all Info about the Movie - */ -module.exports.getDetails = async (id) => { - try { - const apiCall = await fetch( - `https://api.themoviedb.org/3/movie/${id}?api_key=${TMDb}&language=en-US` - ); - const convertRes = await apiCall.json(); - return convertRes; - } catch (err) { - throw err; - } -}; diff --git a/modules/logger.js b/modules/logger.js deleted file mode 100644 index 8ecf263..0000000 --- a/modules/logger.js +++ /dev/null @@ -1,30 +0,0 @@ -const moment = require("moment"); -const chalk = require("chalk"); - -/** - * Logger for debugging purposes - * @param {string} message - * @param {string} type - * @returns "" - */ - -module.exports.logger = (message, type = "log") => { - const date = `${moment().format("DD-MM-YYYY hh:mm:ss")}`; - - switch (type) { - case "log": - return console.log( - `[${chalk.gray(date)}]: [${chalk.black.bgGreen( - type.toUpperCase() - )}] ${message}` - ); - case "error": - return console.log( - `[${chalk.gray(date)}]: [${chalk.black.bgRed( - type.toUpperCase() - )}] ${message}` - ); - default: - throw new TypeError("Logger type must be either log or error!"); - } -}; diff --git a/modules/requestAPI.js b/modules/requestAPI.js deleted file mode 100644 index b65b783..0000000 --- a/modules/requestAPI.js +++ /dev/null @@ -1,17 +0,0 @@ -const fetch = require("node-fetch"); - -/** - * Performs a simple GET request - * @param {string} url - * @returns Response from the API as JSON - */ - -module.exports.requestAPI = async (url, options = {}) => { - try { - const request = await fetch(url, options); - const responseToJson = await request.json(); - return responseToJson; - } catch (err) { - throw err; - } -};