commit 6ddb0b77812cf7d3cf92044d985f6889fbb7108b
parent 4f3feb9504786a14e73e2b5af684de202166e200
Author: night0721 <[email protected]>
Date: Thu, 27 Jan 2022 08:33:56 +0800
scorestreak command
Diffstat:
8 files changed, 176 insertions(+), 363 deletions(-)
diff --git a/client/CODMClient.js b/client/CODMClient.js
@@ -1,2 +1,2 @@
const { CODMClient } = require("cath");
-module.exports = new CODMClient("Gae");
+module.exports = new CODMClient(process.env.CODM_API_KEY);
diff --git a/command/CODM/build.js b/command/CODM/build.js
@@ -764,7 +764,7 @@ module.exports = {
`${process.env.api}/api/v1/codm/builds?name=${gun}&cc=${cc}&tag=${tag}`,
{
headers: {
- Authorization: "Gae",
+ Authorization: process.env.CODM_API_KEY,
},
}
)
diff --git a/command/CODM/perk.js b/command/CODM/perk.js
@@ -1,6 +1,5 @@
const { MessageEmbed } = require("discord.js");
-const { CODMClient } = require("cath");
-const c = new CODMClient("Gae");
+const c = require("../../client/CODMClient");
module.exports = {
name: "perk",
description: "Get perk stats",
diff --git a/command/CODM/scorestreak.js b/command/CODM/scorestreak.js
@@ -0,0 +1,169 @@
+const { MessageEmbed } = require("discord.js");
+const c = require("../../client/CODMClient");
+module.exports = {
+ name: "scorestreak",
+ description: "Get Scorestreak stats",
+ type: "CHAT_INPUT",
+ usage: "{Scorestreak}",
+ category: "CODM",
+ options: [
+ {
+ type: "SUB_COMMAND",
+ name: "lethal",
+ description: "Lethal Scorestreak",
+ options: [
+ {
+ type: 3,
+ name: "scorestreak",
+ description: "Select a lethal scorestreak",
+ required: true,
+ choices: [
+ {
+ name: "Shield Turret",
+ value: "shieldturret",
+ },
+ {
+ name: "Hunter Killer Drone",
+ value: "hunterkillerdrone",
+ },
+ {
+ name: "MQ-27 Dragonfire",
+ value: "mq27dragonfire",
+ },
+ {
+ name: "Predator Missile",
+ value: "predatormissile",
+ },
+ {
+ name: "Hawk X3",
+ value: "hawkx3",
+ },
+ {
+ name: "Sentry Gun",
+ value: "sentrygun",
+ },
+ {
+ name: "Lightning Strike",
+ value: "lightningstrike",
+ },
+ {
+ name: "Orbital Laser",
+ value: "orbitallaser",
+ },
+ {
+ name: "XS1 Goliath",
+ value: "xs1goliath",
+ },
+ {
+ name: "Cluster Strike",
+ value: "clusterstrike",
+ },
+ {
+ name: "Stealth Chopper",
+ value: "stealthchopper",
+ },
+ {
+ name: "Swarm",
+ value: "swarm",
+ },
+ {
+ name: "Napalm",
+ value: "napalm",
+ },
+ {
+ name: "VTOL",
+ value: "vtol",
+ },
+ ],
+ },
+ ],
+ },
+ {
+ type: "SUB_COMMAND",
+ name: "support",
+ description: "Support Scorestreak",
+ options: [
+ {
+ type: 3,
+ name: "scorestreak",
+ description: "Select a Support Scorestreak",
+ required: true,
+ choices: [
+ {
+ name: "UAV",
+ value: "uav",
+ },
+ {
+ name: "Shock RC",
+ value: "shockrc",
+ },
+ {
+ name: "Care Package",
+ value: "carepackage",
+ },
+ {
+ name: "Counter UAV",
+ value: "cuav",
+ },
+ {
+ name: "SAM Turret",
+ value: "samturret",
+ },
+ {
+ name: "Advance UAV",
+ value: "auav",
+ },
+ {
+ name: "EMP Systems",
+ value: "empsystems",
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ run: async (client, interaction, args) => {
+ const val = args[1];
+ const d = await c.getscorestreak(val);
+ const embed = new MessageEmbed()
+ .setTitle(d.name)
+ .setURL(d.preview_video)
+ .setDescription(`\`\`\`${d.description}\`\`\``)
+ .addFields(
+ {
+ name: "Cost",
+ value: `\`\`\`${d.cost}\`\`\``,
+ inline: true,
+ },
+ {
+ name: "AI-Assisted",
+ value: `
+ ${
+ d.manual
+ ? "<a:nyx_checkmark:897240322411724841> Yes"
+ : "<a:nyx_cross:897244999211696198> No"
+ }`,
+ inline: true,
+ },
+ {
+ name: "More Info",
+ value: `\`\`\`${d.special ? d.special : "** **"}\`\`\``,
+ inline: false,
+ }
+ )
+ .setThumbnail(d.preview)
+ .setFooter({
+ text: `Made by ${client.author}`,
+ iconURL: client.user.displayAvatarURL(),
+ })
+ .setColor(
+ d.type == "lethal"
+ ? "FF2222"
+ : d.type == "assist"
+ ? "22FF4A"
+ : client.color
+ )
+ .setTimestamp();
+ interaction.followUp({ embeds: [embed] });
+ },
+};
diff --git a/command/Owner/scorestreak.js b/command/Owner/scorestreak.js
@@ -1,177 +0,0 @@
-const { MessageEmbed } = require("discord.js");
-const { CODMClient } = require("cath");
-const c = new CODMClient("Gae");
-module.exports = {
- name: "scorestreak",
- description: "Get Scorestreak stats",
- type: "CHAT_INPUT",
- usage: "{Scorestreak}",
- category: "CODM",
- options: [
- {
- type: "SUB_COMMAND",
- name: "lethal",
- description: "Lethal Scorestreak",
- options: [
- {
- type: 3,
- name: "scorestreak",
- description: "Select a lethal scorestreak",
- required: true,
- choices: [
- {
- name: "Shield Turret",
- value: "shieldturret",
- },
- {
- name: "Hunter Killer Drone",
- value: "hunterkillerdrone",
- },
- {
- name: "MQ-27 Dragonfire",
- value: "mq27dragonfire",
- },
- {
- name: "Predator Missile",
- value: "predatormissile",
- },
- {
- name: "Hawk X3",
- value: "hawkx3",
- },
- {
- name: "Sentry Gun",
- value: "sentrygun",
- },
- {
- name: "Lightning Strike",
- value: "lightningstrike",
- },
- {
- name: "Orbital Laser",
- value: "orbitallaser",
- },
- {
- name: "XS1 Goliath",
- value: "xs1goliath",
- },
- {
- name: "Cluster Strike",
- value: "clusterstrike",
- },
- {
- name: "XS1 Goliath",
- value: "xs1goliath",
- },
- {
- name: "Stealth Chopper",
- value: "stealthchopper",
- },
- {
- name: "Swarm",
- value: "swarm",
- },
- {
- name: "Napalm",
- value: "napalm",
- },
- {
- name: "VTOL",
- value: "vtol",
- },
- ],
- },
- ],
- },
- {
- type: "SUB_COMMAND",
- name: "support",
- description: "Support Scorestreak",
- options: [
- {
- type: 3,
- name: "scorestreak",
- description: "Select a Support Scorestreak",
- required: true,
- choices: [
- {
- name: "UAV",
- value: "uav",
- },
- {
- name: "Shock RC",
- value: "shockrc",
- },
- {
- name: "Care Package",
- value: "carepackage",
- },
- {
- name: "Counter UAV",
- value: "cuav",
- },
- {
- name: "SAM Turret",
- value: "samturret",
- },
- {
- name: "Advance UAV",
- value: "auav",
- },
- {
- name: "EMP Systems",
- value: "empsystems",
- },
- ],
- },
- ],
- },
- ],
- run: async (client, interaction, args) => {
- const val = args[1];
- const d = await c.getscorestreak(val);
- const embed = new MessageEmbed()
- .setTitle(d.scorestreak)
- .setURL(d.preview_video)
- .setDescription(`\`\`\`${d.description}\`\`\``)
- .addFields(
- {
- name: "Cost",
- value: `\`\`\`${d.cost}\`\`\``,
- inline: true
- },
- {
- name: "Lethal",
- value: `
- ${d.lethal == true
- ? "<a:nyx_checkmark:897240322411724841> Yes"
- : "<a:nyx_cross:897244999211696198> No"}`,
- inline: true
- },
- {
- name: "AI-Assisted",
- value: `
- ${d.manual == false
- ? "<a:nyx_checkmark:897240322411724841> Yes"
- : "<a:nyx_cross:897244999211696198> No"}`,
- inline: true
- },
- {
- name: "More Info",
- value: `\`\`\`${d.special}\`\`\``,
- inline: false
- }
- )
- .setThumbnail(`${d.preview}`)
- .setFooter(`Made by ${client.author}`, client.user.displayAvatarURL())
- .setColor(
- d.type == "lethal"
- ? "FF2222"
- : d.type == "support"
- ? "22FF4A"
- : client.color
- )
- .setTimestamp();
- interaction.followUp({ embeds: [embed] });
- },
-};
diff --git a/package.json b/package.json
@@ -41,7 +41,7 @@
},
"dependencies": {
"axios": "^0.25.0",
- "cath": "^1.4.6",
+ "cath": "^1.4.7",
"discord.js": "^13.6.0",
"dotenv": "^14.2.0",
"erela.js": "^2.3.3",
diff --git a/scorestreak.js b/scorestreak.js
@@ -1,181 +0,0 @@
-const { MessageEmbed } = require("discord.js");
-const { CODMClient } = require("cath");
-const c = new CODMClient("Gae");
-module.exports = {
- name: "scorestreak",
- description: "Get Scorestreak stats",
- type: "CHAT_INPUT",
- usage: "{Scorestreak}",
- category: "CODM",
- options: [
- {
- type: "SUB_COMMAND",
- name: "lethal",
- description: "Lethal Scorestreak",
- options: [
- {
- type: 3,
- name: "scorestreak",
- description: "Select a lethal scorestreak",
- required: true,
- choices: [
- {
- name: "Shield Turret",
- value: "shieldturret",
- },
- {
- name: "Hunter Killer Drone",
- value: "hunterkillerdrone",
- },
- {
- name: "MQ-27 Dragonfire",
- value: "mq27dragonfire",
- },
- {
- name: "Predator Missile",
- value: "predatormissile",
- },
- {
- name: "Hawk X3",
- value: "hawkx3",
- },
- {
- name: "Sentry Gun",
- value: "sentrygun",
- },
- {
- name: "Lightning Strike",
- value: "lightningstrike",
- },
- {
- name: "Orbital Laser",
- value: "orbitallaser",
- },
- {
- name: "XS1 Goliath",
- value: "xs1goliath",
- },
- {
- name: "Cluster Strike",
- value: "clusterstrike",
- },
- {
- name: "XS1 Goliath",
- value: "xs1goliath",
- },
- {
- name: "Stealth Chopper",
- value: "stealthchopper",
- },
- {
- name: "Swarm",
- value: "swarm",
- },
- {
- name: "Napalm",
- value: "napalm",
- },
- {
- name: "VTOL",
- value: "vtol",
- },
- ],
- },
- ],
- },
- {
- type: "SUB_COMMAND",
- name: "support",
- description: "Support Scorestreak",
- options: [
- {
- type: 3,
- name: "scorestreak",
- description: "Select a Support Scorestreak",
- required: true,
- choices: [
- {
- name: "UAV",
- value: "uav",
- },
- {
- name: "Shock RC",
- value: "shockrc",
- },
- {
- name: "Care Package",
- value: "carepackage",
- },
- {
- name: "Counter UAV",
- value: "cuav",
- },
- {
- name: "SAM Turret",
- value: "samturret",
- },
- {
- name: "Advance UAV",
- value: "auav",
- },
- {
- name: "EMP Systems",
- value: "empsystems",
- },
- ],
- },
- ],
- },
- ],
- run: async (client, interaction, args) => {
- const val = args[1];
- const d = await c.getscorestreak(val);
- const embed = new MessageEmbed()
- .setTitle(d.scorestreak)
- .setURL(d.preview_video)
- .setDescription(`\`\`\`${d.description}\`\`\``)
- .addFields(
- {
- name: "Cost",
- value: `\`\`\`${d.cost}\`\`\``,
- inline: true,
- },
- {
- name: "Lethal",
- value: `
- ${
- d.lethal == true
- ? "<a:nyx_checkmark:897240322411724841> Yes"
- : "<a:nyx_cross:897244999211696198> No"
- }`,
- inline: true,
- },
- {
- name: "AI-Assisted",
- value: `
- ${
- d.manual == false
- ? "<a:nyx_checkmark:897240322411724841> Yes"
- : "<a:nyx_cross:897244999211696198> No"
- }`,
- inline: true,
- },
- {
- name: "More Info",
- value: `\`\`\`${d.special}\`\`\``,
- inline: false,
- }
- )
- .setThumbnail(d.preview)
- .setFooter(`Made by ${client.author}`, client.user.displayAvatarURL())
- .setColor(
- d.type == "lethal"
- ? "FF2222"
- : d.type == "support"
- ? "22FF4A"
- : client.color
- )
- .setTimestamp();
- interaction.followUp({ embeds: [embed] });
- },
-};
diff --git a/util/functions/common.js b/util/functions/common.js
@@ -5,6 +5,7 @@ const weaponActualName = nmDt.weaponActualName;
const weaponAlliasName = nmDt.weaponAlliasName;
Object.defineProperty(String.prototype, "Simplify", {
// Function to remove all characters except 0-9 and a-z
+ // Eg "AK-47" -> "ak47"
value: function Simplify() {
return this.toLowerCase().replace(/[^0-9a-z]/g, "");
},
@@ -112,6 +113,8 @@ function weaponIdentifier(inpmsg) {
: "There isn't any weapon name.";
}
let probableWeapons = [];
+ // Loop through all the weapons to find the probable weapons
+ // Eg: "ak"
for (let i = 0; i < data.cguns.length; i++) {
if (inpWeaponName.Simplify() == data.cguns[i].gunname.Simplify()) {
return JSON.parse(JSON.stringify(data.cguns[i]));