scorestreak command

This commit is contained in:
night0721 2022-01-27 08:33:56 +08:00
parent 4f3feb9504
commit 6ddb0b7781
7 changed files with 16 additions and 203 deletions

View file

@ -1,2 +1,2 @@
const { CODMClient } = require("cath");
module.exports = new CODMClient("Gae");
module.exports = new CODMClient(process.env.CODM_API_KEY);

View file

@ -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,
},
}
)

View file

@ -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",

View file

@ -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: "scorestreak",
description: "Get Scorestreak stats",
@ -59,10 +58,6 @@ module.exports = {
name: "Cluster Strike",
value: "clusterstrike",
},
{
name: "XS1 Goliath",
value: "xs1goliath",
},
{
name: "Stealth Chopper",
value: "stealthchopper",
@ -131,7 +126,7 @@ module.exports = {
const val = args[1];
const d = await c.getscorestreak(val);
const embed = new MessageEmbed()
.setTitle(d.scorestreak)
.setTitle(d.name)
.setURL(d.preview_video)
.setDescription(`\`\`\`${d.description}\`\`\``)
.addFields(
@ -140,21 +135,11 @@ module.exports = {
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
d.manual
? "<a:nyx_checkmark:897240322411724841> Yes"
: "<a:nyx_cross:897244999211696198> No"
}`,
@ -162,16 +147,19 @@ module.exports = {
},
{
name: "More Info",
value: `\`\`\`${d.special}\`\`\``,
value: `\`\`\`${d.special ? d.special : "** **"}\`\`\``,
inline: false,
}
)
.setThumbnail(d.preview)
.setFooter(`Made by ${client.author}`, client.user.displayAvatarURL())
.setFooter({
text: `Made by ${client.author}`,
iconURL: client.user.displayAvatarURL(),
})
.setColor(
d.type == "lethal"
? "FF2222"
: d.type == "support"
: d.type == "assist"
? "22FF4A"
: client.color
)

View file

@ -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] });
},
};

View file

@ -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",

View file

@ -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]));