commit 610ed6810a015ae2c923892d970afea0fb95cd0c
parent 1540d7843c06f59aa5176f33bf1e836fd83e1ee8
Author: night0721 <[email protected]>
Date: Thu, 3 Feb 2022 18:57:59 +0800
yoooo
Diffstat:
7 files changed, 69 insertions(+), 60 deletions(-)
diff --git a/CODM/new-stats.js b/CODM/new-stats.js
@@ -8,7 +8,7 @@ module.exports = {
category: "CODM",
options: [
{
- type: "SUB_COMMAND",
+ type: 1,
name: "assault_rifle",
description: "Get a Stats for Assault Rifle",
options: [
@@ -107,7 +107,7 @@ module.exports = {
],
},
{
- type: "SUB_COMMAND",
+ type: 1,
name: "sub_machine_gun",
description: "Get a Stats for Sub Machine Gun",
options: [
@@ -190,7 +190,7 @@ module.exports = {
],
},
{
- type: "SUB_COMMAND",
+ type: 1,
name: "sniper_rifle",
description: "Get a Stats for Sniper Rifle",
options: [
@@ -241,7 +241,7 @@ module.exports = {
],
},
{
- type: "SUB_COMMAND",
+ type: 1,
name: "light_machine_gun",
description: "Get a Stats for Light Machine Gun",
options: [
@@ -288,7 +288,7 @@ module.exports = {
],
},
{
- type: "SUB_COMMAND",
+ type: 1,
name: "shotgun",
description: "Get a Stats for Shotgun",
options: [
@@ -331,7 +331,7 @@ module.exports = {
],
},
{
- type: "SUB_COMMAND",
+ type: 1,
name: "marksman_rifle",
description: "Get a Stats for Marksman Rifle",
options: [
@@ -362,7 +362,7 @@ module.exports = {
],
},
{
- type: "SUB_COMMAND",
+ type: 1,
name: "pistol",
description: "Get a Stats for Pistol",
options: [
@@ -410,8 +410,8 @@ module.exports = {
Authorization: process.env.CODM_API_KEY,
},
})
- .then((res) => res.data)
- .catch((e) => null);
+ .then(res => res.data)
+ .catch(e => null);
if (!data?.ID) {
const embed = new MessageEmbed()
@@ -422,14 +422,10 @@ module.exports = {
interaction.followUp({ embeds: [embed] });
} else {
const embed = new MessageEmbed()
- .setTitle(
- `${data.author} Statistical Breakdown`
- )
+ .setTitle(`${data.author} Statistical Breakdown`)
.setColor(16580400)
.setImage(data.imageUrl)
- .setFooter(
- `Stats Curtosy of Round Table`,
- )
+ .setFooter(`Stats Curtosy of Round Table`)
// .setFooter(
// `Stats Curtosy of Stats on Duty`,
// )
@@ -448,7 +444,7 @@ module.exports = {
"MMMM Do YYYY"
)}\n\`\`\``,
inline: true,
- },
+ },
{
name: "Basic Stats",
value: `\`\`\`\n
@@ -473,7 +469,7 @@ module.exports = {
inline: false,
},
{
- name: "Ammunation Stats",
+ name: "Ammunation Stats",
value: `\`\`\`\n
Magazine : 30
Reserve : 120
@@ -499,9 +495,7 @@ module.exports = {
},
};
-// @night0721 Damage profile will be avalable by different command
-
-
+// @night0721 Damage profile will be avalable by different command
// recoilAvailable = false;
// hasError = false;
@@ -523,7 +517,6 @@ module.exports = {
// },
// }
-
// run: async (client, interaction, args) => {
// recoilAvailable = false;
// hasError = false;
diff --git a/command/CODM/build.js b/command/CODM/build.js
@@ -9,7 +9,7 @@ module.exports = {
category: "CODM",
options: [
{
- type: "SUB_COMMAND",
+ type: 1,
name: "assault_rifle",
description: "Get a gunsmith build for a Assault Rifle",
options: [
@@ -112,7 +112,7 @@ module.exports = {
required: true,
choices: [
{
- name: "Path.exe",
+ name: "path.exe",
value: "path.exe",
},
{
@@ -152,7 +152,7 @@ module.exports = {
],
},
{
- type: "SUB_COMMAND",
+ type: 1,
name: "sub_machine_gun",
description: "Get a gunsmith build for a Sub Machine Gun",
options: [
@@ -239,7 +239,7 @@ module.exports = {
required: true,
choices: [
{
- name: "Path.exe",
+ name: "path.exe",
value: "path.exe",
},
{
@@ -275,7 +275,7 @@ module.exports = {
],
},
{
- type: "SUB_COMMAND",
+ type: 1,
name: "sniper_rifle",
description: "Get a gunsmith build for a Sniper Rifle",
options: [
@@ -330,7 +330,7 @@ module.exports = {
required: true,
choices: [
{
- name: "Path.exe",
+ name: "path.exe",
value: "path.exe",
},
],
@@ -362,7 +362,7 @@ module.exports = {
],
},
{
- type: "SUB_COMMAND",
+ type: 1,
name: "light_machine_gun",
description: "Get a gunsmith build for a Light Machine Gun",
options: [
@@ -413,7 +413,7 @@ module.exports = {
required: true,
choices: [
{
- name: "Path.exe",
+ name: "path.exe",
value: "path.exe",
},
],
@@ -445,7 +445,7 @@ module.exports = {
],
},
{
- type: "SUB_COMMAND",
+ type: 1,
name: "shotgun",
description: "Get a gunsmith build for a Shotgun",
options: [
@@ -492,7 +492,7 @@ module.exports = {
required: true,
choices: [
{
- name: "Path.exe",
+ name: "path.exe",
value: "path.exe",
},
{
@@ -520,7 +520,7 @@ module.exports = {
],
},
{
- type: "SUB_COMMAND",
+ type: 1,
name: "marksman_rifle",
description: "Get a gunsmith build for a Marksman Rifle",
options: [
@@ -555,7 +555,7 @@ module.exports = {
required: true,
choices: [
{
- name: "Path.exe",
+ name: "path.exe",
value: "path.exe",
},
{
@@ -587,7 +587,7 @@ module.exports = {
],
},
{
- type: "SUB_COMMAND",
+ type: 1,
name: "pistol",
description: "Get a gunsmith build for a Pistol",
options: [
@@ -630,7 +630,7 @@ module.exports = {
required: true,
choices: [
{
- name: "Path.exe",
+ name: "path.exe",
value: "path.exe",
},
// {
@@ -670,11 +670,10 @@ module.exports = {
.then(res => res.data)
.catch(e => null);
var all = {
- "path.exe": "Path.exe",
+ "path.exe": "path.exe",
dhitman: "dHitman",
jokesta: "Jokesta",
sod: "Stats On Duty",
-
aggressive: "Aggressive",
passive: "Passive",
respawn: "Respawn",
diff --git a/command/CODM/perk.js b/command/CODM/perk.js
@@ -8,7 +8,7 @@ module.exports = {
category: "CODM",
options: [
{
- type: "SUB_COMMAND",
+ type: 1,
name: "red",
description: "Red Perk",
options: [
@@ -67,7 +67,7 @@ module.exports = {
],
},
{
- type: "SUB_COMMAND",
+ type: 1,
name: "green",
description: "Green Perk",
options: [
@@ -122,7 +122,7 @@ module.exports = {
],
},
{
- type: "SUB_COMMAND",
+ type: 1,
name: "blue",
description: "Blue Perk",
options: [
diff --git a/command/CODM/stats.js b/command/CODM/stats.js
@@ -58,20 +58,20 @@ module.exports = {
if (args.length == 1)
repEmb = statsHandler(args.join(" ").replace("\n", " "));
else repEmb = statsHandler(args.join(" + ").replace("\n", " "));
-
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)] });
}
- 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)] });
},
};
diff --git a/events/interactionCreate.js b/events/interactionCreate.js
@@ -12,7 +12,7 @@ client.on("interactionCreate", async interaction => {
if (option.type === "SUB_COMMAND_GROUP") {
if (option.name) args.push(option.name);
option.options?.forEach(x => {
- if (x.type === "SUB_COMMAND") {
+ if (x.type === 1) {
if (x.name) args.push(x.name);
x.options?.forEach(y => {
if (y.value) args.push(y.value);
@@ -23,7 +23,7 @@ client.on("interactionCreate", async interaction => {
if (x.value) args.push(x.value);
});
}
- if (option.type === "SUB_COMMAND") {
+ if (option.type === 1) {
if (option.name) args.push(option.name);
option.options?.forEach(x => {
if (x.value) args.push(x.value);
@@ -183,7 +183,7 @@ client.on("interactionCreate", async interaction => {
if (!ownercmd) return;
const args = [];
for (const option of interaction.options.data) {
- if (option.type === "SUB_COMMAND") {
+ if (option.type === 1) {
if (option.name) args.push(option.name);
option.options?.forEach(x => {
if (x.value) args.push(x.value);
diff --git a/unused/commands/Giveaway/giveaway.js b/unused/commands/Giveaway/giveaway.js
@@ -5,7 +5,7 @@ module.exports = {
UserPerms: ["MANAGE_MESSAGES"],
options: [
{
- type: "SUB_COMMAND",
+ type: 1,
name: "start",
description: "Start a giveaway",
options: [
@@ -53,7 +53,7 @@ module.exports = {
],
},
{
- type: "SUB_COMMAND",
+ type: 1,
name: "reroll",
description: "Reroll a giveaway",
options: [
@@ -67,7 +67,7 @@ module.exports = {
],
},
{
- type: "SUB_COMMAND",
+ type: 1,
name: "end",
description: "End a giveaway",
options: [
diff --git a/util/functions/common.js b/util/functions/common.js
@@ -233,13 +233,17 @@ function attachmentsIdentifier(inpmsg, gun) {
// if probables list doesn't include the attachment, push
let probablePushed = false;
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)) {
probables[i4].push(j);
+ // make it true so that it doesn't push again in the next condition
probablePushed = true;
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]);
}
}
@@ -250,28 +254,35 @@ function attachmentsIdentifier(inpmsg, gun) {
// finding magazines attachments
if (
(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].replace(/\D/g, "")
)
) {
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(
x =>
x.type === 8 && x.effects[27] + x.effects[28] + gun.stats[17] === tmp1
);
+ // push if the magazine is found
if (tmp2.length === 1) {
outAttachments.push(tmp2[0]);
continue;
}
}
+ // if probables is empty or there is more than one identified attachment
if (
probables.length === 0 ||
probables[probables.length - 1].length !== 1 ||
probables.length < splitInputAttachmentsName.length
) {
probables = [];
+ // the splitInputAttachmentsName isn't simplified pls rmb
splitInputAttachmentsName.map((x, i5) =>
+ // finding aliases
nmDt.attachmentAlliasName[1].map((y, i6) =>
y.map(z => {
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("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(
+ "47 + 40 round mag + marksman + stippled + red dot",
+ data.cguns[0]
+ )
+);
+makeError();
function damageHandler(
currDmgs,
currRngs,