aboutsummaryrefslogtreecommitdiff
path: root/src/main.js
diff options
context:
space:
mode:
authorIndrajith K L2021-03-27 17:03:16 +0530
committerIndrajith K L2021-03-27 17:03:16 +0530
commit6f07b57b89ff39d47279bc2ce451493701314212 (patch)
tree8c9018ed75582d2508029532867840bbdd0e9f39 /src/main.js
parent965412619a87969c0e62236049880a39611917bd (diff)
downloadlul-bot-6f07b57b89ff39d47279bc2ce451493701314212.tar.gz
lul-bot-6f07b57b89ff39d47279bc2ce451493701314212.tar.bz2
lul-bot-6f07b57b89ff39d47279bc2ce451493701314212.zip
Integrates AirTable
Adds New Command Weapons Loadout
Diffstat (limited to 'src/main.js')
-rw-r--r--src/main.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/main.js b/src/main.js
index 3648b2d..f1df54b 100644
--- a/src/main.js
+++ b/src/main.js
@@ -3,6 +3,12 @@ const { Client, MessageEmbed, Collection } = require('discord.js');
const fetch = require('node-fetch');
const ytdl = require('ytdl-core');
const ytSearch = require('yt-search');
+const Airtable = require('airtable');
+Airtable.configure({
+ endpointUrl: 'https://api.airtable.com',
+ apiKey: process.env.AIRTABLE_KEY
+});
+const base = Airtable.base('appppieGLc8loZp5H');
const client = new Client();
const CMD_PREFIX = "!";
@@ -79,6 +85,7 @@ function parseCMD(message) {
case 'jokes': randomJokes(message); return {};
case 'play': playMusik(message, args); return {};
case 'stop': stopMusik(message); return {};
+ case 'loadout': getCodMLoadOut(message, args); return{};
default: return null;
}
}
@@ -151,9 +158,11 @@ async function playMusik(message, args) {
if (video) {
const youtubeStream = ytdl(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 ${video.title}...`);
} else {
@@ -170,6 +179,7 @@ async function stopMusik(message) {
await voiceChannel.leave();
await message.channel.send("Stoping Music... Baye Baye.... 😅");
+ client.user.setPresence({activity: {name: `COMMANDS`, type: 'LISTENING'}});
}
async function searchVideo(query) {
@@ -177,6 +187,30 @@ async function searchVideo(query) {
return (searchResult.videos.length > 1) ? searchResult.videos[0] : null;
}
+async function getCodMLoadOut(message, args) {
+ const codUserName = args[0];
+ if(!codUserName) return;
+ base('cod_loadout').select({
+ maxRecords: 2,
+ view: "Grid view",
+ filterByFormula: `({cod_username} = '${args[0]}')`
+ }).eachPage(function page(records, fetchNextPage) {
+ records.forEach((record) => {
+ const loadOutMessage = new MessageEmbed()
+ .setTitle(`Loadout of ${codUserName} : ${record.get('cod_match_type')}`)
+ .addField('Weapon Name', record.get('cod_weapon_name'),true)
+ .addField('Weapon Type', record.get('cod_weapon_type'),true)
+ .addField('Attachments', record.get('cod_weapon_attachments'),true)
+ .setColor("RANDOM");
+ message.channel.send(loadOutMessage);
+ });
+ fetchNextPage();
+
+ }, function done(err) {
+ if (err) { console.error(err); return; }
+ });
+}
+
client.login(process.env.LUL_BOT_TKN)
.then(() => {
intervalJokes();