Integrates AirTable
Adds New Command Weapons Loadout
This commit is contained in:
22
package-lock.json
generated
22
package-lock.json
generated
@@ -73,6 +73,11 @@
|
|||||||
"event-target-shim": "^5.0.0"
|
"event-target-shim": "^5.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"abortcontroller-polyfill": {
|
||||||
|
"version": "1.7.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/abortcontroller-polyfill/-/abortcontroller-polyfill-1.7.1.tgz",
|
||||||
|
"integrity": "sha512-yml9NiDEH4M4p0G4AcPkg8AAa4mF3nfYF28VQxaokpO67j9H7gWgmsVWJ/f1Rn+PzsnDYvzJzWIQzCqDKRvWlA=="
|
||||||
|
},
|
||||||
"agent-base": {
|
"agent-base": {
|
||||||
"version": "6.0.2",
|
"version": "6.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
|
||||||
@@ -96,6 +101,18 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"airtable": {
|
||||||
|
"version": "0.10.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/airtable/-/airtable-0.10.1.tgz",
|
||||||
|
"integrity": "sha512-obFW+R3ly2mKtCj0D/xto0ggUvYwdM0RJT3VJ9wvgqoxDkzqg2mNtkuTNfYjF6wWQA0GvoHG9guqzgBBqFjItw==",
|
||||||
|
"requires": {
|
||||||
|
"@types/node": ">=8.0.0 <15",
|
||||||
|
"abort-controller": "^3.0.0",
|
||||||
|
"abortcontroller-polyfill": "^1.4.0",
|
||||||
|
"lodash": "^4.17.19",
|
||||||
|
"node-fetch": "^2.6.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"ansi-regex": {
|
"ansi-regex": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
|
||||||
@@ -673,6 +690,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/keypress/-/keypress-0.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/keypress/-/keypress-0.2.1.tgz",
|
||||||
"integrity": "sha1-HoBFQlABjbrUw/6USX1uZ7YmnHc="
|
"integrity": "sha1-HoBFQlABjbrUw/6USX1uZ7YmnHc="
|
||||||
},
|
},
|
||||||
|
"lodash": {
|
||||||
|
"version": "4.17.21",
|
||||||
|
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||||
|
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
|
||||||
|
},
|
||||||
"lodash.assignin": {
|
"lodash.assignin": {
|
||||||
"version": "4.2.0",
|
"version": "4.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/lodash.assignin/-/lodash.assignin-4.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/lodash.assignin/-/lodash.assignin-4.2.0.tgz",
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/opus": "^0.4.0",
|
"@discordjs/opus": "^0.4.0",
|
||||||
|
"airtable": "^0.10.1",
|
||||||
"discord.js": "^12.5.1",
|
"discord.js": "^12.5.1",
|
||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
"ffmpeg-static": "^4.2.7",
|
"ffmpeg-static": "^4.2.7",
|
||||||
|
|||||||
34
src/main.js
34
src/main.js
@@ -3,6 +3,12 @@ const { Client, MessageEmbed, Collection } = require('discord.js');
|
|||||||
const fetch = require('node-fetch');
|
const fetch = require('node-fetch');
|
||||||
const ytdl = require('ytdl-core');
|
const ytdl = require('ytdl-core');
|
||||||
const ytSearch = require('yt-search');
|
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 client = new Client();
|
||||||
const CMD_PREFIX = "!";
|
const CMD_PREFIX = "!";
|
||||||
@@ -79,6 +85,7 @@ function parseCMD(message) {
|
|||||||
case 'jokes': randomJokes(message); return {};
|
case 'jokes': randomJokes(message); return {};
|
||||||
case 'play': playMusik(message, args); return {};
|
case 'play': playMusik(message, args); return {};
|
||||||
case 'stop': stopMusik(message); return {};
|
case 'stop': stopMusik(message); return {};
|
||||||
|
case 'loadout': getCodMLoadOut(message, args); return{};
|
||||||
default: return null;
|
default: return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,9 +158,11 @@ async function playMusik(message, args) {
|
|||||||
|
|
||||||
if (video) {
|
if (video) {
|
||||||
const youtubeStream = ytdl(video.url, { filter: 'audioonly' });
|
const youtubeStream = ytdl(video.url, { filter: 'audioonly' });
|
||||||
|
client.user.setPresence({activity: {name: `${video.title}`, type: 'LISTENING'}});
|
||||||
connection.play(youtubeStream, { seek: 0, volume: 1 })
|
connection.play(youtubeStream, { seek: 0, volume: 1 })
|
||||||
.on('finish', () => {
|
.on('finish', () => {
|
||||||
voiceChannel.leave();
|
voiceChannel.leave();
|
||||||
|
client.user.setPresence({activity: {name: ` `}});
|
||||||
});
|
});
|
||||||
await message.reply(`Now Playing ${video.title}...`);
|
await message.reply(`Now Playing ${video.title}...`);
|
||||||
} else {
|
} else {
|
||||||
@@ -170,6 +179,7 @@ async function stopMusik(message) {
|
|||||||
|
|
||||||
await voiceChannel.leave();
|
await voiceChannel.leave();
|
||||||
await message.channel.send("Stoping Music... Baye Baye.... 😅");
|
await message.channel.send("Stoping Music... Baye Baye.... 😅");
|
||||||
|
client.user.setPresence({activity: {name: `COMMANDS`, type: 'LISTENING'}});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function searchVideo(query) {
|
async function searchVideo(query) {
|
||||||
@@ -177,6 +187,30 @@ async function searchVideo(query) {
|
|||||||
return (searchResult.videos.length > 1) ? searchResult.videos[0] : null;
|
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)
|
client.login(process.env.LUL_BOT_TKN)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
intervalJokes();
|
intervalJokes();
|
||||||
|
|||||||
Reference in New Issue
Block a user