This commit is contained in:
night0721 2022-02-03 18:57:59 +08:00
parent 1540d7843c
commit 610ed6810a
7 changed files with 69 additions and 60 deletions

View file

@ -8,7 +8,7 @@ module.exports = {
category: "CODM", category: "CODM",
options: [ options: [
{ {
type: "SUB_COMMAND", type: 1,
name: "assault_rifle", name: "assault_rifle",
description: "Get a Stats for Assault Rifle", description: "Get a Stats for Assault Rifle",
options: [ options: [
@ -107,7 +107,7 @@ module.exports = {
], ],
}, },
{ {
type: "SUB_COMMAND", type: 1,
name: "sub_machine_gun", name: "sub_machine_gun",
description: "Get a Stats for Sub Machine Gun", description: "Get a Stats for Sub Machine Gun",
options: [ options: [
@ -190,7 +190,7 @@ module.exports = {
], ],
}, },
{ {
type: "SUB_COMMAND", type: 1,
name: "sniper_rifle", name: "sniper_rifle",
description: "Get a Stats for Sniper Rifle", description: "Get a Stats for Sniper Rifle",
options: [ options: [
@ -241,7 +241,7 @@ module.exports = {
], ],
}, },
{ {
type: "SUB_COMMAND", type: 1,
name: "light_machine_gun", name: "light_machine_gun",
description: "Get a Stats for Light Machine Gun", description: "Get a Stats for Light Machine Gun",
options: [ options: [
@ -288,7 +288,7 @@ module.exports = {
], ],
}, },
{ {
type: "SUB_COMMAND", type: 1,
name: "shotgun", name: "shotgun",
description: "Get a Stats for Shotgun", description: "Get a Stats for Shotgun",
options: [ options: [
@ -331,7 +331,7 @@ module.exports = {
], ],
}, },
{ {
type: "SUB_COMMAND", type: 1,
name: "marksman_rifle", name: "marksman_rifle",
description: "Get a Stats for Marksman Rifle", description: "Get a Stats for Marksman Rifle",
options: [ options: [
@ -362,7 +362,7 @@ module.exports = {
], ],
}, },
{ {
type: "SUB_COMMAND", type: 1,
name: "pistol", name: "pistol",
description: "Get a Stats for Pistol", description: "Get a Stats for Pistol",
options: [ options: [
@ -410,8 +410,8 @@ module.exports = {
Authorization: process.env.CODM_API_KEY, Authorization: process.env.CODM_API_KEY,
}, },
}) })
.then((res) => res.data) .then(res => res.data)
.catch((e) => null); .catch(e => null);
if (!data?.ID) { if (!data?.ID) {
const embed = new MessageEmbed() const embed = new MessageEmbed()
@ -422,14 +422,10 @@ module.exports = {
interaction.followUp({ embeds: [embed] }); interaction.followUp({ embeds: [embed] });
} else { } else {
const embed = new MessageEmbed() const embed = new MessageEmbed()
.setTitle( .setTitle(`${data.author} Statistical Breakdown`)
`${data.author} Statistical Breakdown`
)
.setColor(16580400) .setColor(16580400)
.setImage(data.imageUrl) .setImage(data.imageUrl)
.setFooter( .setFooter(`Stats Curtosy of Round Table`)
`Stats Curtosy of Round Table`,
)
// .setFooter( // .setFooter(
// `Stats Curtosy of Stats on Duty`, // `Stats Curtosy of Stats on Duty`,
// ) // )
@ -501,8 +497,6 @@ module.exports = {
// @night0721 Damage profile will be avalable by different command // @night0721 Damage profile will be avalable by different command
// recoilAvailable = false; // recoilAvailable = false;
// hasError = false; // hasError = false;
// console.log(args); // console.log(args);
@ -523,7 +517,6 @@ module.exports = {
// }, // },
// } // }
// run: async (client, interaction, args) => { // run: async (client, interaction, args) => {
// recoilAvailable = false; // recoilAvailable = false;
// hasError = false; // hasError = false;

View file

@ -9,7 +9,7 @@ module.exports = {
category: "CODM", category: "CODM",
options: [ options: [
{ {
type: "SUB_COMMAND", type: 1,
name: "assault_rifle", name: "assault_rifle",
description: "Get a gunsmith build for a Assault Rifle", description: "Get a gunsmith build for a Assault Rifle",
options: [ options: [
@ -112,7 +112,7 @@ module.exports = {
required: true, required: true,
choices: [ choices: [
{ {
name: "Path.exe", name: "path.exe",
value: "path.exe", value: "path.exe",
}, },
{ {
@ -152,7 +152,7 @@ module.exports = {
], ],
}, },
{ {
type: "SUB_COMMAND", type: 1,
name: "sub_machine_gun", name: "sub_machine_gun",
description: "Get a gunsmith build for a Sub Machine Gun", description: "Get a gunsmith build for a Sub Machine Gun",
options: [ options: [
@ -239,7 +239,7 @@ module.exports = {
required: true, required: true,
choices: [ choices: [
{ {
name: "Path.exe", name: "path.exe",
value: "path.exe", value: "path.exe",
}, },
{ {
@ -275,7 +275,7 @@ module.exports = {
], ],
}, },
{ {
type: "SUB_COMMAND", type: 1,
name: "sniper_rifle", name: "sniper_rifle",
description: "Get a gunsmith build for a Sniper Rifle", description: "Get a gunsmith build for a Sniper Rifle",
options: [ options: [
@ -330,7 +330,7 @@ module.exports = {
required: true, required: true,
choices: [ choices: [
{ {
name: "Path.exe", name: "path.exe",
value: "path.exe", value: "path.exe",
}, },
], ],
@ -362,7 +362,7 @@ module.exports = {
], ],
}, },
{ {
type: "SUB_COMMAND", type: 1,
name: "light_machine_gun", name: "light_machine_gun",
description: "Get a gunsmith build for a Light Machine Gun", description: "Get a gunsmith build for a Light Machine Gun",
options: [ options: [
@ -413,7 +413,7 @@ module.exports = {
required: true, required: true,
choices: [ choices: [
{ {
name: "Path.exe", name: "path.exe",
value: "path.exe", value: "path.exe",
}, },
], ],
@ -445,7 +445,7 @@ module.exports = {
], ],
}, },
{ {
type: "SUB_COMMAND", type: 1,
name: "shotgun", name: "shotgun",
description: "Get a gunsmith build for a Shotgun", description: "Get a gunsmith build for a Shotgun",
options: [ options: [
@ -492,7 +492,7 @@ module.exports = {
required: true, required: true,
choices: [ choices: [
{ {
name: "Path.exe", name: "path.exe",
value: "path.exe", value: "path.exe",
}, },
{ {
@ -520,7 +520,7 @@ module.exports = {
], ],
}, },
{ {
type: "SUB_COMMAND", type: 1,
name: "marksman_rifle", name: "marksman_rifle",
description: "Get a gunsmith build for a Marksman Rifle", description: "Get a gunsmith build for a Marksman Rifle",
options: [ options: [
@ -555,7 +555,7 @@ module.exports = {
required: true, required: true,
choices: [ choices: [
{ {
name: "Path.exe", name: "path.exe",
value: "path.exe", value: "path.exe",
}, },
{ {
@ -587,7 +587,7 @@ module.exports = {
], ],
}, },
{ {
type: "SUB_COMMAND", type: 1,
name: "pistol", name: "pistol",
description: "Get a gunsmith build for a Pistol", description: "Get a gunsmith build for a Pistol",
options: [ options: [
@ -630,7 +630,7 @@ module.exports = {
required: true, required: true,
choices: [ choices: [
{ {
name: "Path.exe", name: "path.exe",
value: "path.exe", value: "path.exe",
}, },
// { // {
@ -670,11 +670,10 @@ module.exports = {
.then(res => res.data) .then(res => res.data)
.catch(e => null); .catch(e => null);
var all = { var all = {
"path.exe": "Path.exe", "path.exe": "path.exe",
dhitman: "dHitman", dhitman: "dHitman",
jokesta: "Jokesta", jokesta: "Jokesta",
sod: "Stats On Duty", sod: "Stats On Duty",
aggressive: "Aggressive", aggressive: "Aggressive",
passive: "Passive", passive: "Passive",
respawn: "Respawn", respawn: "Respawn",

View file

@ -8,7 +8,7 @@ module.exports = {
category: "CODM", category: "CODM",
options: [ options: [
{ {
type: "SUB_COMMAND", type: 1,
name: "red", name: "red",
description: "Red Perk", description: "Red Perk",
options: [ options: [
@ -67,7 +67,7 @@ module.exports = {
], ],
}, },
{ {
type: "SUB_COMMAND", type: 1,
name: "green", name: "green",
description: "Green Perk", description: "Green Perk",
options: [ options: [
@ -122,7 +122,7 @@ module.exports = {
], ],
}, },
{ {
type: "SUB_COMMAND", type: 1,
name: "blue", name: "blue",
description: "Blue Perk", description: "Blue Perk",
options: [ options: [

View file

@ -58,20 +58,20 @@ module.exports = {
if (args.length == 1) if (args.length == 1)
repEmb = statsHandler(args.join(" ").replace("\n", " ")); repEmb = statsHandler(args.join(" ").replace("\n", " "));
else repEmb = statsHandler(args.join(" + ").replace("\n", " ")); else repEmb = statsHandler(args.join(" + ").replace("\n", " "));
if (hasError) { if (hasError) {
interaction.followUp({ content: `**${repEmb}**` });
} else {
if (recoilAvailable) {
repEmb.fields.push({
name: "**Recoil Graph**",
value:
"```\nThe Recoil graph below is dynamic (change based on attachment equipped)```",
});
const recoilImageLink = await chart.getShortUrl();
repEmb.image = { url: recoilImageLink };
}
interaction.followUp({ embeds: [new MessageEmbed(repEmb)] }); interaction.followUp({ embeds: [new MessageEmbed(repEmb)] });
} }
if (recoilAvailable) {
repEmb.fields.push({
name: "**Recoil Graph**",
value:
"```\nThe Recoil graph below is dynamic (change based on attachment equipped)```",
});
const recoilImageLink = await chart.getShortUrl();
repEmb.image = { url: recoilImageLink };
}
interaction.followUp({ embeds: [new MessageEmbed(repEmb)] });
}, },
}; };

View file

@ -12,7 +12,7 @@ client.on("interactionCreate", async interaction => {
if (option.type === "SUB_COMMAND_GROUP") { if (option.type === "SUB_COMMAND_GROUP") {
if (option.name) args.push(option.name); if (option.name) args.push(option.name);
option.options?.forEach(x => { option.options?.forEach(x => {
if (x.type === "SUB_COMMAND") { if (x.type === 1) {
if (x.name) args.push(x.name); if (x.name) args.push(x.name);
x.options?.forEach(y => { x.options?.forEach(y => {
if (y.value) args.push(y.value); if (y.value) args.push(y.value);
@ -23,7 +23,7 @@ client.on("interactionCreate", async interaction => {
if (x.value) args.push(x.value); if (x.value) args.push(x.value);
}); });
} }
if (option.type === "SUB_COMMAND") { if (option.type === 1) {
if (option.name) args.push(option.name); if (option.name) args.push(option.name);
option.options?.forEach(x => { option.options?.forEach(x => {
if (x.value) args.push(x.value); if (x.value) args.push(x.value);
@ -183,7 +183,7 @@ client.on("interactionCreate", async interaction => {
if (!ownercmd) return; if (!ownercmd) return;
const args = []; const args = [];
for (const option of interaction.options.data) { for (const option of interaction.options.data) {
if (option.type === "SUB_COMMAND") { if (option.type === 1) {
if (option.name) args.push(option.name); if (option.name) args.push(option.name);
option.options?.forEach(x => { option.options?.forEach(x => {
if (x.value) args.push(x.value); if (x.value) args.push(x.value);

View file

@ -5,7 +5,7 @@ module.exports = {
UserPerms: ["MANAGE_MESSAGES"], UserPerms: ["MANAGE_MESSAGES"],
options: [ options: [
{ {
type: "SUB_COMMAND", type: 1,
name: "start", name: "start",
description: "Start a giveaway", description: "Start a giveaway",
options: [ options: [
@ -53,7 +53,7 @@ module.exports = {
], ],
}, },
{ {
type: "SUB_COMMAND", type: 1,
name: "reroll", name: "reroll",
description: "Reroll a giveaway", description: "Reroll a giveaway",
options: [ options: [
@ -67,7 +67,7 @@ module.exports = {
], ],
}, },
{ {
type: "SUB_COMMAND", type: 1,
name: "end", name: "end",
description: "End a giveaway", description: "End a giveaway",
options: [ options: [

View file

@ -233,13 +233,17 @@ function attachmentsIdentifier(inpmsg, gun) {
// if probables list doesn't include the attachment, push // if probables list doesn't include the attachment, push
let probablePushed = false; let probablePushed = false;
for (let i4 = 0; i4 < probables.length; i4++) { for (let i4 = 0; i4 < probables.length; i4++) {
// push another attachment that also probable to the probables list to the same array that identified last loop
// Eg: probables = [ [32]] // as user input mag and first loop it identfified extended mag
// then as it got more possible, it will push large extended mag to the same array -> [ [32,33] ]
if (!probables[i4].includes(j)) { if (!probables[i4].includes(j)) {
probables[i4].push(j); probables[i4].push(j);
// make it true so that it doesn't push again in the next condition
probablePushed = true; probablePushed = true;
break; break;
} }
} }
// for the first loop as the probables array is emrpty // push if the attachment isn't been identified yet
if (!probablePushed) probables.push([j]); if (!probablePushed) probables.push([j]);
} }
} }
@ -250,28 +254,35 @@ function attachmentsIdentifier(inpmsg, gun) {
// finding magazines attachments // finding magazines attachments
if ( if (
(inputAttachmentsNames[i].includes(" rounds mag") || (inputAttachmentsNames[i].includes(" rounds mag") ||
inputAttachmentsNames[i].includes(" round mag")) && inputAttachmentsNames[i].includes(" round mag") ||
inputAttachmentsNames[i].includes(" round") ||
inputAttachmentsNames[i].includes(" rounds")) &&
inputAttachmentsNames[i].startsWith( inputAttachmentsNames[i].startsWith(
inputAttachmentsNames[i].replace(/\D/g, "") inputAttachmentsNames[i].replace(/\D/g, "")
) )
) { ) {
var tmp1 = parseInt(inputAttachmentsNames[i]); var tmp1 = parseInt(inputAttachmentsNames[i]);
// calculating the sum of number of rounds and see if it matches the input number of rounds
const tmp2 = gun.aments.filter( const tmp2 = gun.aments.filter(
x => x =>
x.type === 8 && x.effects[27] + x.effects[28] + gun.stats[17] === tmp1 x.type === 8 && x.effects[27] + x.effects[28] + gun.stats[17] === tmp1
); );
// push if the magazine is found
if (tmp2.length === 1) { if (tmp2.length === 1) {
outAttachments.push(tmp2[0]); outAttachments.push(tmp2[0]);
continue; continue;
} }
} }
// if probables is empty or there is more than one identified attachment
if ( if (
probables.length === 0 || probables.length === 0 ||
probables[probables.length - 1].length !== 1 || probables[probables.length - 1].length !== 1 ||
probables.length < splitInputAttachmentsName.length probables.length < splitInputAttachmentsName.length
) { ) {
probables = []; probables = [];
// the splitInputAttachmentsName isn't simplified pls rmb
splitInputAttachmentsName.map((x, i5) => splitInputAttachmentsName.map((x, i5) =>
// finding aliases
nmDt.attachmentAlliasName[1].map((y, i6) => nmDt.attachmentAlliasName[1].map((y, i6) =>
y.map(z => { y.map(z => {
if (x.Simplify() === z.Simplify()) { if (x.Simplify() === z.Simplify()) {
@ -401,7 +412,13 @@ function attachmentsIdentifier(inpmsg, gun) {
// console.log(attachmentsIdentifier("ak + 5mw lazer", data.cguns[0].aments)); makeError(); // console.log(attachmentsIdentifier("ak + 5mw lazer", data.cguns[0].aments)); makeError();
// console.log(attachmentsIdentifier("117 + 40 round mag", data.cguns[0].aments, data.cguns[0].stats)); makeError(); // console.log(attachmentsIdentifier("117 + 40 round mag", data.cguns[0].aments, data.cguns[0].stats)); makeError();
// console.log(attachmentsIdentifier("117 + rtc muzzle brake, rubberized griptape, tac lazer sight, 40 round mag, no stock", data.cguns[1].aments)); makeError(); // console.log(attachmentsIdentifier("117 + rtc muzzle brake, rubberized griptape, tac lazer sight, 40 round mag, no stock", data.cguns[1].aments)); makeError();
console.log(
attachmentsIdentifier(
"47 + 40 round mag + marksman + stippled + red dot",
data.cguns[0]
)
);
makeError();
function damageHandler( function damageHandler(
currDmgs, currDmgs,
currRngs, currRngs,