From 5a026a2f72eeb90e1b8b201c726c099801a01f7b Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Sat, 16 Oct 2021 12:11:46 +0530 Subject: [PATCH 01/40] Add a Itunes command --- src/commands/misc/itunes.js | 54 +++++++++++++++++++++++++++++++++ src/locales/en-US/commands.json | 12 ++++++++ 2 files changed, 66 insertions(+) create mode 100644 src/commands/misc/itunes.js diff --git a/src/commands/misc/itunes.js b/src/commands/misc/itunes.js new file mode 100644 index 000000000..06022e20f --- /dev/null +++ b/src/commands/misc/itunes.js @@ -0,0 +1,54 @@ +const { Command, SwitchbladeEmbed, SearchCommand } = require('../../') +const fetch = require("node-fetch") + +module.exports = class Itunes extends Command { + constructor(client) { + super({ + name: 'itunes', + aliases: ['itunes'], + parameters: [{ + type: 'string', + full: true, + clean: true, + missingError: 'commands:itunes.noText' + }] + }, client) + } + + async run({ channel, message }, text) { + text = text.split(" ") + + const media = text.at(0) + + const term = text.splice(1 , text.length - 1).join(" ") + + const data = await fetch(`https://itunes.apple.com/search?media=${media}&term=${term}&limit=10`).then(res => res.json()).then(data => data) + + const description = this.createDescription(data) + + const embed = new SwitchbladeEmbed() + .setColor(this.embedColor) + .setTitle(media.toUpperCase() + ' - ' + term.toUpperCase()) + .setDescription(description) + + channel.send(embed); + } + + createDescription = (data) => { + var description = "" + + var count = 1 + + for(let key in data.results){ + description += `${count < 10 ? "0" + count.toString() : count}: [${data.results[key].trackName}](${data.results[key].trackViewUrl}) - [${data.results[key].artistName}](${data.results[key].artistViewUrl})\n` + + count += 1 + } + + if(count === 1){ + description = "Not Found" + } + + return description + } +} \ No newline at end of file diff --git a/src/locales/en-US/commands.json b/src/locales/en-US/commands.json index 7e9b7e8aa..c771cf303 100644 --- a/src/locales/en-US/commands.json +++ b/src/locales/en-US/commands.json @@ -672,6 +672,18 @@ "commandUsage": "", "noText": "You have to give me some text to asciify!" }, + "itunes": { + "commandDescription": "Provides the content within the iTunes Store and Apple Books Store.", + "commandUsage": " ", + "example": "s!itunes ebook Famous Five", + "subcommands": { + "media": { + "commandDescription": "Type of media. Examples: Ebook , Movie , PodCast", + "commandUsage": "media " + } + }, + "noText": "You have to give me media and search terms!" +}, "hentai": { "commandDescription": "Sends hentai in an NSFW channel.", "hereIsYourHentai": "Here's your hentai!" From 4eeba9e0410f8ec743e83b94bec53dd62391cdd8 Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Sun, 17 Oct 2021 18:17:29 +0530 Subject: [PATCH 02/40] Update code with requested changes --- src/apis/ITunes.js | 42 ++++++++++++++ src/commands/misc/itunes.js | 98 ++++++++++++++++++++------------- src/locales/en-US/commands.json | 11 ++-- src/utils/Constants.js | 1 + 4 files changed, 109 insertions(+), 43 deletions(-) create mode 100644 src/apis/ITunes.js diff --git a/src/apis/ITunes.js b/src/apis/ITunes.js new file mode 100644 index 000000000..fd565b82c --- /dev/null +++ b/src/apis/ITunes.js @@ -0,0 +1,42 @@ +const { APIWrapper } = require('../') +const axios = require('axios') + +module.exports = class ITunes extends APIWrapper { + constructor () { + super({ + name: 'itunes' + }) + } + + async search (query) { + query = query.split(" ") + + const media = query.at(0) + + if(!["movie", "podcast", "music", "musicVideo", "audiobook", "shortFilm", "tvShow", "software", "ebook", "all"].includes(media)){ + return [{"errorMessage": `Invaid term provided. The term has to be one of the following: ${["movie", "podcast", "music", "musicVideo", "audiobook", "shortFilm", "tvShow", "software", "ebook", "all"].join(" , ")}`}] + } + + const term = query.splice(1 , query.length - 1).join("+").toLowerCase() + + const userCountry = await this.getUserCountry() + + try{ + const { data } = await axios.get(`https://itunes.apple.com/search?media=${media}&term=${term}&limit=10&country=${userCountry}`) + + if(data.results == 0){ + throw new TypeError() + } + + return data.results + } catch{ + return [{"errorMessage": "No results found"}] + } + } + + getUserCountry = async () => { + const response = await axios.get("https://ipinfo.io") + + return response.data.country + } +} diff --git a/src/commands/misc/itunes.js b/src/commands/misc/itunes.js index 06022e20f..83b34ba90 100644 --- a/src/commands/misc/itunes.js +++ b/src/commands/misc/itunes.js @@ -1,54 +1,78 @@ -const { Command, SwitchbladeEmbed, SearchCommand } = require('../../') -const fetch = require("node-fetch") +const { SwitchbladeEmbed, SearchCommand, Constants, CommandStructures } = require('../../') +const { Command, CommandParameters, StringParameter } = CommandStructures +const moment = require("moment") -module.exports = class Itunes extends Command { +module.exports = class Itunes extends SearchCommand { constructor(client) { super({ - name: 'itunes', - aliases: ['itunes'], - parameters: [{ - type: 'string', - full: true, - clean: true, - missingError: 'commands:itunes.noText' - }] - }, client) + name: "itunes", + requirements: { + apis: ["itunes"] + }, + embedColor: Constants.ITUNES_COLOR, + embedLogoURL: "https://i.imgur.com/mwPUlYA.png", + } , client); } + + async search(_ , query){ + const data = await this.client.apis.itunes.search(query) - async run({ channel, message }, text) { - text = text.split(" ") + console.log(data) - const media = text.at(0) - - const term = text.splice(1 , text.length - 1).join(" ") - - const data = await fetch(`https://itunes.apple.com/search?media=${media}&term=${term}&limit=10`).then(res => res.json()).then(data => data) - - const description = this.createDescription(data) + return await data; + } - const embed = new SwitchbladeEmbed() - .setColor(this.embedColor) - .setTitle(media.toUpperCase() + ' - ' + term.toUpperCase()) - .setDescription(description) + searchResultFormatter(i) { + if(!i.error){ + return `[${i.trackName}](${i.trackViewUrl}) - [${i.artistName}](${i.artistViewUrl})` + } else { + return i.error + } + } - channel.send(embed); + getRatingEmojis (rating) { + return (this.getEmoji('ratingstar', '⭐').repeat(Math.floor(rating))) + (this.getEmoji('ratinghalfstar').repeat(Math.ceil(rating - Math.floor(rating)))) } - createDescription = (data) => { - var description = "" + async handleResult({ t, author, channel }, data){ + if(data.errorMessage){ + const embed = new SwitchbladeEmbed(author) + .setColor(Constants.ERROR_COLOR) + .setTitle(data.errorMessage) - var count = 1 + channel.send(embed) - for(let key in data.results){ - description += `${count < 10 ? "0" + count.toString() : count}: [${data.results[key].trackName}](${data.results[key].trackViewUrl}) - [${data.results[key].artistName}](${data.results[key].artistViewUrl})\n` + return + } - count += 1 - } - if(count === 1){ - description = "Not Found" - } + const stars = this.getRatingEmojis(data.averageUserRating) + + const embed = new SwitchbladeEmbed(author) + .setColor(this.embedColor) + .setAuthor(t('commands:itunes.place'), this.embedLogoURL, 'https://www.apple.com/itunes/') + .setURL(data.trackViewUrl) + .setTitle(t("commands:itunes.track" , {name: data.trackName, artistName: data.artistName})) + .setThumbnail(data.artworkUrl100) + .setDescriptionFromBlockArray([ + [ + data.description ? `Description: ${data.description.replace(new RegExp('<[^>]*>' , 'g') , "")}` : data.longDescription ? `Description: ${data.longDescription}` : "" + ], + [ + data.userRatingCount ? t('commands:itunes.ratingCount', { count: data.userRatingCount || 0}) : "", + data.averageUserRating ? `Rating: ${stars} (${Math.round(data.averageUserRating) || ""})`: "" + ], + [ + t("commands:itunes.price" , {price: data.formattedPrice || data.trackPrice , currency: data.currency}) + ], + [ + t("commands:itunes.release" , {date: moment(data.releaseDate).format("DD/MM/YYYY")}) + ], + [ + `Genres: ${(data.genres || ["-"]).join(" , ")}` + ] + ]) - return description + channel.send(embed) } } \ No newline at end of file diff --git a/src/locales/en-US/commands.json b/src/locales/en-US/commands.json index c771cf303..8da0c66e5 100644 --- a/src/locales/en-US/commands.json +++ b/src/locales/en-US/commands.json @@ -676,12 +676,11 @@ "commandDescription": "Provides the content within the iTunes Store and Apple Books Store.", "commandUsage": " ", "example": "s!itunes ebook Famous Five", - "subcommands": { - "media": { - "commandDescription": "Type of media. Examples: Ebook , Movie , PodCast", - "commandUsage": "media " - } - }, + "place": "Itunes Store", + "track": "{{name}} - {{artistName}}", + "ratingCount": "Rating Count: {{count}}", + "price": "Price: {{price}} ({{currency}})", + "release": "Release Date: {{date}}", "noText": "You have to give me media and search terms!" }, "hentai": { diff --git a/src/utils/Constants.js b/src/utils/Constants.js index d7314d701..e8bd0f77d 100644 --- a/src/utils/Constants.js +++ b/src/utils/Constants.js @@ -6,6 +6,7 @@ module.exports = { ERROR_COLOR: '#FF3333', EIGHTBALL_COLOR: '#000000', NPM_COLOR: '#CB3837', + ITUNES_COLOR: "#49CCC9", GENERIC_RED_COLOR: '#CB3837', E621_COLOR: '#258CF5', XKCD_COLOR: '#96A8C8', From 2f032a8ac70f9c3c0f0ce55303159ff6026f862e Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Sun, 17 Oct 2021 18:22:46 +0530 Subject: [PATCH 03/40] Make requested changes --- .env.example | 4 ++-- shard.js | 3 +++ src/apis/ITunes.js | 6 ++++-- src/commands/misc/itunes.js | 2 -- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.env.example b/.env.example index b2b0157e9..f7815ba6e 100644 --- a/.env.example +++ b/.env.example @@ -1,10 +1,10 @@ BOT_GUILD=000000000000000000 DEVELOPER_ROLE=000000000000000000 LOGGING_CHANNEL_ID=0000000000000000001+ -DISCORD_TOKEN=NDQWCmReCyz0Uf7TX0nw32-3XZNDJQc5AsQDWihYXWNr2.COBpA5idy52C9 +DISCORD_TOKEN=ODk5MTIxMTU5MTUxNDM5OTAy.YWuJ1Q.xJJ6PrriTi8uteX1UO3pKXCnXVQ EMBED_COLOR=#7289DA LAVALINK_NODES=[{"host": "127.0.0.1", "port": 1337, "password": "passwordlavalink", "region": "asia|eu|us|sam"}] -MONGODB_URI=mongodb://username:password@example.com:80/example +MONGODB_URI=mongodb+srv://takemehome:takemehome@cluster0.iyvxc.mongodb.net/Cluster0?retryWrites=true&w=majority PREFIX=s! SPOTIFY_CLIENT_ID=8w84g2wg7a3gj315rn7dlh7bsicggurf SPOTIFY_CLIENT_SECRET=yr21s12n8q3hulxwtwz21r5xh28dl1g9 diff --git a/shard.js b/shard.js index eff8c582a..90f5ce722 100644 --- a/shard.js +++ b/shard.js @@ -1,4 +1,7 @@ const { ShardingManager } = require('discord.js') +const dotenv = require("dotenv") + +dotenv.config({"path": "./.env.example"}) const manager = new ShardingManager('./index.js', { token: process.env.DISCORD_TOKEN, totalShards: parseInt(process.env.SHARD_COUNT) || 'auto' diff --git a/src/apis/ITunes.js b/src/apis/ITunes.js index fd565b82c..e86c452a9 100644 --- a/src/apis/ITunes.js +++ b/src/apis/ITunes.js @@ -13,8 +13,10 @@ module.exports = class ITunes extends APIWrapper { const media = query.at(0) - if(!["movie", "podcast", "music", "musicVideo", "audiobook", "shortFilm", "tvShow", "software", "ebook", "all"].includes(media)){ - return [{"errorMessage": `Invaid term provided. The term has to be one of the following: ${["movie", "podcast", "music", "musicVideo", "audiobook", "shortFilm", "tvShow", "software", "ebook", "all"].join(" , ")}`}] + const mediaWhiteList = ["movie", "podcast", "music", "musicVideo", "audiobook", "shortFilm", "tvShow", "software", "ebook", "all"] + + if(!mediaWhiteList.includes(media)){ + return [{"errorMessage": `Invaid term provided. The term has to be one of the following: ${mediaWhiteList.join(" , ")}`}] } const term = query.splice(1 , query.length - 1).join("+").toLowerCase() diff --git a/src/commands/misc/itunes.js b/src/commands/misc/itunes.js index 83b34ba90..d23b2eb52 100644 --- a/src/commands/misc/itunes.js +++ b/src/commands/misc/itunes.js @@ -17,8 +17,6 @@ module.exports = class Itunes extends SearchCommand { async search(_ , query){ const data = await this.client.apis.itunes.search(query) - console.log(data) - return await data; } From f087b79200c6f38a38b9f0635427c1b05cf2507c Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Sun, 17 Oct 2021 18:26:21 +0530 Subject: [PATCH 04/40] Update .env and shard.js --- .env.example | 6 +++--- shard.js | 3 --- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.env.example b/.env.example index f7815ba6e..bada613d7 100644 --- a/.env.example +++ b/.env.example @@ -1,10 +1,10 @@ BOT_GUILD=000000000000000000 DEVELOPER_ROLE=000000000000000000 LOGGING_CHANNEL_ID=0000000000000000001+ -DISCORD_TOKEN=ODk5MTIxMTU5MTUxNDM5OTAy.YWuJ1Q.xJJ6PrriTi8uteX1UO3pKXCnXVQ +DISCORD_TOKEN=NDQWCmReCyz0Uf7TX0nw32-3XZNDJQc5AsQDWihYXWNr2.COBpA5idy52C9 EMBED_COLOR=#7289DA LAVALINK_NODES=[{"host": "127.0.0.1", "port": 1337, "password": "passwordlavalink", "region": "asia|eu|us|sam"}] -MONGODB_URI=mongodb+srv://takemehome:takemehome@cluster0.iyvxc.mongodb.net/Cluster0?retryWrites=true&w=majority +MONGODB_URI=mongodb://username:password@example.com:80/example PREFIX=s! SPOTIFY_CLIENT_ID=8w84g2wg7a3gj315rn7dlh7bsicggurf SPOTIFY_CLIENT_SECRET=yr21s12n8q3hulxwtwz21r5xh28dl1g9 @@ -41,4 +41,4 @@ DEBUG=false MERRIAM_WEBSTER_API_KEY=1293a33-4731-34cb-69a3-178a39b7c23 GITHUB_USER=SwitchbladeBot GITHUB_REPOSITORY=switchblade -GITHUB_BRANCH=master +GITHUB_BRANCH=master \ No newline at end of file diff --git a/shard.js b/shard.js index 90f5ce722..eff8c582a 100644 --- a/shard.js +++ b/shard.js @@ -1,7 +1,4 @@ const { ShardingManager } = require('discord.js') -const dotenv = require("dotenv") - -dotenv.config({"path": "./.env.example"}) const manager = new ShardingManager('./index.js', { token: process.env.DISCORD_TOKEN, totalShards: parseInt(process.env.SHARD_COUNT) || 'auto' From 297553e19318adc70e2d828ab09b5983758b8347 Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Sun, 17 Oct 2021 18:29:14 +0530 Subject: [PATCH 05/40] Make requested changes --- src/apis/ITunes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apis/ITunes.js b/src/apis/ITunes.js index e86c452a9..5d79d63e2 100644 --- a/src/apis/ITunes.js +++ b/src/apis/ITunes.js @@ -27,7 +27,7 @@ module.exports = class ITunes extends APIWrapper { const { data } = await axios.get(`https://itunes.apple.com/search?media=${media}&term=${term}&limit=10&country=${userCountry}`) if(data.results == 0){ - throw new TypeError() + throw new Error() } return data.results From f115f10f6a9660dfcfb066c135f78e644bcf209c Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Sun, 17 Oct 2021 18:30:54 +0530 Subject: [PATCH 06/40] Make requested changes --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index bada613d7..b2b0157e9 100644 --- a/.env.example +++ b/.env.example @@ -41,4 +41,4 @@ DEBUG=false MERRIAM_WEBSTER_API_KEY=1293a33-4731-34cb-69a3-178a39b7c23 GITHUB_USER=SwitchbladeBot GITHUB_REPOSITORY=switchblade -GITHUB_BRANCH=master \ No newline at end of file +GITHUB_BRANCH=master From 8ae2504aa3c39877524c12aac76d81badc7eaeb3 Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Sun, 17 Oct 2021 18:42:53 +0530 Subject: [PATCH 07/40] Use params while sending requests with axios --- src/apis/ITunes.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/apis/ITunes.js b/src/apis/ITunes.js index 5d79d63e2..204a92ecd 100644 --- a/src/apis/ITunes.js +++ b/src/apis/ITunes.js @@ -24,7 +24,13 @@ module.exports = class ITunes extends APIWrapper { const userCountry = await this.getUserCountry() try{ - const { data } = await axios.get(`https://itunes.apple.com/search?media=${media}&term=${term}&limit=10&country=${userCountry}`) + const { data } = await axios.get(`https://itunes.apple.com/search` , { + params: { + media: media, + term: term, + country: userCountry, + } + }) if(data.results == 0){ throw new Error() @@ -36,7 +42,7 @@ module.exports = class ITunes extends APIWrapper { } } - getUserCountry = async () => { + async getUserCountry() { const response = await axios.get("https://ipinfo.io") return response.data.country From 5af5876689445d46c2ca5789e49161324d974d7c Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Sun, 17 Oct 2021 18:58:35 +0530 Subject: [PATCH 08/40] Set limit to the response data --- src/apis/ITunes.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/apis/ITunes.js b/src/apis/ITunes.js index 204a92ecd..7456cacf2 100644 --- a/src/apis/ITunes.js +++ b/src/apis/ITunes.js @@ -29,6 +29,7 @@ module.exports = class ITunes extends APIWrapper { media: media, term: term, country: userCountry, + limit: 10, } }) From 898059b7f5cdc37b306fe73dba1ed97dc708304b Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Sun, 17 Oct 2021 19:08:29 +0530 Subject: [PATCH 09/40] Formatting + Minor bugs --- src/apis/ITunes.js | 82 ++++++++++++++++++++----------------- src/commands/misc/itunes.js | 2 +- src/utils/Constants.js | 2 +- 3 files changed, 46 insertions(+), 40 deletions(-) diff --git a/src/apis/ITunes.js b/src/apis/ITunes.js index 7456cacf2..b06f370d2 100644 --- a/src/apis/ITunes.js +++ b/src/apis/ITunes.js @@ -1,51 +1,57 @@ -const { APIWrapper } = require('../') +const {APIWrapper} = require('../') const axios = require('axios') module.exports = class ITunes extends APIWrapper { - constructor () { - super({ - name: 'itunes' - }) + constructor() { + super({name: 'itunes'}) + } + + async search(query) { + query = query.split(' ') + + const media = query.at(0) + + const mediaWhiteList = + [ + 'movie', 'podcast', 'music', 'musicVideo', 'audiobook', 'shortFilm', + 'tvShow', 'software', 'ebook', 'all' + ] + + if (!mediaWhiteList.includes(media)) { + return [{ + 'errorMessage': + `Invaid term provided. The term has to be one of the following: ${ + mediaWhiteList.join(' , ')}` + }] } - async search (query) { - query = query.split(" ") + const term = query.splice(1, query.length - 1).join('+').toLowerCase() - const media = query.at(0) + const userCountry = await this.getUserCountry() - const mediaWhiteList = ["movie", "podcast", "music", "musicVideo", "audiobook", "shortFilm", "tvShow", "software", "ebook", "all"] - - if(!mediaWhiteList.includes(media)){ - return [{"errorMessage": `Invaid term provided. The term has to be one of the following: ${mediaWhiteList.join(" , ")}`}] + try { + const {data} = await axios.get(`https://itunes.apple.com/search`, { + params: { + media: media, + term: term, + country: userCountry, + limit: 10, } + }) - const term = query.splice(1 , query.length - 1).join("+").toLowerCase() - - const userCountry = await this.getUserCountry() - - try{ - const { data } = await axios.get(`https://itunes.apple.com/search` , { - params: { - media: media, - term: term, - country: userCountry, - limit: 10, - } - }) + if (data.results == 0) { + throw new Error() + } - if(data.results == 0){ - throw new Error() - } - - return data.results - } catch{ - return [{"errorMessage": "No results found"}] - } + return data.results + } catch { + return [{'errorMessage': 'No results found'}] } + } - async getUserCountry() { - const response = await axios.get("https://ipinfo.io") + async getUserCountry() { + const response = await axios.get('https://ipinfo.io') - return response.data.country - } -} + return response.data.country + } +} \ No newline at end of file diff --git a/src/commands/misc/itunes.js b/src/commands/misc/itunes.js index d23b2eb52..6ed79ab21 100644 --- a/src/commands/misc/itunes.js +++ b/src/commands/misc/itunes.js @@ -10,7 +10,7 @@ module.exports = class Itunes extends SearchCommand { apis: ["itunes"] }, embedColor: Constants.ITUNES_COLOR, - embedLogoURL: "https://i.imgur.com/mwPUlYA.png", + embedLogoURL: "https://i.imgur.com/K8uqCSw.png", } , client); } diff --git a/src/utils/Constants.js b/src/utils/Constants.js index e8bd0f77d..70c1b97be 100644 --- a/src/utils/Constants.js +++ b/src/utils/Constants.js @@ -6,7 +6,7 @@ module.exports = { ERROR_COLOR: '#FF3333', EIGHTBALL_COLOR: '#000000', NPM_COLOR: '#CB3837', - ITUNES_COLOR: "#49CCC9", + ITUNES_COLOR: "#FF6283", GENERIC_RED_COLOR: '#CB3837', E621_COLOR: '#258CF5', XKCD_COLOR: '#96A8C8', From cbb1026dd2cf4ba6aae31bdd8ae95bbc1282c239 Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Mon, 18 Oct 2021 10:55:05 +0530 Subject: [PATCH 10/40] Bug fixes --- .env.example | 6 +- shard.js | 3 + src/apis/ITunes.js | 12 +--- src/commands/misc/itunes.js | 131 ++++++++++++++++++++---------------- 4 files changed, 81 insertions(+), 71 deletions(-) diff --git a/.env.example b/.env.example index b2b0157e9..a3daa8333 100644 --- a/.env.example +++ b/.env.example @@ -1,15 +1,15 @@ BOT_GUILD=000000000000000000 DEVELOPER_ROLE=000000000000000000 LOGGING_CHANNEL_ID=0000000000000000001+ -DISCORD_TOKEN=NDQWCmReCyz0Uf7TX0nw32-3XZNDJQc5AsQDWihYXWNr2.COBpA5idy52C9 +DISCORD_TOKEN=ODk5MTIxMTU5MTUxNDM5OTAy.YWuJ1Q.2QqluYAf0oJP45zWxRBpMjs28os EMBED_COLOR=#7289DA LAVALINK_NODES=[{"host": "127.0.0.1", "port": 1337, "password": "passwordlavalink", "region": "asia|eu|us|sam"}] -MONGODB_URI=mongodb://username:password@example.com:80/example +MONGODB_URI=mongodb+srv://takemehome:takemehome@cluster0.iyvxc.mongodb.net/Cluster0?retryWrites=true&w=majority PREFIX=s! SPOTIFY_CLIENT_ID=8w84g2wg7a3gj315rn7dlh7bsicggurf SPOTIFY_CLIENT_SECRET=yr21s12n8q3hulxwtwz21r5xh28dl1g9 TWITCH_CLIENT_ID=4uuc9u4iezex5zadzidv3f0lfm7vyo -YOUTUBE_API_KEY=Yp1M7jgfnsbhn5azgzlNiw6IldSAXBKzYrTV44w +YOUTUBE_API_KEY=AIzaSyD3jjoF8ta9kx55Rvb9Nd9n6s98908CDKo CROWDIN_API_KEY=1DT16vcCjfAS79Ar6sybJfAt23ay2Cko CROWDIN_PROJECT_ID=example GENIUS_API=7WWvbyiaJOfh1PPeRNS3gaHdjB-PgKee5xYRtSh4NgXtbVfZfG9UH4A5vp7EICL3 diff --git a/shard.js b/shard.js index eff8c582a..c99948694 100644 --- a/shard.js +++ b/shard.js @@ -1,4 +1,7 @@ const { ShardingManager } = require('discord.js') +const dotenv = require('dotenv') + +dotenv.config({"path": "./.env.example"}) const manager = new ShardingManager('./index.js', { token: process.env.DISCORD_TOKEN, totalShards: parseInt(process.env.SHARD_COUNT) || 'auto' diff --git a/src/apis/ITunes.js b/src/apis/ITunes.js index b06f370d2..a1bf01c20 100644 --- a/src/apis/ITunes.js +++ b/src/apis/ITunes.js @@ -6,11 +6,7 @@ module.exports = class ITunes extends APIWrapper { super({name: 'itunes'}) } - async search(query) { - query = query.split(' ') - - const media = query.at(0) - + async search(media , term , country) { const mediaWhiteList = [ 'movie', 'podcast', 'music', 'musicVideo', 'audiobook', 'shortFilm', @@ -25,16 +21,12 @@ module.exports = class ITunes extends APIWrapper { }] } - const term = query.splice(1, query.length - 1).join('+').toLowerCase() - - const userCountry = await this.getUserCountry() - try { const {data} = await axios.get(`https://itunes.apple.com/search`, { params: { media: media, term: term, - country: userCountry, + country: country, limit: 10, } }) diff --git a/src/commands/misc/itunes.js b/src/commands/misc/itunes.js index 6ed79ab21..34da9eef8 100644 --- a/src/commands/misc/itunes.js +++ b/src/commands/misc/itunes.js @@ -1,76 +1,91 @@ -const { SwitchbladeEmbed, SearchCommand, Constants, CommandStructures } = require('../../') -const { Command, CommandParameters, StringParameter } = CommandStructures -const moment = require("moment") +const {SwitchbladeEmbed, SearchCommand, Constants, CommandStructures} = + require('../../') +const {Command, CommandParameters, StringParameter} = CommandStructures +const moment = require('moment') module.exports = class Itunes extends SearchCommand { - constructor(client) { - super({ - name: "itunes", - requirements: { - apis: ["itunes"] - }, - embedColor: Constants.ITUNES_COLOR, - embedLogoURL: "https://i.imgur.com/K8uqCSw.png", - } , client); - } - - async search(_ , query){ - const data = await this.client.apis.itunes.search(query) + constructor(client) { + super( + { + name: 'itunes', + requirements: {apis: ['itunes']}, + embedColor: Constants.ITUNES_COLOR, + embedLogoURL: 'https://i.imgur.com/K8uqCSw.png', + }, + client); + } - return await data; - } + async search(_, query) { + const data = await this.client.apis.itunes.search(query) - searchResultFormatter(i) { - if(!i.error){ - return `[${i.trackName}](${i.trackViewUrl}) - [${i.artistName}](${i.artistViewUrl})` - } else { - return i.error - } - } + return await data; + } - getRatingEmojis (rating) { - return (this.getEmoji('ratingstar', '⭐').repeat(Math.floor(rating))) + (this.getEmoji('ratinghalfstar').repeat(Math.ceil(rating - Math.floor(rating)))) + searchResultFormatter(i) { + if (!i.error) { + return `[${i.trackName}](${i.trackViewUrl}) - [${i.artistName}](${ + i.artistViewUrl})` + } else { + return i.error } + } - async handleResult({ t, author, channel }, data){ - if(data.errorMessage){ - const embed = new SwitchbladeEmbed(author) - .setColor(Constants.ERROR_COLOR) - .setTitle(data.errorMessage) + getRatingEmojis(rating) { + return (this.getEmoji('ratingstar', '⭐').repeat(Math.floor(rating))) + + (this.getEmoji('ratinghalfstar') + .repeat(Math.ceil(rating - Math.floor(rating)))) + } - channel.send(embed) + async handleResult({t, author, channel}, data) { + if (data.errorMessage) { + const embed = new SwitchbladeEmbed(author) + .setColor(Constants.ERROR_COLOR) + .setTitle(data.errorMessage) - return - } + channel.send(embed) + + return + } - const stars = this.getRatingEmojis(data.averageUserRating) + const stars = this.getRatingEmojis(data.averageUserRating) - const embed = new SwitchbladeEmbed(author) + const embed = + new SwitchbladeEmbed(author) .setColor(this.embedColor) - .setAuthor(t('commands:itunes.place'), this.embedLogoURL, 'https://www.apple.com/itunes/') + .setAuthor( + t('commands:itunes.place'), this.embedLogoURL, + 'https://www.apple.com/itunes/') .setURL(data.trackViewUrl) - .setTitle(t("commands:itunes.track" , {name: data.trackName, artistName: data.artistName})) + .setTitle( + t('commands:itunes.track', + {name: data.trackName, artistName: data.artistName})) .setThumbnail(data.artworkUrl100) .setDescriptionFromBlockArray([ - [ - data.description ? `Description: ${data.description.replace(new RegExp('<[^>]*>' , 'g') , "")}` : data.longDescription ? `Description: ${data.longDescription}` : "" - ], - [ - data.userRatingCount ? t('commands:itunes.ratingCount', { count: data.userRatingCount || 0}) : "", - data.averageUserRating ? `Rating: ${stars} (${Math.round(data.averageUserRating) || ""})`: "" - ], - [ - t("commands:itunes.price" , {price: data.formattedPrice || data.trackPrice , currency: data.currency}) - ], - [ - t("commands:itunes.release" , {date: moment(data.releaseDate).format("DD/MM/YYYY")}) - ], - [ - `Genres: ${(data.genres || ["-"]).join(" , ")}` - ] - ]) + [data.description ? `Description: ${ + data.description.replace( + new RegExp('<[^>]*>', 'g'), '')}` : + data.longDescription ? + `Description: ${data.longDescription}` : + ''], + [ + data.userRatingCount ? t('commands:itunes.ratingCount', + {count: data.userRatingCount || 0}) : + '', + data.averageUserRating ? + `Rating: ${stars} (${ + Math.round(data.averageUserRating) || ''})` : + '' + ], + [t('commands:itunes.price', { + price: data.formattedPrice || data.trackPrice, + currency: data.currency + })], + [t('commands:itunes.release', + {date: moment(data.releaseDate).format('DD/MM/YYYY')})], + [`Genres: ${(data.genres || ['-']).join(' , ')}`] + ]) - channel.send(embed) - } + channel.send(embed) + } } \ No newline at end of file From 522bf0fe08c0ade84613e39b8ecadb082b7c501b Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Mon, 18 Oct 2021 10:57:23 +0530 Subject: [PATCH 11/40] Update --- .env.example | 6 +++--- shard.js | 3 --- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.env.example b/.env.example index a3daa8333..b2b0157e9 100644 --- a/.env.example +++ b/.env.example @@ -1,15 +1,15 @@ BOT_GUILD=000000000000000000 DEVELOPER_ROLE=000000000000000000 LOGGING_CHANNEL_ID=0000000000000000001+ -DISCORD_TOKEN=ODk5MTIxMTU5MTUxNDM5OTAy.YWuJ1Q.2QqluYAf0oJP45zWxRBpMjs28os +DISCORD_TOKEN=NDQWCmReCyz0Uf7TX0nw32-3XZNDJQc5AsQDWihYXWNr2.COBpA5idy52C9 EMBED_COLOR=#7289DA LAVALINK_NODES=[{"host": "127.0.0.1", "port": 1337, "password": "passwordlavalink", "region": "asia|eu|us|sam"}] -MONGODB_URI=mongodb+srv://takemehome:takemehome@cluster0.iyvxc.mongodb.net/Cluster0?retryWrites=true&w=majority +MONGODB_URI=mongodb://username:password@example.com:80/example PREFIX=s! SPOTIFY_CLIENT_ID=8w84g2wg7a3gj315rn7dlh7bsicggurf SPOTIFY_CLIENT_SECRET=yr21s12n8q3hulxwtwz21r5xh28dl1g9 TWITCH_CLIENT_ID=4uuc9u4iezex5zadzidv3f0lfm7vyo -YOUTUBE_API_KEY=AIzaSyD3jjoF8ta9kx55Rvb9Nd9n6s98908CDKo +YOUTUBE_API_KEY=Yp1M7jgfnsbhn5azgzlNiw6IldSAXBKzYrTV44w CROWDIN_API_KEY=1DT16vcCjfAS79Ar6sybJfAt23ay2Cko CROWDIN_PROJECT_ID=example GENIUS_API=7WWvbyiaJOfh1PPeRNS3gaHdjB-PgKee5xYRtSh4NgXtbVfZfG9UH4A5vp7EICL3 diff --git a/shard.js b/shard.js index c99948694..eff8c582a 100644 --- a/shard.js +++ b/shard.js @@ -1,7 +1,4 @@ const { ShardingManager } = require('discord.js') -const dotenv = require('dotenv') - -dotenv.config({"path": "./.env.example"}) const manager = new ShardingManager('./index.js', { token: process.env.DISCORD_TOKEN, totalShards: parseInt(process.env.SHARD_COUNT) || 'auto' From dfe0435707d486c30947781c50ee1ecd9fa14e3a Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Mon, 18 Oct 2021 12:09:11 +0530 Subject: [PATCH 12/40] Make requested changes --- src/apis/ITunes.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/apis/ITunes.js b/src/apis/ITunes.js index a1bf01c20..45501a3a6 100644 --- a/src/apis/ITunes.js +++ b/src/apis/ITunes.js @@ -1,23 +1,20 @@ const {APIWrapper} = require('../') const axios = require('axios') +const MEDIA_WHITE_LIST = ['movie', 'podcast', 'music', 'musicVideo', 'audiobook', 'shortFilm', +'tvShow', 'software', 'ebook', 'all'] + module.exports = class ITunes extends APIWrapper { constructor() { super({name: 'itunes'}) } async search(media , term , country) { - const mediaWhiteList = - [ - 'movie', 'podcast', 'music', 'musicVideo', 'audiobook', 'shortFilm', - 'tvShow', 'software', 'ebook', 'all' - ] - - if (!mediaWhiteList.includes(media)) { + if (!MEDIA_WHITE_LIST.includes(media)) { return [{ 'errorMessage': `Invaid term provided. The term has to be one of the following: ${ - mediaWhiteList.join(' , ')}` + MEDIA_WHITE_LIST.join(' , ')}` }] } From a00ed9215f86565087e76cbdceba284d13537294 Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Mon, 18 Oct 2021 12:31:00 +0530 Subject: [PATCH 13/40] Bug fixes --- .env.example | 4 ++-- shard.js | 3 +++ src/apis/{ITunes.js => Itunes.js} | 29 +++++++++++++++++++++-------- 3 files changed, 26 insertions(+), 10 deletions(-) rename src/apis/{ITunes.js => Itunes.js} (64%) diff --git a/.env.example b/.env.example index b2b0157e9..a42feb025 100644 --- a/.env.example +++ b/.env.example @@ -1,10 +1,10 @@ BOT_GUILD=000000000000000000 DEVELOPER_ROLE=000000000000000000 LOGGING_CHANNEL_ID=0000000000000000001+ -DISCORD_TOKEN=NDQWCmReCyz0Uf7TX0nw32-3XZNDJQc5AsQDWihYXWNr2.COBpA5idy52C9 +DISCORD_TOKEN=ODk5MTIxMTU5MTUxNDM5OTAy.YWuJ1Q.PThDsDf-MKUg9kIzHR3sZcl2Mcg EMBED_COLOR=#7289DA LAVALINK_NODES=[{"host": "127.0.0.1", "port": 1337, "password": "passwordlavalink", "region": "asia|eu|us|sam"}] -MONGODB_URI=mongodb://username:password@example.com:80/example +MONGODB_URI=mongodb+srv://takemehome:takemehome@cluster0.iyvxc.mongodb.net/Cluster0?retryWrites=true&w=majority PREFIX=s! SPOTIFY_CLIENT_ID=8w84g2wg7a3gj315rn7dlh7bsicggurf SPOTIFY_CLIENT_SECRET=yr21s12n8q3hulxwtwz21r5xh28dl1g9 diff --git a/shard.js b/shard.js index eff8c582a..c99948694 100644 --- a/shard.js +++ b/shard.js @@ -1,4 +1,7 @@ const { ShardingManager } = require('discord.js') +const dotenv = require('dotenv') + +dotenv.config({"path": "./.env.example"}) const manager = new ShardingManager('./index.js', { token: process.env.DISCORD_TOKEN, totalShards: parseInt(process.env.SHARD_COUNT) || 'auto' diff --git a/src/apis/ITunes.js b/src/apis/Itunes.js similarity index 64% rename from src/apis/ITunes.js rename to src/apis/Itunes.js index 45501a3a6..6167ddf3c 100644 --- a/src/apis/ITunes.js +++ b/src/apis/Itunes.js @@ -1,4 +1,4 @@ -const {APIWrapper} = require('../') +const {APIWrapper} = require('..') const axios = require('axios') const MEDIA_WHITE_LIST = ['movie', 'podcast', 'music', 'musicVideo', 'audiobook', 'shortFilm', @@ -9,7 +9,24 @@ module.exports = class ITunes extends APIWrapper { super({name: 'itunes'}) } - async search(media , term , country) { + async search(query) { + query = query.split(" ") + + const media = query.at(0) + + var term = query.splice(1 , query.length - 2).join(" ") + + var country = query.splice(query.length - 1 , 1).join(" ") + + console.log(media , " - " , term , " - " , country) + + // Check if the country code is 2 letters + if(country.length != 2){ + term += " " + country + + country = "US" + } + if (!MEDIA_WHITE_LIST.includes(media)) { return [{ 'errorMessage': @@ -18,6 +35,8 @@ module.exports = class ITunes extends APIWrapper { }] } + console.log(media , term , country) + try { const {data} = await axios.get(`https://itunes.apple.com/search`, { params: { @@ -37,10 +56,4 @@ module.exports = class ITunes extends APIWrapper { return [{'errorMessage': 'No results found'}] } } - - async getUserCountry() { - const response = await axios.get('https://ipinfo.io') - - return response.data.country - } } \ No newline at end of file From 5fb79b09e8b3b39c9a63c7dfbec850bbd8da7245 Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Mon, 18 Oct 2021 12:31:46 +0530 Subject: [PATCH 14/40] Remove unused lines --- .env.example | 4 ++-- shard.js | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index a42feb025..b2b0157e9 100644 --- a/.env.example +++ b/.env.example @@ -1,10 +1,10 @@ BOT_GUILD=000000000000000000 DEVELOPER_ROLE=000000000000000000 LOGGING_CHANNEL_ID=0000000000000000001+ -DISCORD_TOKEN=ODk5MTIxMTU5MTUxNDM5OTAy.YWuJ1Q.PThDsDf-MKUg9kIzHR3sZcl2Mcg +DISCORD_TOKEN=NDQWCmReCyz0Uf7TX0nw32-3XZNDJQc5AsQDWihYXWNr2.COBpA5idy52C9 EMBED_COLOR=#7289DA LAVALINK_NODES=[{"host": "127.0.0.1", "port": 1337, "password": "passwordlavalink", "region": "asia|eu|us|sam"}] -MONGODB_URI=mongodb+srv://takemehome:takemehome@cluster0.iyvxc.mongodb.net/Cluster0?retryWrites=true&w=majority +MONGODB_URI=mongodb://username:password@example.com:80/example PREFIX=s! SPOTIFY_CLIENT_ID=8w84g2wg7a3gj315rn7dlh7bsicggurf SPOTIFY_CLIENT_SECRET=yr21s12n8q3hulxwtwz21r5xh28dl1g9 diff --git a/shard.js b/shard.js index c99948694..eff8c582a 100644 --- a/shard.js +++ b/shard.js @@ -1,7 +1,4 @@ const { ShardingManager } = require('discord.js') -const dotenv = require('dotenv') - -dotenv.config({"path": "./.env.example"}) const manager = new ShardingManager('./index.js', { token: process.env.DISCORD_TOKEN, totalShards: parseInt(process.env.SHARD_COUNT) || 'auto' From fb05f1561f7e47faacf0f2edabea42b770d70855 Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Tue, 19 Oct 2021 22:02:09 +0530 Subject: [PATCH 15/40] Add Birthday Command --- package-lock.json | 124 ++++++++++-- package.json | 1 + src/commands/misc/birthday.js | 186 ++++++++++++++++++ .../mongo/repositories/RolesRepository.js | 20 ++ src/database/mongo/schemas/RolesSchema.js | 13 ++ src/utils/Constants.js | 1 + 6 files changed, 327 insertions(+), 18 deletions(-) create mode 100644 src/commands/misc/birthday.js create mode 100644 src/database/mongo/repositories/RolesRepository.js create mode 100644 src/database/mongo/schemas/RolesSchema.js diff --git a/package-lock.json b/package-lock.json index f20da4c8e..e3499f2da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -47,6 +47,7 @@ "morgan": "^1.10.0", "ms": "^2.1.3", "node-fetch": "^2.6.1", + "node-schedule": "^2.0.0", "node-spotify-api": "^1.1.1", "node-worker-threads-pool": "^1.5.1", "pirate-speak": "^1.0.1", @@ -1417,7 +1418,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", - "dev": true, "dependencies": { "function-bind": "^1.1.1", "get-intrinsic": "^1.0.2" @@ -2212,6 +2212,18 @@ "node": ">=0.10.0" } }, + "node_modules/cron-parser": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/cron-parser/-/cron-parser-3.5.0.tgz", + "integrity": "sha512-wyVZtbRs6qDfFd8ap457w3XVntdvqcwBGxBoTvJQH9KGVKL/fB+h2k3C8AqiVxvUQKN1Ps/Ns46CNViOpVDhfQ==", + "dependencies": { + "is-nan": "^1.3.2", + "luxon": "^1.26.0" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/cross-fetch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.2.tgz", @@ -2396,7 +2408,6 @@ "version": "1.1.3", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", - "dev": true, "dependencies": { "object-keys": "^1.0.12" }, @@ -4315,8 +4326,7 @@ "node_modules/function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, "node_modules/functional-red-black-tree": { "version": "1.0.1", @@ -4442,7 +4452,6 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", - "dev": true, "dependencies": { "function-bind": "^1.1.1", "has": "^1.0.3", @@ -5376,7 +5385,6 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, "dependencies": { "function-bind": "^1.1.1" }, @@ -5425,7 +5433,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", - "dev": true, "engines": { "node": ">= 0.4" }, @@ -6117,6 +6124,21 @@ "xtend": "^4.0.0" } }, + "node_modules/is-nan": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/is-nan/-/is-nan-1.3.2.tgz", + "integrity": "sha512-E+zBKpQ2t6MEo1VsonYmluk9NxGrbzpeeLC2xIViuO2EjU2xsXsBPwTr3Ykv9l08UYEVEdWeRZNouaZqF6RN0w==", + "dependencies": { + "call-bind": "^1.0.0", + "define-properties": "^1.1.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/is-negative-zero": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.1.tgz", @@ -7045,6 +7067,11 @@ "node": ">=0.8.0" } }, + "node_modules/long-timeout": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/long-timeout/-/long-timeout-0.1.1.tgz", + "integrity": "sha1-lyHXiLR+C8taJMLivuGg2lXatRQ=" + }, "node_modules/loose-envify": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", @@ -7090,6 +7117,14 @@ "es5-ext": "~0.10.2" } }, + "node_modules/luxon": { + "version": "1.28.0", + "resolved": "https://registry.npmjs.org/luxon/-/luxon-1.28.0.tgz", + "integrity": "sha512-TfTiyvZhwBYM/7QdAVDh+7dBTBA29v4ik0Ce9zda3Mnf8on1S5KJI8P2jKFZ8+5C0jhmr0KwJEO/Wdpm0VeWJQ==", + "engines": { + "node": "*" + } + }, "node_modules/make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", @@ -8298,6 +8333,19 @@ "integrity": "sha1-FK1hE4EtLTfXLme0ystLtyZQXxE=", "optional": true }, + "node_modules/node-schedule": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/node-schedule/-/node-schedule-2.0.0.tgz", + "integrity": "sha512-cHc9KEcfiuXxYDU+HjsBVo2FkWL1jRAUoczFoMIzRBpOA4p/NRHuuLs85AWOLgKsHtSPjN8csvwIxc2SqMv+CQ==", + "dependencies": { + "cron-parser": "^3.1.0", + "long-timeout": "0.1.1", + "sorted-array-functions": "^1.3.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/node-source-walk": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/node-source-walk/-/node-source-walk-3.3.0.tgz", @@ -8857,7 +8905,6 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", - "dev": true, "engines": { "node": ">= 0.4" } @@ -11312,6 +11359,11 @@ "node": ">=0.8.0" } }, + "node_modules/sorted-array-functions": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/sorted-array-functions/-/sorted-array-functions-1.3.0.tgz", + "integrity": "sha512-2sqgzeFlid6N4Z2fUQ1cvFmTOLRi/sEDzSQ0OKYchqgoPmQBVyM3959qYx3fpS6Esef80KjmpgPeEr028dP3OA==" + }, "node_modules/source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", @@ -14575,7 +14627,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", - "dev": true, "requires": { "function-bind": "^1.1.1", "get-intrinsic": "^1.0.2" @@ -15190,6 +15241,15 @@ "capture-stack-trace": "^1.0.0" } }, + "cron-parser": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/cron-parser/-/cron-parser-3.5.0.tgz", + "integrity": "sha512-wyVZtbRs6qDfFd8ap457w3XVntdvqcwBGxBoTvJQH9KGVKL/fB+h2k3C8AqiVxvUQKN1Ps/Ns46CNViOpVDhfQ==", + "requires": { + "is-nan": "^1.3.2", + "luxon": "^1.26.0" + } + }, "cross-fetch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.2.tgz", @@ -15332,7 +15392,6 @@ "version": "1.1.3", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", - "dev": true, "requires": { "object-keys": "^1.0.12" } @@ -16774,8 +16833,7 @@ "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, "functional-red-black-tree": { "version": "1.0.1", @@ -16882,7 +16940,6 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", - "dev": true, "requires": { "function-bind": "^1.1.1", "has": "^1.0.3", @@ -17621,7 +17678,6 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, "requires": { "function-bind": "^1.1.1" } @@ -17656,8 +17712,7 @@ "has-symbols": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", - "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", - "dev": true + "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==" }, "has-tostringtag": { "version": "1.0.0", @@ -18170,6 +18225,15 @@ "xtend": "^4.0.0" } }, + "is-nan": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/is-nan/-/is-nan-1.3.2.tgz", + "integrity": "sha512-E+zBKpQ2t6MEo1VsonYmluk9NxGrbzpeeLC2xIViuO2EjU2xsXsBPwTr3Ykv9l08UYEVEdWeRZNouaZqF6RN0w==", + "requires": { + "call-bind": "^1.0.0", + "define-properties": "^1.1.3" + } + }, "is-negative-zero": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.1.tgz", @@ -18923,6 +18987,11 @@ } } }, + "long-timeout": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/long-timeout/-/long-timeout-0.1.1.tgz", + "integrity": "sha1-lyHXiLR+C8taJMLivuGg2lXatRQ=" + }, "loose-envify": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", @@ -18959,6 +19028,11 @@ "es5-ext": "~0.10.2" } }, + "luxon": { + "version": "1.28.0", + "resolved": "https://registry.npmjs.org/luxon/-/luxon-1.28.0.tgz", + "integrity": "sha512-TfTiyvZhwBYM/7QdAVDh+7dBTBA29v4ik0Ce9zda3Mnf8on1S5KJI8P2jKFZ8+5C0jhmr0KwJEO/Wdpm0VeWJQ==" + }, "make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", @@ -19873,6 +19947,16 @@ } } }, + "node-schedule": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/node-schedule/-/node-schedule-2.0.0.tgz", + "integrity": "sha512-cHc9KEcfiuXxYDU+HjsBVo2FkWL1jRAUoczFoMIzRBpOA4p/NRHuuLs85AWOLgKsHtSPjN8csvwIxc2SqMv+CQ==", + "requires": { + "cron-parser": "^3.1.0", + "long-timeout": "0.1.1", + "sorted-array-functions": "^1.3.0" + } + }, "node-source-walk": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/node-source-walk/-/node-source-walk-3.3.0.tgz", @@ -20296,8 +20380,7 @@ "object-keys": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", - "dev": true + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==" }, "object-visit": { "version": "1.0.1", @@ -22234,6 +22317,11 @@ "hoek": "2.x.x" } }, + "sorted-array-functions": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/sorted-array-functions/-/sorted-array-functions-1.3.0.tgz", + "integrity": "sha512-2sqgzeFlid6N4Z2fUQ1cvFmTOLRi/sEDzSQ0OKYchqgoPmQBVyM3959qYx3fpS6Esef80KjmpgPeEr028dP3OA==" + }, "source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", diff --git a/package.json b/package.json index 7725f63d9..8d60ba079 100644 --- a/package.json +++ b/package.json @@ -70,6 +70,7 @@ "morgan": "^1.10.0", "ms": "^2.1.3", "node-fetch": "^2.6.1", + "node-schedule": "^2.0.0", "node-spotify-api": "^1.1.1", "node-worker-threads-pool": "^1.5.1", "pirate-speak": "^1.0.1", diff --git a/src/commands/misc/birthday.js b/src/commands/misc/birthday.js new file mode 100644 index 000000000..0017ae0d1 --- /dev/null +++ b/src/commands/misc/birthday.js @@ -0,0 +1,186 @@ +const { Command , SwitchbladeEmbed , Constants} = require('../../') +const mongoose = require('mongoose') +const moment = require('moment') +const schedule = require("node-schedule") +const RolesRepository = require("../../database/mongo/repositories/RolesRepository") + +module.exports = class Birthday extends Command { + constructor(client) { + super( + { + name: 'birthday', + parameters: [{ + type: 'string', + full: false, + clean: true, + missingError: "commands:birthday.missingSentence" + } , { + type: "string", + full: false, + clean: true, + }] + }, + client) + + this.mongo = new RolesRepository(mongoose) + + this.rolesMap = new Map() + + const rule = new schedule.RecurrenceRule() + + rule.hour = 22 + + rule.minute = 0 + + schedule.scheduleJob(rule , this.checkForBirthdays) + } + + run({ channel, message }, subCommand , term) { + if(subCommand === "role"){ + this.setRole(channel , message , term) + } else{ + this.setUserBirthday(channel , message , term) + } + } + + async setRole(channel , message , term){ + const user = message.mentions.users.first() || message.author; + + var flag = true + + message.guild.member(user).roles.cache.forEach(r => { + if(r.name === "MANAGE_ROLE"){ + flag = false + + return + } + }) + + if(flag){ + this.sendEmbed(channel , message.author.username , "Invalid Permissions" , "You cannot set the gift role because you do not have the role of MANAGE_ROLE!" , Constants.ERROR_COLOR) + + return + } + + flag = true + + message.guild.roles.cache.forEach(r => { + if(r.id === term || r.name === term){ + flag = false + + return + } + }) + + if(flag){ + this.sendEmbed(channel , message.author.username , "Invalid Role" , `Sorry, but it looks like role ${term} does not exist.` , Constants.ERROR_COLOR) + + return + } + + await this.mongo.update("role" , {"giftedRole": term}) + + this.sendEmbed(channel , "Success" , `Role ${term} will be given to member's birthday!` , Constants.SUCCESS_COLOR) + } + + sendEmbed(channel , user , title , description , color){ + const embed = new SwitchbladeEmbed() + .setTitle(title) + .setFooter(user) + .setDescription(description) + .setColor(color) + + channel.send(embed) + } + + async setUserBirthday(channel , message , term) { + const username = await message.author.username + + const dateInMoment = moment(term , "DD/MM" , true) + + if(!dateInMoment.isValid()) { + this.sendEmbed(channel , username , "Invalid Date" , `Invalid date ${term}. Make sure it is in format of DD/MM` , Constants.ERROR_COLOR) + + return + } + + const currentUsers = await this.mongo.get("role") + + let flag = false + + for(const [index , user] of currentUsers.users.entries()){ + if(user.username === username){ + const entity = {} + + const newKeyValue = {} + + newKeyValue[`users.${index}.birthday`] = term + + entity["$set"] = newKeyValue + + await this.mongo.update("role" , entity , { upsert: false }) + + flag = true + + break + } + } + + if(!flag){ + this.callback(username , term) + } + + this.sendEmbed(channel , username , "Success" , "Successfully added your birthday" , Constants.SUCCESS_COLOR) + } + + async callback(username , term) { + await this.mongo.update("role" ,{ + "$push": { + "users": { + "username": username, + "birthday": term + } + } + }) + } + + checkForBirthdays = async () => { + try{ + + const guildId = Array.from(this.client.guilds.cache)[0][0] + + const list = this.client.guilds.cache.get(guildId) + + this.client.guilds.cache.first().roles.cache.forEach(role => { + this.rolesMap[role.name] = role + }) + + this.mongo.get("role").then((res) => { + const giftRole = res.giftedRole + + if(giftRole === "") return + + const birthdayUsers = [] + + for(let user of res.users){ + const currentDate = moment() + + currentDate.format("DD/MM") + + const userBirthday = moment(user.birthday , "DD/MM" , true) + + if(currentDate.date() === userBirthday.date()){ + birthdayUsers.push(user.username) + } + } + + list.members.cache.array().forEach(async member => { + if(birthdayUsers.includes(member.user.username)){ + await member.roles.add(this.rolesMap[giftRole]) + } + }) + }) + } + catch{ } + } +} diff --git a/src/database/mongo/repositories/RolesRepository.js b/src/database/mongo/repositories/RolesRepository.js new file mode 100644 index 000000000..af3cd11ed --- /dev/null +++ b/src/database/mongo/repositories/RolesRepository.js @@ -0,0 +1,20 @@ +const MongoRepository = require('../MongoRepository.js') +const RolesSchema = require('../schemas/RolesSchema.js') + +module.exports = class RolesRepository extends MongoRepository { + constructor (mongoose) { + super(mongoose, mongoose.model('Roles', RolesSchema)) + } + + parse (entity) { + return { + giftedRole: "", + users: [], + ...(super.parse(entity) || {}) + } + } + + // update(filter , entity , options = { "upsert": true }) { + // return this.model.updateOne(filter, entity, options) + // } +} diff --git a/src/database/mongo/schemas/RolesSchema.js b/src/database/mongo/schemas/RolesSchema.js new file mode 100644 index 000000000..02f34e900 --- /dev/null +++ b/src/database/mongo/schemas/RolesSchema.js @@ -0,0 +1,13 @@ +const { Schema } = require('mongoose') + +module.exports = new Schema({ + _id: String, + giftedRole: { + type: String, + default: '' + }, + users: { + type: Array, + default: [] + } +}) diff --git a/src/utils/Constants.js b/src/utils/Constants.js index 7dac12f03..3cfa964c1 100644 --- a/src/utils/Constants.js +++ b/src/utils/Constants.js @@ -12,6 +12,7 @@ module.exports = { XKCD_COLOR: '#96A8C8', DEEZER_COLOR: '#00C7F2', MAL_COLOR: '#2E51A2', + SUCCESS_COLOR: '#A3BE8C', GELBOORU_COLOR: '#2887FD', GENIUS_COLOR: '#FFFB66', GUILD_LOST_COLOR: '#BD4351', From d83c670f3232f26fd6119fc7fb31912008f39727 Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Tue, 19 Oct 2021 22:02:50 +0530 Subject: [PATCH 16/40] Configure time --- src/commands/misc/birthday.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/misc/birthday.js b/src/commands/misc/birthday.js index 0017ae0d1..701de8467 100644 --- a/src/commands/misc/birthday.js +++ b/src/commands/misc/birthday.js @@ -28,7 +28,7 @@ module.exports = class Birthday extends Command { const rule = new schedule.RecurrenceRule() - rule.hour = 22 + rule.hour = 0 rule.minute = 0 From b672ee03b3bb9885b22c07062539477946d351c0 Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Tue, 19 Oct 2021 22:07:35 +0530 Subject: [PATCH 17/40] Revert last commit --- src/commands/misc/birthday.js | 186 ------------------ .../mongo/repositories/RolesRepository.js | 20 -- src/database/mongo/schemas/RolesSchema.js | 13 -- src/utils/Constants.js | 1 - 4 files changed, 220 deletions(-) delete mode 100644 src/commands/misc/birthday.js delete mode 100644 src/database/mongo/repositories/RolesRepository.js delete mode 100644 src/database/mongo/schemas/RolesSchema.js diff --git a/src/commands/misc/birthday.js b/src/commands/misc/birthday.js deleted file mode 100644 index 701de8467..000000000 --- a/src/commands/misc/birthday.js +++ /dev/null @@ -1,186 +0,0 @@ -const { Command , SwitchbladeEmbed , Constants} = require('../../') -const mongoose = require('mongoose') -const moment = require('moment') -const schedule = require("node-schedule") -const RolesRepository = require("../../database/mongo/repositories/RolesRepository") - -module.exports = class Birthday extends Command { - constructor(client) { - super( - { - name: 'birthday', - parameters: [{ - type: 'string', - full: false, - clean: true, - missingError: "commands:birthday.missingSentence" - } , { - type: "string", - full: false, - clean: true, - }] - }, - client) - - this.mongo = new RolesRepository(mongoose) - - this.rolesMap = new Map() - - const rule = new schedule.RecurrenceRule() - - rule.hour = 0 - - rule.minute = 0 - - schedule.scheduleJob(rule , this.checkForBirthdays) - } - - run({ channel, message }, subCommand , term) { - if(subCommand === "role"){ - this.setRole(channel , message , term) - } else{ - this.setUserBirthday(channel , message , term) - } - } - - async setRole(channel , message , term){ - const user = message.mentions.users.first() || message.author; - - var flag = true - - message.guild.member(user).roles.cache.forEach(r => { - if(r.name === "MANAGE_ROLE"){ - flag = false - - return - } - }) - - if(flag){ - this.sendEmbed(channel , message.author.username , "Invalid Permissions" , "You cannot set the gift role because you do not have the role of MANAGE_ROLE!" , Constants.ERROR_COLOR) - - return - } - - flag = true - - message.guild.roles.cache.forEach(r => { - if(r.id === term || r.name === term){ - flag = false - - return - } - }) - - if(flag){ - this.sendEmbed(channel , message.author.username , "Invalid Role" , `Sorry, but it looks like role ${term} does not exist.` , Constants.ERROR_COLOR) - - return - } - - await this.mongo.update("role" , {"giftedRole": term}) - - this.sendEmbed(channel , "Success" , `Role ${term} will be given to member's birthday!` , Constants.SUCCESS_COLOR) - } - - sendEmbed(channel , user , title , description , color){ - const embed = new SwitchbladeEmbed() - .setTitle(title) - .setFooter(user) - .setDescription(description) - .setColor(color) - - channel.send(embed) - } - - async setUserBirthday(channel , message , term) { - const username = await message.author.username - - const dateInMoment = moment(term , "DD/MM" , true) - - if(!dateInMoment.isValid()) { - this.sendEmbed(channel , username , "Invalid Date" , `Invalid date ${term}. Make sure it is in format of DD/MM` , Constants.ERROR_COLOR) - - return - } - - const currentUsers = await this.mongo.get("role") - - let flag = false - - for(const [index , user] of currentUsers.users.entries()){ - if(user.username === username){ - const entity = {} - - const newKeyValue = {} - - newKeyValue[`users.${index}.birthday`] = term - - entity["$set"] = newKeyValue - - await this.mongo.update("role" , entity , { upsert: false }) - - flag = true - - break - } - } - - if(!flag){ - this.callback(username , term) - } - - this.sendEmbed(channel , username , "Success" , "Successfully added your birthday" , Constants.SUCCESS_COLOR) - } - - async callback(username , term) { - await this.mongo.update("role" ,{ - "$push": { - "users": { - "username": username, - "birthday": term - } - } - }) - } - - checkForBirthdays = async () => { - try{ - - const guildId = Array.from(this.client.guilds.cache)[0][0] - - const list = this.client.guilds.cache.get(guildId) - - this.client.guilds.cache.first().roles.cache.forEach(role => { - this.rolesMap[role.name] = role - }) - - this.mongo.get("role").then((res) => { - const giftRole = res.giftedRole - - if(giftRole === "") return - - const birthdayUsers = [] - - for(let user of res.users){ - const currentDate = moment() - - currentDate.format("DD/MM") - - const userBirthday = moment(user.birthday , "DD/MM" , true) - - if(currentDate.date() === userBirthday.date()){ - birthdayUsers.push(user.username) - } - } - - list.members.cache.array().forEach(async member => { - if(birthdayUsers.includes(member.user.username)){ - await member.roles.add(this.rolesMap[giftRole]) - } - }) - }) - } - catch{ } - } -} diff --git a/src/database/mongo/repositories/RolesRepository.js b/src/database/mongo/repositories/RolesRepository.js deleted file mode 100644 index af3cd11ed..000000000 --- a/src/database/mongo/repositories/RolesRepository.js +++ /dev/null @@ -1,20 +0,0 @@ -const MongoRepository = require('../MongoRepository.js') -const RolesSchema = require('../schemas/RolesSchema.js') - -module.exports = class RolesRepository extends MongoRepository { - constructor (mongoose) { - super(mongoose, mongoose.model('Roles', RolesSchema)) - } - - parse (entity) { - return { - giftedRole: "", - users: [], - ...(super.parse(entity) || {}) - } - } - - // update(filter , entity , options = { "upsert": true }) { - // return this.model.updateOne(filter, entity, options) - // } -} diff --git a/src/database/mongo/schemas/RolesSchema.js b/src/database/mongo/schemas/RolesSchema.js deleted file mode 100644 index 02f34e900..000000000 --- a/src/database/mongo/schemas/RolesSchema.js +++ /dev/null @@ -1,13 +0,0 @@ -const { Schema } = require('mongoose') - -module.exports = new Schema({ - _id: String, - giftedRole: { - type: String, - default: '' - }, - users: { - type: Array, - default: [] - } -}) diff --git a/src/utils/Constants.js b/src/utils/Constants.js index 3cfa964c1..7dac12f03 100644 --- a/src/utils/Constants.js +++ b/src/utils/Constants.js @@ -12,7 +12,6 @@ module.exports = { XKCD_COLOR: '#96A8C8', DEEZER_COLOR: '#00C7F2', MAL_COLOR: '#2E51A2', - SUCCESS_COLOR: '#A3BE8C', GELBOORU_COLOR: '#2887FD', GENIUS_COLOR: '#FFFB66', GUILD_LOST_COLOR: '#BD4351', From 1ca785618c49179cdc0a314b6bdb6dcfcaf86035 Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Fri, 22 Oct 2021 07:49:14 +0530 Subject: [PATCH 18/40] Make requested changes --- .env.example | 4 +- shard.js | 4 + src/apis/Itunes.js | 50 +++--------- src/commands/misc/itunes.js | 135 +++++++++++++++----------------- src/locales/en-US/commands.json | 5 +- src/utils/Constants.js | 2 +- 6 files changed, 85 insertions(+), 115 deletions(-) diff --git a/.env.example b/.env.example index b2b0157e9..1ce99361d 100644 --- a/.env.example +++ b/.env.example @@ -1,10 +1,10 @@ BOT_GUILD=000000000000000000 DEVELOPER_ROLE=000000000000000000 LOGGING_CHANNEL_ID=0000000000000000001+ -DISCORD_TOKEN=NDQWCmReCyz0Uf7TX0nw32-3XZNDJQc5AsQDWihYXWNr2.COBpA5idy52C9 +DISCORD_TOKEN=ODk5MTIxMTU5MTUxNDM5OTAy.YWuJ1Q.CrhgtUxtMI0WQ_gy3qOM-qD6KH0 EMBED_COLOR=#7289DA LAVALINK_NODES=[{"host": "127.0.0.1", "port": 1337, "password": "passwordlavalink", "region": "asia|eu|us|sam"}] -MONGODB_URI=mongodb://username:password@example.com:80/example +MONGODB_URI=mongodb+srv://myname:issasukeuchiha@chessqt.osusz.mongodb.net/ChessQt?retryWrites=true&w=majority PREFIX=s! SPOTIFY_CLIENT_ID=8w84g2wg7a3gj315rn7dlh7bsicggurf SPOTIFY_CLIENT_SECRET=yr21s12n8q3hulxwtwz21r5xh28dl1g9 diff --git a/shard.js b/shard.js index eff8c582a..3014c5b7a 100644 --- a/shard.js +++ b/shard.js @@ -1,4 +1,8 @@ const { ShardingManager } = require('discord.js') +const dotenv = require('dotenv') + +dotenv.config({"path": "./.env.example"}) + const manager = new ShardingManager('./index.js', { token: process.env.DISCORD_TOKEN, totalShards: parseInt(process.env.SHARD_COUNT) || 'auto' diff --git a/src/apis/Itunes.js b/src/apis/Itunes.js index 6167ddf3c..0f2ea822c 100644 --- a/src/apis/Itunes.js +++ b/src/apis/Itunes.js @@ -1,59 +1,29 @@ -const {APIWrapper} = require('..') +const { APIWrapper } = require('..') const axios = require('axios') -const MEDIA_WHITE_LIST = ['movie', 'podcast', 'music', 'musicVideo', 'audiobook', 'shortFilm', -'tvShow', 'software', 'ebook', 'all'] - module.exports = class ITunes extends APIWrapper { - constructor() { - super({name: 'itunes'}) + constructor () { + super({ name: 'itunes' }) } - async search(query) { - query = query.split(" ") - - const media = query.at(0) - - var term = query.splice(1 , query.length - 2).join(" ") - - var country = query.splice(query.length - 1 , 1).join(" ") - - console.log(media , " - " , term , " - " , country) - - // Check if the country code is 2 letters - if(country.length != 2){ - term += " " + country - - country = "US" - } - - if (!MEDIA_WHITE_LIST.includes(media)) { - return [{ - 'errorMessage': - `Invaid term provided. The term has to be one of the following: ${ - MEDIA_WHITE_LIST.join(' , ')}` - }] - } - - console.log(media , term , country) - + async search (media , term , country) { try { - const {data} = await axios.get(`https://itunes.apple.com/search`, { + const { data } = await axios.get('https://itunes.apple.com/search', { params: { media: media, term: term, country: country, - limit: 10, + limit: 10 } }) - if (data.results == 0) { + if (data.results === 0) { throw new Error() } return data.results - } catch { - return [{'errorMessage': 'No results found'}] + } catch(err) { + return [] } } -} \ No newline at end of file +} diff --git a/src/commands/misc/itunes.js b/src/commands/misc/itunes.js index 34da9eef8..6aaf38cbc 100644 --- a/src/commands/misc/itunes.js +++ b/src/commands/misc/itunes.js @@ -1,91 +1,84 @@ -const {SwitchbladeEmbed, SearchCommand, Constants, CommandStructures} = - require('../../') -const {Command, CommandParameters, StringParameter} = CommandStructures +const { SwitchbladeEmbed, Constants, Command } = require('../../') const moment = require('moment') -module.exports = class Itunes extends SearchCommand { - constructor(client) { - super( - { - name: 'itunes', - requirements: {apis: ['itunes']}, - embedColor: Constants.ITUNES_COLOR, - embedLogoURL: 'https://i.imgur.com/K8uqCSw.png', +const MEDIA_WHITE_LIST = ['movie', 'podcast', 'music', 'musicVideo', 'audiobook', 'shortFilm', 'tvShow', 'software', 'ebook', 'all'] + +module.exports = class Itunes extends Command { + constructor (client) { + super({ + name: 'itunes', + requirements: { apis: ['itunes'] }, + parameters: [{ + type: "string", + full: false, + name: "media", + whitelist: MEDIA_WHITE_LIST, + missingError: ({ t, prefix }) => { + return new SwitchbladeEmbed().setTitle(t('commands:itunes.noMedia')) + .setDescription([ + this.usage(t, prefix), + '', + `__**${t('commands:itunes.availableMedia')}:**__`, + `**${MEDIA_WHITE_LIST.map(l => `\`${l}\``).join(', ')}**` + ].join('\n')) }, - client); + required: true, + } , { + type: "string", + full: true, + name: "term", + required: true, + }, { + type: "string", + full: false, + name: "country", + required: false, + }] + }, + client) + + this.author = null + + this.embedUrl = "https://i.imgur.com/U4jjk5F.png" + } - async search(_, query) { - const data = await this.client.apis.itunes.search(query) + async run (context , media , term , country = "US") { + this.author = context.author - return await data; + const data = await this.client.apis.itunes.search(media , term , country) + + this.parseResponse(context , await data , context.message.content) } - searchResultFormatter(i) { - if (!i.error) { - return `[${i.trackName}](${i.trackViewUrl}) - [${i.artistName}](${ - i.artistViewUrl})` - } else { - return i.error - } + searchResultFormatter (i) { + return `[${i.trackName}](${i.trackViewUrl}) - [${i.artistName}](${i.artistViewUrl})` } - getRatingEmojis(rating) { + getRatingEmojis (rating) { return (this.getEmoji('ratingstar', '⭐').repeat(Math.floor(rating))) + - (this.getEmoji('ratinghalfstar') - .repeat(Math.ceil(rating - Math.floor(rating)))) + (this.getEmoji('ratinghalfstar') + .repeat(Math.ceil(rating - Math.floor(rating)))) } + + async parseResponse({ channel , author, t } , data , title) { + var description = "" - async handleResult({t, author, channel}, data) { - if (data.errorMessage) { - const embed = new SwitchbladeEmbed(author) - .setColor(Constants.ERROR_COLOR) - .setTitle(data.errorMessage) + var index = 1 - channel.send(embed) + const formatNumber = (n) => Number(n) > 9 ? n : '0' + n - return - } + for(let item of data){ + description += `\`${formatNumber(index)}\`: ${this.searchResultFormatter(item)} \n` + index++ + } - const stars = this.getRatingEmojis(data.averageUserRating) - - const embed = - new SwitchbladeEmbed(author) - .setColor(this.embedColor) - .setAuthor( - t('commands:itunes.place'), this.embedLogoURL, - 'https://www.apple.com/itunes/') - .setURL(data.trackViewUrl) - .setTitle( - t('commands:itunes.track', - {name: data.trackName, artistName: data.artistName})) - .setThumbnail(data.artworkUrl100) - .setDescriptionFromBlockArray([ - [data.description ? `Description: ${ - data.description.replace( - new RegExp('<[^>]*>', 'g'), '')}` : - data.longDescription ? - `Description: ${data.longDescription}` : - ''], - [ - data.userRatingCount ? t('commands:itunes.ratingCount', - {count: data.userRatingCount || 0}) : - '', - data.averageUserRating ? - `Rating: ${stars} (${ - Math.round(data.averageUserRating) || ''})` : - '' - ], - [t('commands:itunes.price', { - price: data.formattedPrice || data.trackPrice, - currency: data.currency - })], - [t('commands:itunes.release', - {date: moment(data.releaseDate).format('DD/MM/YYYY')})], - [`Genres: ${(data.genres || ['-']).join(' , ')}`] - ]) + const embed = new SwitchbladeEmbed(author) + .setThumbnail(this.embedUrl) + .setDescription(description) + .setTitle(t("commands:itunes.title" , { title: title })) channel.send(embed) } -} \ No newline at end of file +} diff --git a/src/locales/en-US/commands.json b/src/locales/en-US/commands.json index 3d7e5bc30..287c4fe31 100644 --- a/src/locales/en-US/commands.json +++ b/src/locales/en-US/commands.json @@ -674,10 +674,13 @@ }, "itunes": { "commandDescription": "Provides the content within the iTunes Store and Apple Books Store.", - "commandUsage": " ", + "commandUsage": " ", "example": "s!itunes ebook Famous Five", "place": "Itunes Store", + "title": "Showing Results for {{title}}.", "track": "{{name}} - {{artistName}}", + "noMedia": "You will have to give me a valid type of media", + "availableMedia": "All the available media's are", "ratingCount": "Rating Count: {{count}}", "price": "Price: {{price}} ({{currency}})", "release": "Release Date: {{date}}", diff --git a/src/utils/Constants.js b/src/utils/Constants.js index 7dac12f03..af46ad06c 100644 --- a/src/utils/Constants.js +++ b/src/utils/Constants.js @@ -6,7 +6,7 @@ module.exports = { ERROR_COLOR: '#FF3333', EIGHTBALL_COLOR: '#000000', NPM_COLOR: '#CB3837', - ITUNES_COLOR: "#FF6283", + ITUNES_COLOR: '#FF6283', GENERIC_RED_COLOR: '#CB3837', E621_COLOR: '#258CF5', XKCD_COLOR: '#96A8C8', From 98dd31e74ec79fc0eaf6cc7ead8b1e84398651dd Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Fri, 22 Oct 2021 07:51:11 +0530 Subject: [PATCH 19/40] Remove unnecessary lines --- .env.example | 4 ++-- shard.js | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.env.example b/.env.example index 1ce99361d..b2b0157e9 100644 --- a/.env.example +++ b/.env.example @@ -1,10 +1,10 @@ BOT_GUILD=000000000000000000 DEVELOPER_ROLE=000000000000000000 LOGGING_CHANNEL_ID=0000000000000000001+ -DISCORD_TOKEN=ODk5MTIxMTU5MTUxNDM5OTAy.YWuJ1Q.CrhgtUxtMI0WQ_gy3qOM-qD6KH0 +DISCORD_TOKEN=NDQWCmReCyz0Uf7TX0nw32-3XZNDJQc5AsQDWihYXWNr2.COBpA5idy52C9 EMBED_COLOR=#7289DA LAVALINK_NODES=[{"host": "127.0.0.1", "port": 1337, "password": "passwordlavalink", "region": "asia|eu|us|sam"}] -MONGODB_URI=mongodb+srv://myname:issasukeuchiha@chessqt.osusz.mongodb.net/ChessQt?retryWrites=true&w=majority +MONGODB_URI=mongodb://username:password@example.com:80/example PREFIX=s! SPOTIFY_CLIENT_ID=8w84g2wg7a3gj315rn7dlh7bsicggurf SPOTIFY_CLIENT_SECRET=yr21s12n8q3hulxwtwz21r5xh28dl1g9 diff --git a/shard.js b/shard.js index 3014c5b7a..eff8c582a 100644 --- a/shard.js +++ b/shard.js @@ -1,8 +1,4 @@ const { ShardingManager } = require('discord.js') -const dotenv = require('dotenv') - -dotenv.config({"path": "./.env.example"}) - const manager = new ShardingManager('./index.js', { token: process.env.DISCORD_TOKEN, totalShards: parseInt(process.env.SHARD_COUNT) || 'auto' From e2045ac13226254da10982f9b8edbdb1545b58d8 Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Fri, 22 Oct 2021 07:52:09 +0530 Subject: [PATCH 20/40] Formatting --- src/apis/Itunes.js | 4 ++-- src/commands/misc/itunes.js | 48 ++++++++++++++++++------------------- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/apis/Itunes.js b/src/apis/Itunes.js index 0f2ea822c..e01c93551 100644 --- a/src/apis/Itunes.js +++ b/src/apis/Itunes.js @@ -6,7 +6,7 @@ module.exports = class ITunes extends APIWrapper { super({ name: 'itunes' }) } - async search (media , term , country) { + async search (media, term, country) { try { const { data } = await axios.get('https://itunes.apple.com/search', { params: { @@ -22,7 +22,7 @@ module.exports = class ITunes extends APIWrapper { } return data.results - } catch(err) { + } catch (err) { return [] } } diff --git a/src/commands/misc/itunes.js b/src/commands/misc/itunes.js index 6aaf38cbc..509b70dc1 100644 --- a/src/commands/misc/itunes.js +++ b/src/commands/misc/itunes.js @@ -1,5 +1,4 @@ -const { SwitchbladeEmbed, Constants, Command } = require('../../') -const moment = require('moment') +const { SwitchbladeEmbed, Command } = require('../../') const MEDIA_WHITE_LIST = ['movie', 'podcast', 'music', 'musicVideo', 'audiobook', 'shortFilm', 'tvShow', 'software', 'ebook', 'all'] @@ -9,9 +8,9 @@ module.exports = class Itunes extends Command { name: 'itunes', requirements: { apis: ['itunes'] }, parameters: [{ - type: "string", + type: 'string', full: false, - name: "media", + name: 'media', whitelist: MEDIA_WHITE_LIST, missingError: ({ t, prefix }) => { return new SwitchbladeEmbed().setTitle(t('commands:itunes.noMedia')) @@ -22,33 +21,32 @@ module.exports = class Itunes extends Command { `**${MEDIA_WHITE_LIST.map(l => `\`${l}\``).join(', ')}**` ].join('\n')) }, - required: true, - } , { - type: "string", + required: true + }, { + type: 'string', full: true, - name: "term", - required: true, + name: 'term', + required: true }, { - type: "string", + type: 'string', full: false, - name: "country", - required: false, + name: 'country', + required: false }] }, client) this.author = null - this.embedUrl = "https://i.imgur.com/U4jjk5F.png" - + this.embedUrl = 'https://i.imgur.com/U4jjk5F.png' } - async run (context , media , term , country = "US") { + async run (context, media, term, country = 'US') { this.author = context.author - const data = await this.client.apis.itunes.search(media , term , country) + const data = await this.client.apis.itunes.search(media, term, country) - this.parseResponse(context , await data , context.message.content) + this.parseResponse(context, await data, context.message.content) } searchResultFormatter (i) { @@ -60,24 +58,24 @@ module.exports = class Itunes extends Command { (this.getEmoji('ratinghalfstar') .repeat(Math.ceil(rating - Math.floor(rating)))) } - - async parseResponse({ channel , author, t } , data , title) { - var description = "" - var index = 1 + async parseResponse ({ channel, author, t }, data, title) { + let description = '' + + let index = 1 const formatNumber = (n) => Number(n) > 9 ? n : '0' + n - for(let item of data){ + for (const item of data) { description += `\`${formatNumber(index)}\`: ${this.searchResultFormatter(item)} \n` index++ } const embed = new SwitchbladeEmbed(author) - .setThumbnail(this.embedUrl) - .setDescription(description) - .setTitle(t("commands:itunes.title" , { title: title })) + .setThumbnail(this.embedUrl) + .setDescription(description) + .setTitle(t('commands:itunes.title', { title: title })) channel.send(embed) } From 3290cfce09a61393438e8c5bc579ee7e881146ce Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Sat, 23 Oct 2021 20:01:24 +0530 Subject: [PATCH 21/40] Make requested changes --- package-lock.json | 124 +++++++--------------------------------------- package.json | 1 - 2 files changed, 18 insertions(+), 107 deletions(-) diff --git a/package-lock.json b/package-lock.json index e3499f2da..f20da4c8e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -47,7 +47,6 @@ "morgan": "^1.10.0", "ms": "^2.1.3", "node-fetch": "^2.6.1", - "node-schedule": "^2.0.0", "node-spotify-api": "^1.1.1", "node-worker-threads-pool": "^1.5.1", "pirate-speak": "^1.0.1", @@ -1418,6 +1417,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "dev": true, "dependencies": { "function-bind": "^1.1.1", "get-intrinsic": "^1.0.2" @@ -2212,18 +2212,6 @@ "node": ">=0.10.0" } }, - "node_modules/cron-parser": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/cron-parser/-/cron-parser-3.5.0.tgz", - "integrity": "sha512-wyVZtbRs6qDfFd8ap457w3XVntdvqcwBGxBoTvJQH9KGVKL/fB+h2k3C8AqiVxvUQKN1Ps/Ns46CNViOpVDhfQ==", - "dependencies": { - "is-nan": "^1.3.2", - "luxon": "^1.26.0" - }, - "engines": { - "node": ">=0.8" - } - }, "node_modules/cross-fetch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.2.tgz", @@ -2408,6 +2396,7 @@ "version": "1.1.3", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "dev": true, "dependencies": { "object-keys": "^1.0.12" }, @@ -4326,7 +4315,8 @@ "node_modules/function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true }, "node_modules/functional-red-black-tree": { "version": "1.0.1", @@ -4452,6 +4442,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", + "dev": true, "dependencies": { "function-bind": "^1.1.1", "has": "^1.0.3", @@ -5385,6 +5376,7 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, "dependencies": { "function-bind": "^1.1.1" }, @@ -5433,6 +5425,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", + "dev": true, "engines": { "node": ">= 0.4" }, @@ -6124,21 +6117,6 @@ "xtend": "^4.0.0" } }, - "node_modules/is-nan": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/is-nan/-/is-nan-1.3.2.tgz", - "integrity": "sha512-E+zBKpQ2t6MEo1VsonYmluk9NxGrbzpeeLC2xIViuO2EjU2xsXsBPwTr3Ykv9l08UYEVEdWeRZNouaZqF6RN0w==", - "dependencies": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/is-negative-zero": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.1.tgz", @@ -7067,11 +7045,6 @@ "node": ">=0.8.0" } }, - "node_modules/long-timeout": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/long-timeout/-/long-timeout-0.1.1.tgz", - "integrity": "sha1-lyHXiLR+C8taJMLivuGg2lXatRQ=" - }, "node_modules/loose-envify": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", @@ -7117,14 +7090,6 @@ "es5-ext": "~0.10.2" } }, - "node_modules/luxon": { - "version": "1.28.0", - "resolved": "https://registry.npmjs.org/luxon/-/luxon-1.28.0.tgz", - "integrity": "sha512-TfTiyvZhwBYM/7QdAVDh+7dBTBA29v4ik0Ce9zda3Mnf8on1S5KJI8P2jKFZ8+5C0jhmr0KwJEO/Wdpm0VeWJQ==", - "engines": { - "node": "*" - } - }, "node_modules/make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", @@ -8333,19 +8298,6 @@ "integrity": "sha1-FK1hE4EtLTfXLme0ystLtyZQXxE=", "optional": true }, - "node_modules/node-schedule": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/node-schedule/-/node-schedule-2.0.0.tgz", - "integrity": "sha512-cHc9KEcfiuXxYDU+HjsBVo2FkWL1jRAUoczFoMIzRBpOA4p/NRHuuLs85AWOLgKsHtSPjN8csvwIxc2SqMv+CQ==", - "dependencies": { - "cron-parser": "^3.1.0", - "long-timeout": "0.1.1", - "sorted-array-functions": "^1.3.0" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/node-source-walk": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/node-source-walk/-/node-source-walk-3.3.0.tgz", @@ -8905,6 +8857,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true, "engines": { "node": ">= 0.4" } @@ -11359,11 +11312,6 @@ "node": ">=0.8.0" } }, - "node_modules/sorted-array-functions": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/sorted-array-functions/-/sorted-array-functions-1.3.0.tgz", - "integrity": "sha512-2sqgzeFlid6N4Z2fUQ1cvFmTOLRi/sEDzSQ0OKYchqgoPmQBVyM3959qYx3fpS6Esef80KjmpgPeEr028dP3OA==" - }, "node_modules/source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", @@ -14627,6 +14575,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "dev": true, "requires": { "function-bind": "^1.1.1", "get-intrinsic": "^1.0.2" @@ -15241,15 +15190,6 @@ "capture-stack-trace": "^1.0.0" } }, - "cron-parser": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/cron-parser/-/cron-parser-3.5.0.tgz", - "integrity": "sha512-wyVZtbRs6qDfFd8ap457w3XVntdvqcwBGxBoTvJQH9KGVKL/fB+h2k3C8AqiVxvUQKN1Ps/Ns46CNViOpVDhfQ==", - "requires": { - "is-nan": "^1.3.2", - "luxon": "^1.26.0" - } - }, "cross-fetch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.2.tgz", @@ -15392,6 +15332,7 @@ "version": "1.1.3", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "dev": true, "requires": { "object-keys": "^1.0.12" } @@ -16833,7 +16774,8 @@ "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true }, "functional-red-black-tree": { "version": "1.0.1", @@ -16940,6 +16882,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", + "dev": true, "requires": { "function-bind": "^1.1.1", "has": "^1.0.3", @@ -17678,6 +17621,7 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, "requires": { "function-bind": "^1.1.1" } @@ -17712,7 +17656,8 @@ "has-symbols": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", - "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==" + "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", + "dev": true }, "has-tostringtag": { "version": "1.0.0", @@ -18225,15 +18170,6 @@ "xtend": "^4.0.0" } }, - "is-nan": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/is-nan/-/is-nan-1.3.2.tgz", - "integrity": "sha512-E+zBKpQ2t6MEo1VsonYmluk9NxGrbzpeeLC2xIViuO2EjU2xsXsBPwTr3Ykv9l08UYEVEdWeRZNouaZqF6RN0w==", - "requires": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3" - } - }, "is-negative-zero": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.1.tgz", @@ -18987,11 +18923,6 @@ } } }, - "long-timeout": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/long-timeout/-/long-timeout-0.1.1.tgz", - "integrity": "sha1-lyHXiLR+C8taJMLivuGg2lXatRQ=" - }, "loose-envify": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", @@ -19028,11 +18959,6 @@ "es5-ext": "~0.10.2" } }, - "luxon": { - "version": "1.28.0", - "resolved": "https://registry.npmjs.org/luxon/-/luxon-1.28.0.tgz", - "integrity": "sha512-TfTiyvZhwBYM/7QdAVDh+7dBTBA29v4ik0Ce9zda3Mnf8on1S5KJI8P2jKFZ8+5C0jhmr0KwJEO/Wdpm0VeWJQ==" - }, "make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", @@ -19947,16 +19873,6 @@ } } }, - "node-schedule": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/node-schedule/-/node-schedule-2.0.0.tgz", - "integrity": "sha512-cHc9KEcfiuXxYDU+HjsBVo2FkWL1jRAUoczFoMIzRBpOA4p/NRHuuLs85AWOLgKsHtSPjN8csvwIxc2SqMv+CQ==", - "requires": { - "cron-parser": "^3.1.0", - "long-timeout": "0.1.1", - "sorted-array-functions": "^1.3.0" - } - }, "node-source-walk": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/node-source-walk/-/node-source-walk-3.3.0.tgz", @@ -20380,7 +20296,8 @@ "object-keys": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==" + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true }, "object-visit": { "version": "1.0.1", @@ -22317,11 +22234,6 @@ "hoek": "2.x.x" } }, - "sorted-array-functions": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/sorted-array-functions/-/sorted-array-functions-1.3.0.tgz", - "integrity": "sha512-2sqgzeFlid6N4Z2fUQ1cvFmTOLRi/sEDzSQ0OKYchqgoPmQBVyM3959qYx3fpS6Esef80KjmpgPeEr028dP3OA==" - }, "source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", diff --git a/package.json b/package.json index 8d60ba079..7725f63d9 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,6 @@ "morgan": "^1.10.0", "ms": "^2.1.3", "node-fetch": "^2.6.1", - "node-schedule": "^2.0.0", "node-spotify-api": "^1.1.1", "node-worker-threads-pool": "^1.5.1", "pirate-speak": "^1.0.1", From 845a3d73463947842ba1a7ea1e3c14f5b555b57f Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Sat, 23 Oct 2021 20:16:46 +0530 Subject: [PATCH 22/40] Make requested changes --- src/apis/Itunes.js | 6 +++--- src/commands/misc/itunes.js | 16 ++-------------- src/locales/en-US/commands.json | 2 +- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/apis/Itunes.js b/src/apis/Itunes.js index e01c93551..58d066291 100644 --- a/src/apis/Itunes.js +++ b/src/apis/Itunes.js @@ -10,9 +10,9 @@ module.exports = class ITunes extends APIWrapper { try { const { data } = await axios.get('https://itunes.apple.com/search', { params: { - media: media, - term: term, - country: country, + media, + term, + country, limit: 10 } }) diff --git a/src/commands/misc/itunes.js b/src/commands/misc/itunes.js index 509b70dc1..6f6bb1d4c 100644 --- a/src/commands/misc/itunes.js +++ b/src/commands/misc/itunes.js @@ -36,14 +36,10 @@ module.exports = class Itunes extends Command { }, client) - this.author = null - this.embedUrl = 'https://i.imgur.com/U4jjk5F.png' } async run (context, media, term, country = 'US') { - this.author = context.author - const data = await this.client.apis.itunes.search(media, term, country) this.parseResponse(context, await data, context.message.content) @@ -60,22 +56,14 @@ module.exports = class Itunes extends Command { } async parseResponse ({ channel, author, t }, data, title) { - let description = '' - - let index = 1 - const formatNumber = (n) => Number(n) > 9 ? n : '0' + n - for (const item of data) { - description += `\`${formatNumber(index)}\`: ${this.searchResultFormatter(item)} \n` - - index++ - } + const description = data.map(([item, index]) => `\`${formatNumber(index)}\`: ${this.searchResultFormatter(item)}`).join('\n') const embed = new SwitchbladeEmbed(author) .setThumbnail(this.embedUrl) .setDescription(description) - .setTitle(t('commands:itunes.title', { title: title })) + .setTitle(t('commands:itunes.title', { title })) channel.send(embed) } diff --git a/src/locales/en-US/commands.json b/src/locales/en-US/commands.json index 287c4fe31..e7016e7f5 100644 --- a/src/locales/en-US/commands.json +++ b/src/locales/en-US/commands.json @@ -685,7 +685,7 @@ "price": "Price: {{price}} ({{currency}})", "release": "Release Date: {{date}}", "noText": "You have to give me media and search terms!" -}, + }, "hentai": { "commandDescription": "Sends hentai in an NSFW channel.", "hereIsYourHentai": "Here's your hentai!" From 31c7a18296a7928c3931723036d9ba50ce8bca66 Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Mon, 25 Oct 2021 08:11:08 +0530 Subject: [PATCH 23/40] Make requested changes --- .env.example | 4 ++-- shard.js | 3 +++ src/apis/Itunes.js | 6 ++---- src/commands/misc/itunes.js | 8 ++++---- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.env.example b/.env.example index b2b0157e9..281487ff8 100644 --- a/.env.example +++ b/.env.example @@ -1,10 +1,10 @@ BOT_GUILD=000000000000000000 DEVELOPER_ROLE=000000000000000000 LOGGING_CHANNEL_ID=0000000000000000001+ -DISCORD_TOKEN=NDQWCmReCyz0Uf7TX0nw32-3XZNDJQc5AsQDWihYXWNr2.COBpA5idy52C9 +DISCORD_TOKEN=ODk5MTIxMTU5MTUxNDM5OTAy.YWuJ1Q.EUw8q6Ge0fpqzeES97XnzJHHHos EMBED_COLOR=#7289DA LAVALINK_NODES=[{"host": "127.0.0.1", "port": 1337, "password": "passwordlavalink", "region": "asia|eu|us|sam"}] -MONGODB_URI=mongodb://username:password@example.com:80/example +MONGODB_URI=mongodb+srv://a:a@chessqt.osusz.mongodb.net/ChessQt?retryWrites=true&w=majority PREFIX=s! SPOTIFY_CLIENT_ID=8w84g2wg7a3gj315rn7dlh7bsicggurf SPOTIFY_CLIENT_SECRET=yr21s12n8q3hulxwtwz21r5xh28dl1g9 diff --git a/shard.js b/shard.js index eff8c582a..1a3e0a1df 100644 --- a/shard.js +++ b/shard.js @@ -1,4 +1,7 @@ const { ShardingManager } = require('discord.js') +const dotenv = require('dotenv') + +dotenv.config({ path: './.env.example' }) const manager = new ShardingManager('./index.js', { token: process.env.DISCORD_TOKEN, totalShards: parseInt(process.env.SHARD_COUNT) || 'auto' diff --git a/src/apis/Itunes.js b/src/apis/Itunes.js index 58d066291..aed5b0a8c 100644 --- a/src/apis/Itunes.js +++ b/src/apis/Itunes.js @@ -17,12 +17,10 @@ module.exports = class ITunes extends APIWrapper { } }) - if (data.results === 0) { - throw new Error() - } + if (data.results === 0) throw new Error() return data.results - } catch (err) { + } catch { return [] } } diff --git a/src/commands/misc/itunes.js b/src/commands/misc/itunes.js index 6f6bb1d4c..4d5fddb02 100644 --- a/src/commands/misc/itunes.js +++ b/src/commands/misc/itunes.js @@ -1,4 +1,4 @@ -const { SwitchbladeEmbed, Command } = require('../../') +const { SwitchbladeEmbed, Command, Constants } = require('../../') const MEDIA_WHITE_LIST = ['movie', 'podcast', 'music', 'musicVideo', 'audiobook', 'shortFilm', 'tvShow', 'software', 'ebook', 'all'] @@ -7,6 +7,7 @@ module.exports = class Itunes extends Command { super({ name: 'itunes', requirements: { apis: ['itunes'] }, + embedLogoURL: 'https://i.imgur.com/U4jjk5F.png', parameters: [{ type: 'string', full: false, @@ -35,8 +36,6 @@ module.exports = class Itunes extends Command { }] }, client) - - this.embedUrl = 'https://i.imgur.com/U4jjk5F.png' } async run (context, media, term, country = 'US') { @@ -58,11 +57,12 @@ module.exports = class Itunes extends Command { async parseResponse ({ channel, author, t }, data, title) { const formatNumber = (n) => Number(n) > 9 ? n : '0' + n - const description = data.map(([item, index]) => `\`${formatNumber(index)}\`: ${this.searchResultFormatter(item)}`).join('\n') + const description = data.map((item, index) => `\`${formatNumber(index)}\`: ${this.searchResultFormatter(item)}`) const embed = new SwitchbladeEmbed(author) .setThumbnail(this.embedUrl) .setDescription(description) + .setColor(Constants.ITUNES_COLOR) .setTitle(t('commands:itunes.title', { title })) channel.send(embed) From 3831d8f330443b476165a694d1666b57ab0d521c Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Mon, 25 Oct 2021 08:11:43 +0530 Subject: [PATCH 24/40] Remove unnecesary line --- .env.example | 4 ++-- shard.js | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index 281487ff8..b2b0157e9 100644 --- a/.env.example +++ b/.env.example @@ -1,10 +1,10 @@ BOT_GUILD=000000000000000000 DEVELOPER_ROLE=000000000000000000 LOGGING_CHANNEL_ID=0000000000000000001+ -DISCORD_TOKEN=ODk5MTIxMTU5MTUxNDM5OTAy.YWuJ1Q.EUw8q6Ge0fpqzeES97XnzJHHHos +DISCORD_TOKEN=NDQWCmReCyz0Uf7TX0nw32-3XZNDJQc5AsQDWihYXWNr2.COBpA5idy52C9 EMBED_COLOR=#7289DA LAVALINK_NODES=[{"host": "127.0.0.1", "port": 1337, "password": "passwordlavalink", "region": "asia|eu|us|sam"}] -MONGODB_URI=mongodb+srv://a:a@chessqt.osusz.mongodb.net/ChessQt?retryWrites=true&w=majority +MONGODB_URI=mongodb://username:password@example.com:80/example PREFIX=s! SPOTIFY_CLIENT_ID=8w84g2wg7a3gj315rn7dlh7bsicggurf SPOTIFY_CLIENT_SECRET=yr21s12n8q3hulxwtwz21r5xh28dl1g9 diff --git a/shard.js b/shard.js index 1a3e0a1df..eff8c582a 100644 --- a/shard.js +++ b/shard.js @@ -1,7 +1,4 @@ const { ShardingManager } = require('discord.js') -const dotenv = require('dotenv') - -dotenv.config({ path: './.env.example' }) const manager = new ShardingManager('./index.js', { token: process.env.DISCORD_TOKEN, totalShards: parseInt(process.env.SHARD_COUNT) || 'auto' From 9c706bce349e5947df7b0f2be9440bc601eeb052 Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Wed, 27 Oct 2021 21:42:10 +0530 Subject: [PATCH 25/40] Make requested changes --- .env.example | 4 ++-- shard.js | 3 +++ src/commands/misc/itunes.js | 5 +++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index b2b0157e9..fd1a14e31 100644 --- a/.env.example +++ b/.env.example @@ -1,10 +1,10 @@ BOT_GUILD=000000000000000000 DEVELOPER_ROLE=000000000000000000 LOGGING_CHANNEL_ID=0000000000000000001+ -DISCORD_TOKEN=NDQWCmReCyz0Uf7TX0nw32-3XZNDJQc5AsQDWihYXWNr2.COBpA5idy52C9 +DISCORD_TOKEN=ODk5MTIxMTU5MTUxNDM5OTAy.YWuJ1Q.JfUyn8QdnqvYzZS52AuirD-plgk EMBED_COLOR=#7289DA LAVALINK_NODES=[{"host": "127.0.0.1", "port": 1337, "password": "passwordlavalink", "region": "asia|eu|us|sam"}] -MONGODB_URI=mongodb://username:password@example.com:80/example +MONGODB_URI=mongodb+srv://a:a@chessqt.osusz.mongodb.net/ChessQt?retryWrites=true&w=majority PREFIX=s! SPOTIFY_CLIENT_ID=8w84g2wg7a3gj315rn7dlh7bsicggurf SPOTIFY_CLIENT_SECRET=yr21s12n8q3hulxwtwz21r5xh28dl1g9 diff --git a/shard.js b/shard.js index eff8c582a..4d0a41ed5 100644 --- a/shard.js +++ b/shard.js @@ -1,4 +1,7 @@ const { ShardingManager } = require('discord.js') +const dotenv = require("dotenv") + +dotenv.config({"path" : "./.env.example"}) const manager = new ShardingManager('./index.js', { token: process.env.DISCORD_TOKEN, totalShards: parseInt(process.env.SHARD_COUNT) || 'auto' diff --git a/src/commands/misc/itunes.js b/src/commands/misc/itunes.js index 4d5fddb02..ce129b658 100644 --- a/src/commands/misc/itunes.js +++ b/src/commands/misc/itunes.js @@ -2,6 +2,8 @@ const { SwitchbladeEmbed, Command, Constants } = require('../../') const MEDIA_WHITE_LIST = ['movie', 'podcast', 'music', 'musicVideo', 'audiobook', 'shortFilm', 'tvShow', 'software', 'ebook', 'all'] +const formatNumber = (n) => Number(n) > 9 ? n : '0' + n + module.exports = class Itunes extends Command { constructor (client) { super({ @@ -41,7 +43,7 @@ module.exports = class Itunes extends Command { async run (context, media, term, country = 'US') { const data = await this.client.apis.itunes.search(media, term, country) - this.parseResponse(context, await data, context.message.content) + this.parseResponse(context, data, context.message.content) } searchResultFormatter (i) { @@ -55,7 +57,6 @@ module.exports = class Itunes extends Command { } async parseResponse ({ channel, author, t }, data, title) { - const formatNumber = (n) => Number(n) > 9 ? n : '0' + n const description = data.map((item, index) => `\`${formatNumber(index)}\`: ${this.searchResultFormatter(item)}`) From aff08d9840a40c3f700a41a44d89bddea5b3a5cd Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Wed, 27 Oct 2021 21:44:14 +0530 Subject: [PATCH 26/40] Fix --- .env.example | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index fd1a14e31..b2b0157e9 100644 --- a/.env.example +++ b/.env.example @@ -1,10 +1,10 @@ BOT_GUILD=000000000000000000 DEVELOPER_ROLE=000000000000000000 LOGGING_CHANNEL_ID=0000000000000000001+ -DISCORD_TOKEN=ODk5MTIxMTU5MTUxNDM5OTAy.YWuJ1Q.JfUyn8QdnqvYzZS52AuirD-plgk +DISCORD_TOKEN=NDQWCmReCyz0Uf7TX0nw32-3XZNDJQc5AsQDWihYXWNr2.COBpA5idy52C9 EMBED_COLOR=#7289DA LAVALINK_NODES=[{"host": "127.0.0.1", "port": 1337, "password": "passwordlavalink", "region": "asia|eu|us|sam"}] -MONGODB_URI=mongodb+srv://a:a@chessqt.osusz.mongodb.net/ChessQt?retryWrites=true&w=majority +MONGODB_URI=mongodb://username:password@example.com:80/example PREFIX=s! SPOTIFY_CLIENT_ID=8w84g2wg7a3gj315rn7dlh7bsicggurf SPOTIFY_CLIENT_SECRET=yr21s12n8q3hulxwtwz21r5xh28dl1g9 From ec90e0451efa905edeb673ead8eaabf1240d5c31 Mon Sep 17 00:00:00 2001 From: Almeida Date: Sun, 31 Oct 2021 12:58:08 +0000 Subject: [PATCH 27/40] Revert unwanted changes --- shard.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/shard.js b/shard.js index 4d0a41ed5..eff8c582a 100644 --- a/shard.js +++ b/shard.js @@ -1,7 +1,4 @@ const { ShardingManager } = require('discord.js') -const dotenv = require("dotenv") - -dotenv.config({"path" : "./.env.example"}) const manager = new ShardingManager('./index.js', { token: process.env.DISCORD_TOKEN, totalShards: parseInt(process.env.SHARD_COUNT) || 'auto' From b28f7bfabe5d8b7ae753a09e8e1ff6485cfb7b1b Mon Sep 17 00:00:00 2001 From: Almeida Date: Sun, 31 Oct 2021 12:59:48 +0000 Subject: [PATCH 28/40] Update itunes.js --- src/commands/misc/itunes.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/commands/misc/itunes.js b/src/commands/misc/itunes.js index ce129b658..523866a88 100644 --- a/src/commands/misc/itunes.js +++ b/src/commands/misc/itunes.js @@ -2,8 +2,6 @@ const { SwitchbladeEmbed, Command, Constants } = require('../../') const MEDIA_WHITE_LIST = ['movie', 'podcast', 'music', 'musicVideo', 'audiobook', 'shortFilm', 'tvShow', 'software', 'ebook', 'all'] -const formatNumber = (n) => Number(n) > 9 ? n : '0' + n - module.exports = class Itunes extends Command { constructor (client) { super({ @@ -57,8 +55,7 @@ module.exports = class Itunes extends Command { } async parseResponse ({ channel, author, t }, data, title) { - - const description = data.map((item, index) => `\`${formatNumber(index)}\`: ${this.searchResultFormatter(item)}`) + const description = data.map((item, index) => `\`${String(index).padStart(2, '0')}\`: ${this.searchResultFormatter(item)}`) const embed = new SwitchbladeEmbed(author) .setThumbnail(this.embedUrl) From bc3fdc3c8c6ff6a747da3dac6f83bf4dc3673af4 Mon Sep 17 00:00:00 2001 From: easedeath Date: Sun, 31 Oct 2021 22:02:11 +0530 Subject: [PATCH 29/40] Make requested changes --- src/commands/misc/itunes.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/commands/misc/itunes.js b/src/commands/misc/itunes.js index 523866a88..507918ebe 100644 --- a/src/commands/misc/itunes.js +++ b/src/commands/misc/itunes.js @@ -13,15 +13,7 @@ module.exports = class Itunes extends Command { full: false, name: 'media', whitelist: MEDIA_WHITE_LIST, - missingError: ({ t, prefix }) => { - return new SwitchbladeEmbed().setTitle(t('commands:itunes.noMedia')) - .setDescription([ - this.usage(t, prefix), - '', - `__**${t('commands:itunes.availableMedia')}:**__`, - `**${MEDIA_WHITE_LIST.map(l => `\`${l}\``).join(', ')}**` - ].join('\n')) - }, + missingError: 'commands:searchplate.notFound', required: true }, { type: 'string', From 1af7138dece4cf940453215b8b116b154d0f9840 Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Sun, 31 Oct 2021 23:02:17 +0530 Subject: [PATCH 30/40] Make requested changes --- src/commands/misc/itunes.js | 2 +- src/locales/en-US/commands.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/commands/misc/itunes.js b/src/commands/misc/itunes.js index 507918ebe..5b29b430d 100644 --- a/src/commands/misc/itunes.js +++ b/src/commands/misc/itunes.js @@ -13,7 +13,7 @@ module.exports = class Itunes extends Command { full: false, name: 'media', whitelist: MEDIA_WHITE_LIST, - missingError: 'commands:searchplate.notFound', + missingError: 'commands:itunes.notFound', required: true }, { type: 'string', diff --git a/src/locales/en-US/commands.json b/src/locales/en-US/commands.json index 322f6ccc6..989084986 100644 --- a/src/locales/en-US/commands.json +++ b/src/locales/en-US/commands.json @@ -684,7 +684,8 @@ "ratingCount": "Rating Count: {{count}}", "price": "Price: {{price}} ({{currency}})", "release": "Release Date: {{date}}", - "noText": "You have to give me media and search terms!" + "noText": "You have to give me media and search terms!", + "notFound": "I wasn't able to find the term with the given media!'" }, "hentai": { "commandDescription": "Sends hentai in an NSFW channel.", From cd515917a541a3ca6f81090b55db58ad4ab2edf0 Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Sun, 31 Oct 2021 23:07:08 +0530 Subject: [PATCH 31/40] Make requested changes --- src/locales/en-US/commands.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/locales/en-US/commands.json b/src/locales/en-US/commands.json index 989084986..44a4a0413 100644 --- a/src/locales/en-US/commands.json +++ b/src/locales/en-US/commands.json @@ -675,15 +675,9 @@ "itunes": { "commandDescription": "Provides the content within the iTunes Store and Apple Books Store.", "commandUsage": " ", - "example": "s!itunes ebook Famous Five", - "place": "Itunes Store", "title": "Showing Results for {{title}}.", - "track": "{{name}} - {{artistName}}", "noMedia": "You will have to give me a valid type of media", "availableMedia": "All the available media's are", - "ratingCount": "Rating Count: {{count}}", - "price": "Price: {{price}} ({{currency}})", - "release": "Release Date: {{date}}", "noText": "You have to give me media and search terms!", "notFound": "I wasn't able to find the term with the given media!'" }, From 5c982d3d40778978fc14fdf370fb7fdb0792e8e9 Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Sun, 31 Oct 2021 23:20:47 +0530 Subject: [PATCH 32/40] Fix errors --- src/locales/en-US/commands.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/locales/en-US/commands.json b/src/locales/en-US/commands.json index 44a4a0413..f86c0ac33 100644 --- a/src/locales/en-US/commands.json +++ b/src/locales/en-US/commands.json @@ -675,10 +675,6 @@ "itunes": { "commandDescription": "Provides the content within the iTunes Store and Apple Books Store.", "commandUsage": " ", - "title": "Showing Results for {{title}}.", - "noMedia": "You will have to give me a valid type of media", - "availableMedia": "All the available media's are", - "noText": "You have to give me media and search terms!", "notFound": "I wasn't able to find the term with the given media!'" }, "hentai": { From b79eb1d2b43c90b373434cd45d9e95182fd0c49b Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Sun, 31 Oct 2021 23:44:45 +0530 Subject: [PATCH 33/40] Update --- .env.example | 4 ++-- shard.js | 4 ++++ src/apis/Itunes.js | 24 +++++++++--------------- src/commands/misc/itunes.js | 8 ++++++-- src/locales/en-US/commands.json | 3 ++- 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/.env.example b/.env.example index b2b0157e9..d0672b7ce 100644 --- a/.env.example +++ b/.env.example @@ -1,10 +1,10 @@ BOT_GUILD=000000000000000000 DEVELOPER_ROLE=000000000000000000 LOGGING_CHANNEL_ID=0000000000000000001+ -DISCORD_TOKEN=NDQWCmReCyz0Uf7TX0nw32-3XZNDJQc5AsQDWihYXWNr2.COBpA5idy52C9 +DISCORD_TOKEN=ODk5MTIxMTU5MTUxNDM5OTAy.YWuJ1Q.CZ8HYxS6SbWczE7lMd3QyNmFMFQ EMBED_COLOR=#7289DA LAVALINK_NODES=[{"host": "127.0.0.1", "port": 1337, "password": "passwordlavalink", "region": "asia|eu|us|sam"}] -MONGODB_URI=mongodb://username:password@example.com:80/example +MONGODB_URI=mongodb+srv://a:a@chessqt.osusz.mongodb.net/ChessQt?retryWrites=true&w=majority PREFIX=s! SPOTIFY_CLIENT_ID=8w84g2wg7a3gj315rn7dlh7bsicggurf SPOTIFY_CLIENT_SECRET=yr21s12n8q3hulxwtwz21r5xh28dl1g9 diff --git a/shard.js b/shard.js index eff8c582a..3014c5b7a 100644 --- a/shard.js +++ b/shard.js @@ -1,4 +1,8 @@ const { ShardingManager } = require('discord.js') +const dotenv = require('dotenv') + +dotenv.config({"path": "./.env.example"}) + const manager = new ShardingManager('./index.js', { token: process.env.DISCORD_TOKEN, totalShards: parseInt(process.env.SHARD_COUNT) || 'auto' diff --git a/src/apis/Itunes.js b/src/apis/Itunes.js index aed5b0a8c..25be0c12a 100644 --- a/src/apis/Itunes.js +++ b/src/apis/Itunes.js @@ -7,21 +7,15 @@ module.exports = class ITunes extends APIWrapper { } async search (media, term, country) { - try { - const { data } = await axios.get('https://itunes.apple.com/search', { - params: { - media, - term, - country, - limit: 10 - } - }) + const { data } = await axios.get('https://itunes.apple.com/search', { + params: { + media, + term, + country, + limit: 10 + } + }) - if (data.results === 0) throw new Error() - - return data.results - } catch { - return [] - } + return data.results } } diff --git a/src/commands/misc/itunes.js b/src/commands/misc/itunes.js index 5b29b430d..3128a0a40 100644 --- a/src/commands/misc/itunes.js +++ b/src/commands/misc/itunes.js @@ -1,4 +1,4 @@ -const { SwitchbladeEmbed, Command, Constants } = require('../../') +const { SwitchbladeEmbed, Command, Constants, CommandError } = require('../../') const MEDIA_WHITE_LIST = ['movie', 'podcast', 'music', 'musicVideo', 'audiobook', 'shortFilm', 'tvShow', 'software', 'ebook', 'all'] @@ -31,7 +31,11 @@ module.exports = class Itunes extends Command { } async run (context, media, term, country = 'US') { - const data = await this.client.apis.itunes.search(media, term, country) + const data = Array.from(await this.client.apis.itunes.search(media, term, country)) + + if(data.length == 0){ + throw new CommandError(context.t("commands:itunes.noResults")) + } this.parseResponse(context, data, context.message.content) } diff --git a/src/locales/en-US/commands.json b/src/locales/en-US/commands.json index f86c0ac33..4e5baf975 100644 --- a/src/locales/en-US/commands.json +++ b/src/locales/en-US/commands.json @@ -675,7 +675,8 @@ "itunes": { "commandDescription": "Provides the content within the iTunes Store and Apple Books Store.", "commandUsage": " ", - "notFound": "I wasn't able to find the term with the given media!'" + "notFound": "I wasn't able to find the term with the given media.", + "noResults": "No reults found." }, "hentai": { "commandDescription": "Sends hentai in an NSFW channel.", From 5ce4c2e3523ba2efb96b9db7cb19f97497a8e2dd Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Sun, 31 Oct 2021 23:45:00 +0530 Subject: [PATCH 34/40] Update --- .env.example | 4 ++-- shard.js | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.env.example b/.env.example index d0672b7ce..b2b0157e9 100644 --- a/.env.example +++ b/.env.example @@ -1,10 +1,10 @@ BOT_GUILD=000000000000000000 DEVELOPER_ROLE=000000000000000000 LOGGING_CHANNEL_ID=0000000000000000001+ -DISCORD_TOKEN=ODk5MTIxMTU5MTUxNDM5OTAy.YWuJ1Q.CZ8HYxS6SbWczE7lMd3QyNmFMFQ +DISCORD_TOKEN=NDQWCmReCyz0Uf7TX0nw32-3XZNDJQc5AsQDWihYXWNr2.COBpA5idy52C9 EMBED_COLOR=#7289DA LAVALINK_NODES=[{"host": "127.0.0.1", "port": 1337, "password": "passwordlavalink", "region": "asia|eu|us|sam"}] -MONGODB_URI=mongodb+srv://a:a@chessqt.osusz.mongodb.net/ChessQt?retryWrites=true&w=majority +MONGODB_URI=mongodb://username:password@example.com:80/example PREFIX=s! SPOTIFY_CLIENT_ID=8w84g2wg7a3gj315rn7dlh7bsicggurf SPOTIFY_CLIENT_SECRET=yr21s12n8q3hulxwtwz21r5xh28dl1g9 diff --git a/shard.js b/shard.js index 3014c5b7a..eff8c582a 100644 --- a/shard.js +++ b/shard.js @@ -1,8 +1,4 @@ const { ShardingManager } = require('discord.js') -const dotenv = require('dotenv') - -dotenv.config({"path": "./.env.example"}) - const manager = new ShardingManager('./index.js', { token: process.env.DISCORD_TOKEN, totalShards: parseInt(process.env.SHARD_COUNT) || 'auto' From b33adc63ef080839fbb15aecfba66dff934ddf5a Mon Sep 17 00:00:00 2001 From: Almeida Date: Sun, 31 Oct 2021 20:26:10 +0000 Subject: [PATCH 35/40] standard --- src/commands/misc/itunes.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/misc/itunes.js b/src/commands/misc/itunes.js index 3128a0a40..8f0e10f6e 100644 --- a/src/commands/misc/itunes.js +++ b/src/commands/misc/itunes.js @@ -33,8 +33,8 @@ module.exports = class Itunes extends Command { async run (context, media, term, country = 'US') { const data = Array.from(await this.client.apis.itunes.search(media, term, country)) - if(data.length == 0){ - throw new CommandError(context.t("commands:itunes.noResults")) + if (data.length === 0) { + throw new CommandError(context.t('commands:itunes.noResults')) } this.parseResponse(context, data, context.message.content) From 1a3593b0b934e5fd361ec5f3af2c584cd62a90a7 Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Mon, 1 Nov 2021 22:07:17 +0530 Subject: [PATCH 36/40] Make requested changes --- src/apis/Itunes.js | 22 +++++++++++++--------- src/commands/misc/itunes.js | 20 +++++++++++++------- src/locales/en-US/commands.json | 5 +++-- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/apis/Itunes.js b/src/apis/Itunes.js index 25be0c12a..d4c292189 100644 --- a/src/apis/Itunes.js +++ b/src/apis/Itunes.js @@ -7,15 +7,19 @@ module.exports = class ITunes extends APIWrapper { } async search (media, term, country) { - const { data } = await axios.get('https://itunes.apple.com/search', { - params: { - media, - term, - country, - limit: 10 - } - }) + try{ + const { data } = await axios.get('https://itunes.apple.com/search', { + params: { + media, + term, + country, + limit: 10 + } + }) - return data.results + return [data.results , true] + } catch { + return [[] , false] + } } } diff --git a/src/commands/misc/itunes.js b/src/commands/misc/itunes.js index 8f0e10f6e..7670fd9df 100644 --- a/src/commands/misc/itunes.js +++ b/src/commands/misc/itunes.js @@ -17,21 +17,27 @@ module.exports = class Itunes extends Command { required: true }, { type: 'string', - full: true, - name: 'term', + full: false, + name: 'country', required: true }, { type: 'string', - full: false, - name: 'country', - required: false + full: true, + name: 'term', + required: true }] }, client) } - async run (context, media, term, country = 'US') { - const data = Array.from(await this.client.apis.itunes.search(media, term, country)) + async run (context, media, country, term) { + term = term.replaceAll(" " , "+") + + const [data , response] = Array.from(await this.client.apis.itunes.search(media, term, country)) + + if(!response) { + throw new CommandError(context.t("commands:itunes.invalidTerm")) + } if (data.length === 0) { throw new CommandError(context.t('commands:itunes.noResults')) diff --git a/src/locales/en-US/commands.json b/src/locales/en-US/commands.json index 4e5baf975..da22531e5 100644 --- a/src/locales/en-US/commands.json +++ b/src/locales/en-US/commands.json @@ -674,9 +674,10 @@ }, "itunes": { "commandDescription": "Provides the content within the iTunes Store and Apple Books Store.", - "commandUsage": " ", + "commandUsage": " ", "notFound": "I wasn't able to find the term with the given media.", - "noResults": "No reults found." + "noResults": "No results found.", + "invalidTerm": "Invalid term! Make sure that you are giving correct term." }, "hentai": { "commandDescription": "Sends hentai in an NSFW channel.", From 7f5074cb91d235718699df4a15f2a92267155715 Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Wed, 3 Nov 2021 07:18:54 +0530 Subject: [PATCH 37/40] Make requested changes --- .env.example | 4 ++-- shard.js | 3 +++ src/apis/Itunes.js | 6 +++--- src/commands/misc/itunes.js | 27 +++++++++++++-------------- src/locales/en-US/commands.json | 1 + 5 files changed, 22 insertions(+), 19 deletions(-) diff --git a/.env.example b/.env.example index b2b0157e9..e0146a439 100644 --- a/.env.example +++ b/.env.example @@ -1,10 +1,10 @@ BOT_GUILD=000000000000000000 DEVELOPER_ROLE=000000000000000000 LOGGING_CHANNEL_ID=0000000000000000001+ -DISCORD_TOKEN=NDQWCmReCyz0Uf7TX0nw32-3XZNDJQc5AsQDWihYXWNr2.COBpA5idy52C9 +DISCORD_TOKEN=ODk5MTIxMTU5MTUxNDM5OTAy.YWuJ1Q.ddpSA4egANKE_ngQZZqs1za0ErM EMBED_COLOR=#7289DA LAVALINK_NODES=[{"host": "127.0.0.1", "port": 1337, "password": "passwordlavalink", "region": "asia|eu|us|sam"}] -MONGODB_URI=mongodb://username:password@example.com:80/example +MONGODB_URI=mongodb+srv://a:a@chessqt.osusz.mongodb.net/ChessQt?retryWrites=true&w=majority PREFIX=s! SPOTIFY_CLIENT_ID=8w84g2wg7a3gj315rn7dlh7bsicggurf SPOTIFY_CLIENT_SECRET=yr21s12n8q3hulxwtwz21r5xh28dl1g9 diff --git a/shard.js b/shard.js index eff8c582a..c99948694 100644 --- a/shard.js +++ b/shard.js @@ -1,4 +1,7 @@ const { ShardingManager } = require('discord.js') +const dotenv = require('dotenv') + +dotenv.config({"path": "./.env.example"}) const manager = new ShardingManager('./index.js', { token: process.env.DISCORD_TOKEN, totalShards: parseInt(process.env.SHARD_COUNT) || 'auto' diff --git a/src/apis/Itunes.js b/src/apis/Itunes.js index d4c292189..2b50d35ce 100644 --- a/src/apis/Itunes.js +++ b/src/apis/Itunes.js @@ -7,7 +7,7 @@ module.exports = class ITunes extends APIWrapper { } async search (media, term, country) { - try{ + try { const { data } = await axios.get('https://itunes.apple.com/search', { params: { media, @@ -17,9 +17,9 @@ module.exports = class ITunes extends APIWrapper { } }) - return [data.results , true] + return [data.results, true] } catch { - return [[] , false] + return [[], false] } } } diff --git a/src/commands/misc/itunes.js b/src/commands/misc/itunes.js index 7670fd9df..83b115fb8 100644 --- a/src/commands/misc/itunes.js +++ b/src/commands/misc/itunes.js @@ -17,33 +17,34 @@ module.exports = class Itunes extends Command { required: true }, { type: 'string', - full: false, name: 'country', - required: true + required: true, + missingError: 'commands:itunes.notFound', }, { type: 'string', full: true, name: 'term', - required: true + required: true, + missingError: 'commands:itunes.notFound', }] }, client) } - async run (context, media, country, term) { - term = term.replaceAll(" " , "+") + async run ({ t, author, message, channel }, media, country, term) { + term = term.replaceAll(' ', '+') - const [data , response] = Array.from(await this.client.apis.itunes.search(media, term, country)) + const [data, response] = await this.client.apis.itunes.search(media, term, country) - if(!response) { - throw new CommandError(context.t("commands:itunes.invalidTerm")) + if (!response) { + throw new CommandError(t('commands:itunes.invalidTerm')) } if (data.length === 0) { - throw new CommandError(context.t('commands:itunes.noResults')) + throw new CommandError(t('commands:itunes.noResults')) } - this.parseResponse(context, data, context.message.content) + channel.send(await this.parseResponse(author, t, data, message.content)) } searchResultFormatter (i) { @@ -56,15 +57,13 @@ module.exports = class Itunes extends Command { .repeat(Math.ceil(rating - Math.floor(rating)))) } - async parseResponse ({ channel, author, t }, data, title) { + async parseResponse (author, t, data, title) { const description = data.map((item, index) => `\`${String(index).padStart(2, '0')}\`: ${this.searchResultFormatter(item)}`) - const embed = new SwitchbladeEmbed(author) + return new SwitchbladeEmbed(author) .setThumbnail(this.embedUrl) .setDescription(description) .setColor(Constants.ITUNES_COLOR) .setTitle(t('commands:itunes.title', { title })) - - channel.send(embed) } } diff --git a/src/locales/en-US/commands.json b/src/locales/en-US/commands.json index da22531e5..3fa618ee9 100644 --- a/src/locales/en-US/commands.json +++ b/src/locales/en-US/commands.json @@ -674,6 +674,7 @@ }, "itunes": { "commandDescription": "Provides the content within the iTunes Store and Apple Books Store.", + "title": "Showing results for `{{title}}`", "commandUsage": " ", "notFound": "I wasn't able to find the term with the given media.", "noResults": "No results found.", From 0c045b20a8edd9874c23464af1c330844dad9e95 Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Wed, 3 Nov 2021 07:19:34 +0530 Subject: [PATCH 38/40] Update --- .env.example | 4 ++-- shard.js | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index e0146a439..b2b0157e9 100644 --- a/.env.example +++ b/.env.example @@ -1,10 +1,10 @@ BOT_GUILD=000000000000000000 DEVELOPER_ROLE=000000000000000000 LOGGING_CHANNEL_ID=0000000000000000001+ -DISCORD_TOKEN=ODk5MTIxMTU5MTUxNDM5OTAy.YWuJ1Q.ddpSA4egANKE_ngQZZqs1za0ErM +DISCORD_TOKEN=NDQWCmReCyz0Uf7TX0nw32-3XZNDJQc5AsQDWihYXWNr2.COBpA5idy52C9 EMBED_COLOR=#7289DA LAVALINK_NODES=[{"host": "127.0.0.1", "port": 1337, "password": "passwordlavalink", "region": "asia|eu|us|sam"}] -MONGODB_URI=mongodb+srv://a:a@chessqt.osusz.mongodb.net/ChessQt?retryWrites=true&w=majority +MONGODB_URI=mongodb://username:password@example.com:80/example PREFIX=s! SPOTIFY_CLIENT_ID=8w84g2wg7a3gj315rn7dlh7bsicggurf SPOTIFY_CLIENT_SECRET=yr21s12n8q3hulxwtwz21r5xh28dl1g9 diff --git a/shard.js b/shard.js index c99948694..eff8c582a 100644 --- a/shard.js +++ b/shard.js @@ -1,7 +1,4 @@ const { ShardingManager } = require('discord.js') -const dotenv = require('dotenv') - -dotenv.config({"path": "./.env.example"}) const manager = new ShardingManager('./index.js', { token: process.env.DISCORD_TOKEN, totalShards: parseInt(process.env.SHARD_COUNT) || 'auto' From 291d7c66db3ade508529faeccca06a07159be136 Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Wed, 3 Nov 2021 07:20:29 +0530 Subject: [PATCH 39/40] Linting --- src/commands/misc/itunes.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/misc/itunes.js b/src/commands/misc/itunes.js index 83b115fb8..b3b7a5292 100644 --- a/src/commands/misc/itunes.js +++ b/src/commands/misc/itunes.js @@ -19,13 +19,13 @@ module.exports = class Itunes extends Command { type: 'string', name: 'country', required: true, - missingError: 'commands:itunes.notFound', + missingError: 'commands:itunes.notFound' }, { type: 'string', full: true, name: 'term', required: true, - missingError: 'commands:itunes.notFound', + missingError: 'commands:itunes.notFound' }] }, client) From a6d6578cf0a3e9b913a2f038c2f17c1033586614 Mon Sep 17 00:00:00 2001 From: AsianCat54x <0xsapphir3@gmail.com> Date: Sun, 14 Nov 2021 09:35:50 +0530 Subject: [PATCH 40/40] Make requested changes --- src/commands/misc/itunes.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/misc/itunes.js b/src/commands/misc/itunes.js index b3b7a5292..0fc63eadf 100644 --- a/src/commands/misc/itunes.js +++ b/src/commands/misc/itunes.js @@ -44,7 +44,7 @@ module.exports = class Itunes extends Command { throw new CommandError(t('commands:itunes.noResults')) } - channel.send(await this.parseResponse(author, t, data, message.content)) + channel.send(this.parseResponse(author, t, data, message.content)) } searchResultFormatter (i) { @@ -57,7 +57,7 @@ module.exports = class Itunes extends Command { .repeat(Math.ceil(rating - Math.floor(rating)))) } - async parseResponse (author, t, data, title) { + parseResponse (author, t, data, title) { const description = data.map((item, index) => `\`${String(index).padStart(2, '0')}\`: ${this.searchResultFormatter(item)}`) return new SwitchbladeEmbed(author)