aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/bb.js28
-rw-r--r--src/commands/dark.js29
-rw-r--r--src/commands/got.js28
-rw-r--r--src/commands/jokes.js28
-rw-r--r--src/commands/loadout.js79
-rw-r--r--src/commands/play.js52
-rw-r--r--src/commands/radioStart.js54
-rw-r--r--src/commands/radioStop.js23
-rw-r--r--src/commands/stop.js17
-rw-r--r--src/commands/vaccine.js41
10 files changed, 77 insertions, 302 deletions
diff --git a/src/commands/bb.js b/src/commands/bb.js
deleted file mode 100644
index bfd0c3a..0000000
--- a/src/commands/bb.js
+++ /dev/null
@@ -1,28 +0,0 @@
-const axios = require('axios').default;
-const { MessageEmbed } = require('discord.js');
-const instance = axios.create({
- baseURL: 'https://breaking-bad-quotes.herokuapp.com/v1'
-});
-
-async function getRandomQuotes(message, args) {
- const randomQuotesUrl = "/quotes";
- try {
- const result = await instance.get(randomQuotesUrl);
- const { quote, author } = result.data[0];
- const randomQuoteMessage = new MessageEmbed()
- .setDescription(quote)
- .setFooter(`${author}`);
- message.channel.send(randomQuoteMessage);
- } catch (error) {
- const errorMessage = new MessageEmbed()
- .setTitle("Stay out of territory: Error getting quotes from Walter White")
- .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/dark.js b/src/commands/dark.js
deleted file mode 100644
index 54a486d..0000000
--- a/src/commands/dark.js
+++ /dev/null
@@ -1,29 +0,0 @@
-const axios = require('axios').default;
-const { MessageEmbed } = require('discord.js');
-const instance = axios.create({
- baseURL: 'https://dark-api.herokuapp.com/api/v1'
-});
-
-async function getRandomQuotes(message, args) {
- const randomQuotesUrl = "/quote/random";
- try {
- const result = await instance.get(randomQuotesUrl);
- const { author, season, episode, quote } = result.data;
- const randomQuoteMessage = new MessageEmbed()
- .setDescription(quote)
- .setFooter(`${author}, S${season} : Episode - ${episode}`);
- message.channel.send(randomQuoteMessage);
- } catch (error) {
- const errorMessage = new MessageEmbed()
- .setTitle("Something went wrong: Error getting quotes from Mikkel Nielsen")
- .setColor("RED");
- message.channel.send(errorMessage);
- }
-}
-
-module.exports = {
- execute(client, message, args) {
- getRandomQuotes(message, args);
- }
-}
-
diff --git a/src/commands/got.js b/src/commands/got.js
deleted file mode 100644
index bfb9295..0000000
--- a/src/commands/got.js
+++ /dev/null
@@ -1,28 +0,0 @@
-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/jokes.js b/src/commands/jokes.js
deleted file mode 100644
index 578e51b..0000000
--- a/src/commands/jokes.js
+++ /dev/null
@@ -1,28 +0,0 @@
-const fetch = require('node-fetch');
-
-function randomJokes(message) {
- message.channel.startTyping();
- getJokes().then(response => {
- message.channel.stopTyping();
- if (response) {
- message.channel.startTyping();
- message.reply(response.setup);
- setTimeout(() => {
- message.channel.stopTyping();
- message.reply(`||${response.punchline}||`);
- }, 5000);
- }
- });
-}
-
-async function getJokes() {
- return fetch(`https://official-joke-api.appspot.com/jokes/random`)
- .then(res => res.json())
-}
-
-
-module.exports = {
- execute(client,message, args) {
- randomJokes(message);
- }
-} \ No newline at end of file
diff --git a/src/commands/loadout.js b/src/commands/loadout.js
deleted file mode 100644
index 7580e60..0000000
--- a/src/commands/loadout.js
+++ /dev/null
@@ -1,79 +0,0 @@
-const Airtable = require('airtable');
-const {MessageEmbed} = require('discord.js');
-Airtable.configure({
- endpointUrl: 'https://api.airtable.com',
- apiKey: process.env.AIRTABLE_KEY
-});
-const base = Airtable.base('appppieGLc8loZp5H');
-const AirTableConfigs = {
- MAIN_TABLE: 'cod_loadout',
- WEAPONS_TYPE_TABLE: 'Weapon Types',
- WEAPONS_TABLE: 'Weapons',
- GRID_VIEW: 'Grid view',
- WEAPON_TYPE: 'cod_weapon_type',
- WEAPON_NAME: 'cod_weapon_name',
- MATCH_TYPE: 'cod_match_type',
- ATTACHMENTS: 'cod_weapon_attachments',
-};
-
-async function getCodMLoadOut(message, args) {
- const codUserName = args[0];
- if (!codUserName) return;
- base(AirTableConfigs.MAIN_TABLE).select({
- maxRecords: 2,
- view: AirTableConfigs.GRID_VIEW,
- filterByFormula: `({cod_username} = '${args[0]}')`
- }).eachPage((records, fetchNextPage) => {
- if (records && records.length > 0) {
- records.forEach(async (record) => {
- const weaponType = await getWeaponType(record.get(AirTableConfigs.WEAPON_TYPE));
- const weaponName = await getWeaponName(record.get(AirTableConfigs.WEAPON_NAME));
- const loadOutMessage = new MessageEmbed()
- .setTitle(`Loadout of ${codUserName} : ${record.get(AirTableConfigs.MATCH_TYPE)}`)
- .addField('Weapon Name', weaponName, true)
- .addField('Weapon Type', weaponType, true)
- .addField('Attachments', record.get(AirTableConfigs.ATTACHMENTS), true)
- .setColor("RANDOM");
- message.channel.send(loadOutMessage);
- });
- fetchNextPage();
- } else {
- message.channel.send(`No Loadout found for ***${codUserName}***`);
- }
-
- }, function done(err) {
- if (err) { console.error(err); return; }
- });
-}
-
-async function getWeaponType(weaponType) {
- return new Promise((resolve, reject) => {
- base(AirTableConfigs.WEAPONS_TYPE_TABLE).find(weaponType, (error, record) => {
- if (error) {
- console.log(error);
- reject();
- } else {
- resolve(record.get(AirTableConfigs.WEAPON_TYPE));
- }
- });
- })
-}
-
-async function getWeaponName(weaponName) {
- return new Promise((resolve, reject) => {
- base(AirTableConfigs.WEAPONS_TABLE).find(weaponName, (error, record) => {
- if (error) {
- console.log(error);
- reject();
- } else {
- resolve(record.get(AirTableConfigs.WEAPON_NAME));
- }
- });
- })
-}
-
-module.exports = {
- execute(client,message, args) {
- getCodMLoadOut(message,args);
- }
-} \ No newline at end of file
diff --git a/src/commands/play.js b/src/commands/play.js
deleted file mode 100644
index 9c2d7a3..0000000
--- a/src/commands/play.js
+++ /dev/null
@@ -1,52 +0,0 @@
-const ytdl = require('ytdl-core');
-const ytSearch = require('yt-search');
-async function playMusik(client, message, args) {
- const voiceChannel = message.member.voice.channel;
- if (!voiceChannel) {
- return message.channel.send("Join a voice channel to Play Music");
- }
- const permission = voiceChannel.permissionsFor(message.client.user);
- if (!permission.has('CONNECT') || !permission.has('SPEAK')) {
- return message.channel.send("You don't have the permission to play music. 😥");
- }
-
- if (!args.length) {
- return message.channel.send("Please pass something to play as second argument");
- }
-
- const connection = await voiceChannel.join();
- let videoUrl = false;
- let video;
- const youtubeRegex = /(http:|https:)?\/\/(www\.)?(youtube.com|youtu.be)\/(watch)?(\?v=)?(\S+)?/;
- if (youtubeRegex.test(args[0])) {
- video = args[0];
- videoUrl = true;
- } else {
- video = await searchVideo(args.join(' '));
- }
-
- if (video) {
- const youtubeStream = ytdl(videoUrl ? video : video.url, { filter: 'audioonly' });
- client.user.setPresence({ activity: { name: `${video.title}`, type: 'LISTENING' } });
- connection.play(youtubeStream, { seek: 0, volume: 1 })
- .on('finish', () => {
- voiceChannel.leave();
- client.user.setPresence({ activity: { name: ` ` } });
- });
- await message.reply(`Now Playing ${videoUrl ? args[0] : video.title}...`);
- } else {
- message.channel.send("No music found to play for you mate. Try again! 👍");
- }
-}
-
-async function searchVideo(query) {
- const searchResult = await ytSearch(query);
- return (searchResult.videos.length > 1) ? searchResult.videos[0] : null;
-}
-
-
-module.exports = {
- execute(client,message, args) {
- playMusik(client,message,args);
- }
-} \ No newline at end of file
diff --git a/src/commands/radioStart.js b/src/commands/radioStart.js
new file mode 100644
index 0000000..d9c4ac1
--- /dev/null
+++ b/src/commands/radioStart.js
@@ -0,0 +1,54 @@
+const { VoiceChannel, TextChannel, MessageEmbed } = require("discord.js");
+const axios = require('axios').default;
+
+const instance = axios.create({
+ baseURL: 'http://retrowave.ru/api/v1'
+});
+
+const resourceUrl = 'http://retrowave.ru'
+
+async function broadcastRadio(client, args, message, voiceChannel, textChannel) {
+ const connection = await voiceChannel.join();
+ try {
+ playRadio(connection, textChannel);
+ } catch (error) {
+ console.log(error);
+ textChannel.send('Something went wrong. RADIO MON got ill...😱😱');
+ }
+
+}
+
+async function playRadio(connection,textChannel) {
+ const nextMusic = await getNextMusic();
+ const { id, title, streamUrl, artworkUrl } = nextMusic;
+ const nowPlayingMessage = new MessageEmbed()
+ .setTitle("Now Playing")
+ .setDescription(title)
+ .setColor('LUMINOUS_VIVID_PINK')
+ .setThumbnail(`${resourceUrl}${artworkUrl}`);
+ textChannel.send(nowPlayingMessage)
+ connection.play(`${resourceUrl}${streamUrl}`, { seek: 0, volume: 1 })
+ .on('finish', () => {
+ playRadio(connection,textChannel);
+ });
+}
+
+async function getNextMusic() {
+ const result = await instance.get('/tracks?cursor=1&limit=1');
+ return result.data.body.tracks[0];
+}
+
+module.exports = {
+ async execute(client, message, args) {
+ const { RADIO_CHANNEL, NOW_PLAYING_CHANNEL } = process.env;
+ if (!RADIO_CHANNEL) return message.reply(`Please add RADIO_CHANNEL to .env with a Voice Channel ID`);
+ if (!NOW_PLAYING_CHANNEL) return message.reply(`Please add NOW_PLAYING_CHANNEL to .env with a Text Channel ID`);
+
+ const voiceChannel = await client.channels.fetch(process.env.RADIO_CHANNEL);
+ const nowPlayingChannel = await client.channels.fetch(process.env.NOW_PLAYING_CHANNEL);
+ if (!(voiceChannel instanceof VoiceChannel)) return message.reply(`Please provice a Voice Channel ID to the RADIO_CHANNEL`);
+ if (!(nowPlayingChannel instanceof TextChannel)) return message.reply(`Please provice a Text Channel ID to the NOW_PLAYING_CHANNEL`);
+
+ broadcastRadio(client, args, message, voiceChannel, nowPlayingChannel);
+ }
+} \ No newline at end of file
diff --git a/src/commands/radioStop.js b/src/commands/radioStop.js
new file mode 100644
index 0000000..8d5786d
--- /dev/null
+++ b/src/commands/radioStop.js
@@ -0,0 +1,23 @@
+const { VoiceChannel, TextChannel } = require("discord.js");
+
+async function stopRadioBroadcast(client, args, message, voiceChannel, textChannel) {
+ if (voiceChannel) {
+ await voiceChannel.leave();
+ textChannel.send('RADIO Stopped');
+ }
+}
+
+module.exports = {
+ async execute(client, message, args) {
+ const { RADIO_CHANNEL, NOW_PLAYING_CHANNEL } = process.env;
+ if (!RADIO_CHANNEL) return message.reply(`Please add RADIO_CHANNEL to .env with a Voice Channel ID`);
+ if (!NOW_PLAYING_CHANNEL) return message.reply(`Please add NOW_PLAYING_CHANNEL to .env with a Text Channel ID`);
+
+ const voiceChannel = await client.channels.fetch(process.env.RADIO_CHANNEL);
+ const nowPlayingChannel = await client.channels.fetch(process.env.NOW_PLAYING_CHANNEL);
+ if (!(voiceChannel instanceof VoiceChannel)) return message.reply(`Please provice a Voice Channel ID to the RADIO_CHANNEL`);
+ if (!(nowPlayingChannel instanceof TextChannel)) return message.reply(`Please provice a Text Channel ID to the NOW_PLAYING_CHANNEL`);
+
+ stopRadioBroadcast(client, args, message, voiceChannel, nowPlayingChannel);
+ }
+} \ No newline at end of file
diff --git a/src/commands/stop.js b/src/commands/stop.js
deleted file mode 100644
index 0c5e3df..0000000
--- a/src/commands/stop.js
+++ /dev/null
@@ -1,17 +0,0 @@
-async function stopMusik(client,message) {
- const voiceChannel = message.member.voice.channel;
-
- if (!voiceChannel) {
- return message.channel.send("Join a voice channel to Execute this command");
- }
-
- await voiceChannel.leave();
- await message.channel.send("Stoping Music... Baye Baye.... 😅");
- client.user.setPresence({ activity: { name: `COMMANDS`, type: 'LISTENING' } });
-}
-
-module.exports = {
- execute(client,message, args) {
- stopMusik(client, message);
- }
-} \ No newline at end of file
diff --git a/src/commands/vaccine.js b/src/commands/vaccine.js
deleted file mode 100644
index e1219f2..0000000
--- a/src/commands/vaccine.js
+++ /dev/null
@@ -1,41 +0,0 @@
-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