nyx

The first CODM discrod bot -- cath.exe Template
git clone https://codeberg.org/night0721/nyx
Log | Files | Refs | LICENSE

commit bc98d548fad7af65b09a205ac8df48e60338c295
parent 2145e9cf317da691185e400fb2d0f7f5971b866d
Author: Night Kaly <[email protected]>
Date:   Fri, 28 Jan 2022 20:22:29 +0000

Merge. DONT PULL before poll command done


Diffstat:
Mcommand/CODM/build.js | 297+++++++++++++++++++++++++------------------------------------------------------
Mcommand/CODM/stats.js | 2+-
Acommand/Utilities/poll.js | 119+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mutil/Data/aliases.json | 8+++++---
Mutil/Data/attachments.json | 58++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 277 insertions(+), 207 deletions(-)

diff --git a/command/CODM/build.js b/command/CODM/build.js @@ -1,6 +1,6 @@ const { MessageEmbed } = require("discord.js"); -const axios = require("axios"); const moment = require("moment"); +const axios = require("axios"); module.exports = { name: "build", description: "Get gunsmith builds", @@ -19,89 +19,89 @@ module.exports = { required: true, choices: [ { - name: "AK117", - value: "ak117", + name: "Type 25", + value: "A01", }, { name: "M16", - value: "m16", + value: "A02", }, { - name: "Type 25", - value: "type25", + name: "AK117", + value: "A03", }, { name: "AK-47", - value: "ak47", + value: "A04", }, { name: "ASM10", - value: "asm10", + value: "A05", }, { name: "M4", - value: "m4", + value: "A06", }, { name: "BK57", - value: "bk57", + value: "A07", }, { name: "LK24", - value: "lk24", + value: "A08", }, { - name: "Man-o-War", - value: "manowar", + name: "ICR-1", + value: "A09", }, { - name: "ICR-1", - value: "icr1", + name: "Man-o-War", + value: "A10", }, { name: "KN-44", - value: "kn44", + value: "A11", }, { name: "HBRa3", - value: "hbra3", + value: "A12", }, { name: "HVK-30", - value: "hvk30", + value: "A13", }, { name: "DR-H", - value: "drh", + value: "A14", }, { name: "Peacekeeper MK2", - value: "peacekeepermk2", + value: "A15", }, { name: "FR .556", - value: "fr556", + value: "A16", }, { name: "AS VAL", - value: "asval", + value: "A17", }, { name: "CR-56 AMAX", - value: "cr56amax", + value: "A18", }, { name: "M13", - value: "m13", + value: "A19", }, { name: "Swordfish", - value: "swordfish", + value: "A20", + }, + { + name: "Kilo 141", + value: "A21", }, - // { - // name: "Kilo 141", - // value: "kilo", - // }, ], }, { @@ -163,71 +163,71 @@ module.exports = { choices: [ { name: "RUS-79u", - value: "rus79u", + value: "D01", + }, + { + name: "Chicom", + value: "D02", }, { name: "PDW-57", - value: "pdw57", + value: "D03", }, { name: "Razorback", - value: "razorback", + value: "D04", }, { name: "MSMC", - value: "msmc", + value: "D05", }, { name: "HG40", - value: "hg40", + value: "D06", }, { name: "Pharo", - value: "pharo", + value: "D07", }, { name: "GKS", - value: "gks", + value: "D08", }, { name: "Cordite", - value: "cordite", + value: "D09", }, { name: "QQ9", - value: "qq9", + value: "D10", }, { name: "Fennec", - value: "fennec", - }, - { - name: "Chicom", - value: "chicom", + value: "D11", }, { name: "AGR 556", - value: "agr556", + value: "D12", }, { name: "QXR", - value: "qxr", + value: "D13", }, { name: "PP19 Bizon", - value: "pp19bizon", + value: "D14", }, { name: "MX9", - value: "mx9", + value: "D15", }, { name: "CBR4", - value: "cbr4", + value: "D16", }, { name: "PPSh 41", - value: "ppsh", + value: "D17", }, ], }, @@ -284,41 +284,41 @@ module.exports = { description: "Name of the Gun", required: true, choices: [ + // { + // name: "XPR-50", + // value: "B01", + // }, { name: "Arctic .50", - value: "arctic50", + value: "B02", }, { name: "M21 EBR", - value: "m21ebr", + value: "B03", }, { name: "DL Q33", - value: "dlq33", + value: "B04", }, { name: "Locus", - value: "locus", + value: "B05", }, // { - // name: "XPR-50", - // value: "xpr50", - // }, - // { // name: "NA-45", - // value: "na45", + // value: "B06", // }, { name: "Outlaw", - value: "outlaw", + value: "B07", }, { name: "Rytec AMR", - value: "rytecamr", + value: "B08", }, { name: "SVD", - value: "svd", + value: "B09", }, ], }, @@ -332,10 +332,6 @@ module.exports = { name: "Path.exe", value: "path", }, - // { - // name: "little_b", - // value: "littleb", - // }, ], }, { @@ -377,35 +373,35 @@ module.exports = { choices: [ { name: "S36", - value: "s36", + value: "C01", }, { name: "UL736", - value: "ul736", + value: "C02", }, { name: "RPD", - value: "rpd", + value: "C03", }, { name: "M4 LMG", - value: "m4lmg", + value: "C04", }, { name: "Chopper", - value: "chopper", + value: "C05", }, { name: "Holger 26", - value: "holger26", + value: "C06", }, { name: "Hades", - value: "hades", + value: "C07", }, { name: "PKM", - value: "pkm", + value: "C08", }, ], }, @@ -460,31 +456,31 @@ module.exports = { choices: [ { name: "HS2126", - value: "hs2126", + value: "E01", }, { name: "BY15", - value: "by15", + value: "E02", + }, + { + name: "HS0405", + value: "E03", }, { name: "Striker", - value: "striker", + value: "E04", }, { name: "KRM_262", - value: "krm262", + value: "E05", }, { name: "Echo", - value: "echo", - }, - { - name: "HS0405", - value: "hs0405", + value: "E06", }, { name: "R9-0", - value: "r90", + value: "E07", }, ], }, @@ -535,19 +531,19 @@ module.exports = { choices: [ { name: "Kilo Bolt-Action", - value: "kiloboltaction", + value: "F01", }, { name: "SKS", - value: "sks", + value: "F02", }, { name: "SP-R 208", - value: "spr208", + value: "F03", }, { name: "MK2", - value: "mk2", + value: "F04", }, ], }, @@ -561,10 +557,6 @@ module.exports = { name: "Path.exe", value: "path", }, - // { - // name: "Little_b", - // value: "littleb", - // }, ], }, { @@ -602,27 +594,27 @@ module.exports = { choices: [ { name: "J358", - value: "j358", + value: "G01", }, { name: "MW11", - value: "mw11", + value: "G02", }, { name: ".50 GS", - value: "gs50", + value: "G03", }, { name: "Renetti", - value: "renetti", + value: "G04", }, { name: "Shorty", - value: "shorty", + value: "G05", }, { name: "Crossbow", - value: "crossbow", + value: "G06", }, ], }, @@ -654,114 +646,12 @@ module.exports = { }, ], run: async (client, interaction, args) => { - const allguns = { - ak117: "AK117", - m16: "M16", - type25: "Type 25", - ak47: "AK-47", - asm10: "ASM10", - m4: "M4", - bk57: "BK57", - lk24: "LK24", - manowar: "Man-O-War", - icr1: "ICR-1", - kn44: "KN-44", - hbra3: "HBRa3", - hvk30: "HVK-30", - drh: "DR-H", - peacekeepermk2: "Peacekeeper MK2", - fr556: "FR .556", - asval: "AS VAL", - cr56amax: "CR-56 AMAX", - m13: "M13", - swordfish: "Swordfish", - // kilo: "Kilo 141", - - j358: "J358", - gs50: ".50 GS", - mw11: "MW11", - renetti: "Renetti", - shorty: "Shorty", - crossbow: "Crossbow", - - kiloboltaction: "Kilo Bolt-Action", - sks: "SKS", - spr208: "SP-R 208", - mk2: "MK2", - - s36: "S36", - ul736: "UL736", - rpd: "RPD", - m4lmg: "M4LMG", - chopper: "Chopper", - holger26: "Holger 26", - hades: "Hades", - pkm: "PKM", - - arctic50: "Arctic .50", - m21ebr: "M21 EBR", - dlq33: "DL Q33", - locus: "Locus", - // na45: "NA 45", - // xpr50: "XPR-50", - locus: "Locus", - outlaw: "Outlaw", - rytecamr: "Rytec AMR", - svd: "SVD", - - hs2126: "HS2126", - by15: "BY15", - striker: "Striker", - krm262: "KRM 262", - echo: "Echo", - hs0405: "HS0405", - r90: "R9-0", - - rus79u: "RUS-79U", - hg40: "HG-40", - pdw57: "PDW-57", - chicom: "Chicom", - razorback: "Razorback", - msmc: "MSMC", - pharo: "Pharo", - gks: "GKS", - cordite: "Cordite", - qq9: "QQ9", - fennec: "Fennec", - agr556: "AGR 556", - qxr: "QXR", - pp19bizon: "PP19 Bizon", - mx9: "MX9", - cbr4: "CBR4", - ppsh: "PPSh-41", - }; - const all = { - assault_rifle: "Assault Rifle", - sniper_rifle: "Sniper Rifle", - marksman_rifle: "Marksman Rifle", - shotgun: "Shotgun", - light_machine_gun: "Light Machine Gun", - sub_machine_gun: "Sub Machine Gun", - - path: "Path.exe", - dhitman: "dHitman", - jokesta: "Jokesta", - sod: "Stats On Duty", - // littleb:"Little B", - - aggressive: "Aggressive", - passive: "Passive", - snd: "Search And Destroy", - respawn: "Respawn", - ads: "ADS", - hipfire: "Hipfire", - }; - const gun = args[1]; + const cwts = args[1]; const cc = args[2]; const tag = args[3]; const data = await axios .get( - `${process.env.api}/api/v1/codm/builds?name=${gun}&cc=${cc}&tag=${tag}`, + `${process.env.api}/api/v1/codm/builds?cwts=${cwts}&cc=${cc}&tag=${tag}`, { headers: { Authorization: process.env.CODM_API_KEY, @@ -770,6 +660,7 @@ module.exports = { ) .then(res => res.data) .catch(e => null); + if (!data?.ID) { const embed = new MessageEmbed() .setDescription( @@ -784,10 +675,10 @@ module.exports = { }); const embed = new MessageEmbed() .setTitle( - `${data.weaponName}(${data.weaponType})'s ${all[tag]} build from ${data.author}` + `${all[tag]} build for ${data.weaponName} from ${data.author}` ) .setDescription( - `<:nyx_description:897379659665264650> **Description** \`\`\`\n ${data.notes}\n\`\`\`` + `<:nyx_description:897379659665264650> **Description** \`\`\` \n${data.notes} \n\`\`\`` ) .setColor(16580400) .setImage(data.imageUrl) diff --git a/command/CODM/stats.js b/command/CODM/stats.js @@ -299,7 +299,7 @@ function statsHandler(inpmsg) { footer: { text: "[OUTDATED] All data courtesy of Project Lighthouse 2.0 and CoDM Research Crew", icon_url: - "https://media.discordapp.net/attachments/735590814662656102/806960573753327657/cc.png?width=638&height=638", + "https://media.discordapp.net/attachments/735590814662656102/806960573753327657/cc.png", }, }; } diff --git a/command/Utilities/poll.js b/command/Utilities/poll.js @@ -0,0 +1,119 @@ +const { Client, CommandInteraction, MessageEmbed } = require('discord.js'); + +module.exports = { + name: 'poll', + category: "SUB_COMMAND", + description: 'Creates a poll with many options', + options: [ + { + name: 'create', + description: 'Creates An Interactive Poll', + type: 'SUB_COMMAND', + options: [ + { + name: 'question', + description: 'The question of the poll', + type: 'STRING', + required: true, + }, + { + name: 'choice1', + description: 'Choice 1', + type: 'STRING', + required: true, + }, + { + name: 'choice2', + description: 'Choice 2', + type: 'STRING', + required: true, + }, + { + name: 'choice3', + description: 'Choice 3', + type: 'STRING', + required: false, + }, + { + name: 'choice4', + description: 'Choice 4', + type: 'STRING', + required: false, + }, + { + name: 'choice5', + description: 'Choice 5', + type: 'STRING', + required: false, + }, + { + name: 'choice6', + description: 'Choice 6', + type: 'STRING', + required: false, + }, + ], + }, + ], + /** + * @param {Client} client + * @param {CommandInteraction} interaction + * @param {String[]} args + */ + run: async(client, interaction, args) => { + if (interaction.options.getSubcommand() == 'create') { + const title = interaction.options.getString('question') + const c1 = interaction.options.getString('choice1'); + const c2 = interaction.options.getString('choice2'); + const c3 = interaction.options.getString('choice3'); + const c4 = interaction.options.getString('choice4'); + const c5 = interaction.options.getString('choice5'); + const c6 = interaction.options.getString('choice6'); + const pollCreateEmbed = new MessageEmbed() + .setTitle(`${title}`) + .setColor("RED") + .addFields( + { name: "⠀", value: `🇦 ${c1}`}, + { name: "⠀", value: `🇧 ${c2}`} + ) + .setFooter(`Poll By ${interaction.user.tag}`) + .setTimestamp(); + + + if (interaction.options.getString('choice3')) { + pollCreateEmbed.addFields({ name: "⠀", value: `🇨 ${c3}`}); + } + if (interaction.options.getString('choice4')) { + pollCreateEmbed.addFields({ name: "⠀", value: `🇩 ${c4}`}); + } + if (interaction.options.getString('choice5')) { + pollCreateEmbed.addFields({ name: "⠀", value: `🇪 ${c5}`}); + } + if (interaction.options.getString('choice6')) { + pollCreateEmbed.addFields({ name: "⠀", value: `🇫 ${c6}`}); + } + + embedMessage = await interaction.followUp({ + embeds: [pollCreateEmbed], + //fetchReply: true, + }); + embedMessage.react('🇦'); + embedMessage.react('🇧'); + + if (interaction.options.getString('choice3')) { + embedMessage.react('🇨'); + } + if (interaction.options.getString('choice4')) { + embedMessage.react('🇩'); + } + if (interaction.options.getString('choice5')) { + embedMessage.react('🇪'); + } + if (interaction.options.getString('choice6')) { + embedMessage.react('🇫'); + } + } else { + return; + } + }, +}; diff --git a/util/Data/aliases.json b/util/Data/aliases.json @@ -26,7 +26,8 @@ "CR-56 AMAX", "Shorty", "Crossbow", - "R9-0" + "R9-0", + "PPSh-41" ], "weaponAlliasName": [ ["MoW"], @@ -48,14 +49,15 @@ ["Slow Outlaw", "Slower Outlaw"], ["bae"], ["Reneti", "Renneti", "Rennetti", "Burst Pistol"], - ["pp bizon", "pp"], + ["pp bizon", "pp19"], ["AUG"], ["AKBP", "Vepr"], ["AN94"], ["CR56", "AMAX"], ["725"], ["cb", "bow"], - ["r9", "R9-O"] + ["r9", "R9-O"], + ["ppsh", "pp41"] ], "attachmentActualName": [ ["akimbo", "Stopping Power"], diff --git a/util/Data/attachments.json b/util/Data/attachments.json @@ -1043,6 +1043,64 @@ ] } ], + "Kilo_141": [ + { + "muzzle": [ + "Tactical Suppressor", + "OWC Light Suppressor", + "OWC Light Compensator", + "Monolithic Suppressor", + "MIP Light FLash Guard", + "RTC Light Muzzle Brake" + ], + "barrel": [ + "RTC Silencer Barrel", + "MIP Light Extended Barrel", + "OWC Marksman" + ], + "optic": [ + "Red Dot Sight", + "Holographic Sight", + "3x Tactical Scope", + "4x Tactical Scope", + "4.4x Tactical Scope" + ], + "stock": [ + "No Stock", + "YKM Combat Stock", + "OWC Skeleton Stock", + "RTC Steady Stock" + ], + "perk": [ + "FMJ", + "Sleight of Hand", + "Wounding", + "Full Ammo", + "Disable", + "Tough", + "Long Shot", + "Melee Master" + ], + "laser": ["RTC Laser 1mW", "MIP Laser 5mW", "OWC Laser - Tactical"], + "underbarrel": [ + "Strike Foregrip", + "Merc Foregrip", + "Operator Foregrip", + "Ranger Foregrip", + "Tactical Foregrip A" + ], + "ammo": [ + "Extended Mag A", + "Large Extended Mag B", + "100 round LMG Drum Mag" + ], + "rear_grip": [ + "Granulated Grip Tape", + "Ruberized Grip Tape", + "Stippled Grip Tape" + ] + } + ], "XPR_50": [ { "muzzle": [