aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.vscode/launch.json17
-rw-r--r--package-lock.json19
-rw-r--r--package.json3
-rw-r--r--src/commands/gt.js28
-rw-r--r--src/commands/vaccine.js41
-rw-r--r--src/configs/commands.config.json10
6 files changed, 114 insertions, 4 deletions
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..77165f9
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,17 @@
+{
+ // Use IntelliSense to learn about possible attributes.
+ // Hover to view descriptions of existing attributes.
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "type": "pwa-node",
+ "request": "launch",
+ "name": "Launch Program",
+ "skipFiles": [
+ "<node_internals>/**"
+ ],
+ "program": "${workspaceFolder}\\src\\main.js"
+ }
+ ]
+} \ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 79185b4..06bb9fc 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -214,6 +214,14 @@
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
},
+ "axios": {
+ "version": "0.21.1",
+ "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz",
+ "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==",
+ "requires": {
+ "follow-redirects": "^1.10.0"
+ }
+ },
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
@@ -527,6 +535,11 @@
"progress": "^2.0.3"
}
},
+ "follow-redirects": {
+ "version": "1.14.1",
+ "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.1.tgz",
+ "integrity": "sha512-HWqDgT7ZEkqRzBvc2s64vSZ/hfOceEol3ac/7tKwzuvEyWx3/4UegXh5oBOIotkGsObyk3xznnSRVADBgWSQVg=="
+ },
"fs-minipass": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz",
@@ -1203,9 +1216,9 @@
}
},
"ytdl-core": {
- "version": "4.5.0",
- "resolved": "https://registry.npmjs.org/ytdl-core/-/ytdl-core-4.5.0.tgz",
- "integrity": "sha512-e8r6skrakWNixsVlNPBMoRM1HrdW1swE97If9nenDUjF65uogYk4DvxIuqlmqRfBWKe+6aIZwqedNxUU9XLYJA==",
+ "version": "4.8.0",
+ "resolved": "https://registry.npmjs.org/ytdl-core/-/ytdl-core-4.8.0.tgz",
+ "integrity": "sha512-LFhhwqFojReoaME17VpsFeiamygM0W/YNG8O02mrmS2O6Em5LjCPiJYdq7Af3CmJtBEOCdptSZ3Ql+3LGWDGvg==",
"requires": {
"m3u8stream": "^0.8.3",
"miniget": "^4.0.0",
diff --git a/package.json b/package.json
index 923ed0b..d1c0743 100644
--- a/package.json
+++ b/package.json
@@ -13,12 +13,13 @@
"dependencies": {
"@discordjs/opus": "^0.4.0",
"airtable": "^0.10.1",
+ "axios": "^0.21.1",
"discord.js": "^12.5.1",
"dotenv": "^8.2.0",
"ffmpeg-static": "^4.2.7",
"node-fetch": "^2.6.1",
"yt-search": "^2.7.3",
- "ytdl-core": "^4.5.0"
+ "ytdl-core": "^4.8.0"
},
"engines": {
"node": "12.16.3"
diff --git a/src/commands/gt.js b/src/commands/gt.js
new file mode 100644
index 0000000..512e76b
--- /dev/null
+++ b/src/commands/gt.js
@@ -0,0 +1,28 @@
+const axios = require('axios').default;
+const {MessageEmbed} = require('discord.js');
+const instance = axios.create({
+ baseURL: 'https://game-of-thrones-quotes.herokuapp.com/v1'
+ });
+
+async function getRandomQuotes(message, args) {
+ const randomQuotesUrl = "/random";
+ try {
+ const result = await instance.get(randomQuotesUrl);
+ const {sentence, character: {name, house: {name:houseName}}} = result.data;
+ const randomQuoteMessage = new MessageEmbed()
+ .setDescription(sentence)
+ .setFooter(`${name}, ${houseName}`);
+ message.channel.send(randomQuoteMessage);
+ } catch(error) {
+ const errorMessage = new MessageEmbed()
+ .setTitle("Something went wrong: Error getting quotes from Arya Stark")
+ .setColor("RED");
+ message.channel.send(errorMessage);
+ }
+}
+
+module.exports = {
+ execute(client, message, args) {
+ getRandomQuotes(message, args);
+ }
+} \ No newline at end of file
diff --git a/src/commands/vaccine.js b/src/commands/vaccine.js
new file mode 100644
index 0000000..e1219f2
--- /dev/null
+++ b/src/commands/vaccine.js
@@ -0,0 +1,41 @@
+const axios = require('axios').default;
+const {MessageEmbed} = require('discord.js');
+const instance = axios.create({
+ baseURL: 'https://cdn-api.co-vin.in/api/v2',
+ headers: {
+ 'accept': '*/*',
+ 'accept-language': 'en-US',
+ 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36'
+ }
+ });
+async function getVaccineAvailablity(message, args) {
+ const [pincode, date] = args;
+ const url = `/appointment/sessions/public/findByPin?${new URLSearchParams({ pincode, date })}`;
+ instance.get(url).then(res => {
+ if (res.data && res.data.sessions) {
+ const {sessions} = res.data;
+ if (sessions && sessions.length > 0 ){
+ sessions.forEach(async (session) => {
+ const vaccineMessage = new MessageEmbed()
+ .setTitle(`${session.name} : ${session.address}`)
+ .addField('State', session.state_name, true)
+ .addField('District', session.district_name, true)
+ .addField('Vaccine', session.vaccine, true)
+ .addField('Available Capacity', session.available_capacity, true)
+ .addField('Available SLots', session.slots.join("/"), true)
+ .setColor("RANDOM");
+ message.channel.send(vaccineMessage);
+ })
+
+ }else {
+ message.channel.send(`No Vaccine Available at place with pincode => ${pincode} on ${date}`)
+ }
+ }
+ }).catch(error => message.channel.send(`Error Fetching Data from Cowin`));
+}
+
+module.exports = {
+ execute(client, message, args) {
+ getVaccineAvailablity(message, args);
+ }
+} \ No newline at end of file
diff --git a/src/configs/commands.config.json b/src/configs/commands.config.json
index 1865374..268d889 100644
--- a/src/configs/commands.config.json
+++ b/src/configs/commands.config.json
@@ -19,6 +19,16 @@
"name": "loadout",
"description": "Get CoD Mobile User Loadout",
"file": "./commands/loadout.js"
+ },
+ {
+ "name": "vaccine",
+ "description": "Get Vaccine Availability by Pincode",
+ "file": "./commands/vaccine.js"
+ },
+ {
+ "name": "gt",
+ "description": "Game of Thrones Quotes",
+ "file": "./commands/gt.js"
}
]
} \ No newline at end of file