aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/commands/gt.js28
-rw-r--r--src/commands/vaccine.js41
-rw-r--r--src/configs/commands.config.json10
3 files changed, 79 insertions, 0 deletions
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