From c702554dcbc5c80326c78a6c8c7abbe89c004b36 Mon Sep 17 00:00:00 2001 From: Braeden Sowinski Date: Mon, 21 Aug 2023 18:26:11 -0700 Subject: [PATCH] update/lookup-sub-commands --- commands/lookup-discord.js | 60 ------------------------ commands/lookup-gamertag.js | 52 --------------------- commands/lookup.js | 92 +++++++++++++++++++++++++++++++++++++ package.json | 2 +- 4 files changed, 93 insertions(+), 113 deletions(-) delete mode 100644 commands/lookup-discord.js delete mode 100644 commands/lookup-gamertag.js create mode 100644 commands/lookup.js diff --git a/commands/lookup-discord.js b/commands/lookup-discord.js deleted file mode 100644 index 7bdce1c..0000000 --- a/commands/lookup-discord.js +++ /dev/null @@ -1,60 +0,0 @@ -const { EmbedBuilder } = require('discord.js'); -const bitfieldCalculator = require('discord-bitfield-calculator'); - -module.exports = { - name: "lookup-discord", - debug: false, - global: false, - description: "Search for a users discord from a gamertag", - usage: "[gamertag]", - permissions: { - channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"], - member: [], - }, - options: [{ - name: "gamertag", - description: "Gamertag of player", - value: "gamertag", - type: 3, - required: true, - }], - SlashCommand: { - /** - * - * @param {require("../structures/QuarksBot")} client - * @param {import("discord.js").Message} message - * @param {string[]} args - * @param {*} param3 - */ - run: async (client, interaction, args, { GuildDB }) => { - - if (!client.exists(GuildDB.playerstats)) { - GuildDB.playerstats = [{}]; - client.dbo.collection("guilds").updateOne({ "server.serverID": GuildDB.serverID }, { - $set: { - "server.playerstats": [] - } - }, function (err, res) { - if (err) return client.sendInternalError(interaction, err); - }); - } - - let playerStat = GuildDB.playerstats.find(stat => stat.gamertag == args[0].value ); - if (playerStat == undefined) return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Yellow).setDescription(`**Not Found** This gamertag \` ${args[0].value} \` cannot be found, the gamertag may be incorrect or this player has not logged onto the server before for at least \` 5 minutes \`.`)] }); - - if (client.exists(playerStat.discordID)) { - const found = new EmbedBuilder() - .setColor(client.config.Colors.Yellow) - .setDescription(`**Record Found**\n> The gamertag \` ${playerStat.gamertag} \` is currently linked to <@${playerStat.discordID}>.`) - - return interaction.send({ embeds: [found] }); - } - - let notFound = new EmbedBuilder() - .setColor(client.config.Colors.Default) - .setDescription(`**Record Not Found**\n The gamertag \` ${playerStat.gamertag} \` currently has no linked Discord account.`); - - return interaction.send({ embeds: [notFound] }) - }, - }, -} \ No newline at end of file diff --git a/commands/lookup-gamertag.js b/commands/lookup-gamertag.js deleted file mode 100644 index 32b82a9..0000000 --- a/commands/lookup-gamertag.js +++ /dev/null @@ -1,52 +0,0 @@ -const { EmbedBuilder } = require('discord.js'); -const bitfieldCalculator = require('discord-bitfield-calculator'); - -module.exports = { - name: "lookup-gamertag", - debug: false, - global: false, - description: "Search for a users linked gamertag", - usage: "[user]", - permissions: { - channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"], - member: [], - }, - options: [{ - name: "user", - description: "Discord User", - value: "user", - type: 6, - required: true, - }], - SlashCommand: { - /** - * - * @param {require("../structures/QuarksBot")} client - * @param {import("discord.js").Message} message - * @param {string[]} args - * @param {*} param3 - */ - run: async (client, interaction, args, { GuildDB }) => { - - if (!client.exists(GuildDB.playerstats)) { - GuildDB.playerstats = [{}]; - client.dbo.collection("guilds").updateOne({ "server.serverID": GuildDB.serverID }, { - $set: { - "server.playerstats": [] - } - }, function (err, res) { - if (err) return client.sendInternalError(interaction, err); - }); - } - - let playerStat = GuildDB.playerstats.find(stat => stat.discordID == args[0].value ); - if (playerStat == undefined) return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Yellow).setDescription(`**Not Found** The user <@${args[0].value}> has not linked a gamertag.`)] }); - - const found = new EmbedBuilder() - .setColor(client.config.Colors.Yellow) - .setDescription(`**Record Found**\n> The user <@${playerStat.discordID}> has linked the gamertag \` ${playerStat.gamertag} \`.`) - - return interaction.send({ embeds: [found] }); - }, - }, -} \ No newline at end of file diff --git a/commands/lookup.js b/commands/lookup.js new file mode 100644 index 0000000..0febe81 --- /dev/null +++ b/commands/lookup.js @@ -0,0 +1,92 @@ +const { EmbedBuilder } = require('discord.js'); + +module.exports = { + name: "lookup", + debug: false, + global: false, + description: "Search for a users discord or gamertag", + usage: "[cmd] [param]", + permissions: { + channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"], + member: [], + }, + options: [{ + name: "discord", + description: "Find a Discord user from a Gamertag", + value: "discord", + type: 1, + options: [{ + name: "gamertag", + description: "Gamertag of player", + value: "gamertag", + type: 3, + required: true, + }] + }, { + name: "gamertag", + description: "Find a Gamertag from a Discord user", + value: "gamertag", + type: 1, + options: [{ + name: "user", + description: "Discord User", + value: "user", + type: 6, + required: true, + }] + }], + SlashCommand: { + /** + * + * @param {require("../structures/QuarksBot")} client + * @param {import("discord.js").Message} message + * @param {string[]} args + * @param {*} param3 + */ + run: async (client, interaction, args, { GuildDB }) => { + + if (!client.exists(GuildDB.playerstats)) { + GuildDB.playerstats = [{}]; + client.dbo.collection("guilds").updateOne({ "server.serverID": GuildDB.serverID }, { + $set: { + "server.playerstats": [] + } + }, function (err, res) { + if (err) return client.sendInternalError(interaction, err); + }); + } + + if (args[0].name == 'discord') { + + let playerStat = GuildDB.playerstats.find(stat => stat.gamertag == args[0].options[0].value ); + if (playerStat == undefined) return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Yellow).setDescription(`**Not Found** This gamertag \` ${args[0].options[0].value} \` cannot be found, the gamertag may be incorrect or this player has not logged onto the server before for at least \` 5 minutes \`.`)] }); + + if (client.exists(playerStat.discordID)) { + const found = new EmbedBuilder() + .setColor(client.config.Colors.Yellow) + .setDescription(`**Record Found**\n> The gamertag \` ${playerStat.gamertag} \` is currently linked to <@${playerStat.discordID}>.`) + + return interaction.send({ embeds: [found] }); + } + + let notFound = new EmbedBuilder() + .setColor(client.config.Colors.Default) + .setDescription(`**Record Not Found**\n The gamertag \` ${playerStat.gamertag} \` currently has no linked Discord account.`); + + return interaction.send({ embeds: [notFound] }) + + } else if (args[0].name == 'gamertag') { + + let playerStat = GuildDB.playerstats.find(stat => stat.discordID == args[0].options[0].value ); + if (playerStat == undefined) return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Yellow).setDescription(`**Not Found** The user <@${args[0].options[0].value}> has not linked a gamertag.`)] }); + + const found = new EmbedBuilder() + .setColor(client.config.Colors.Yellow) + .setDescription(`**Record Found**\n> The user <@${playerStat.discordID}> has linked the gamertag \` ${playerStat.gamertag} \`.`) + + return interaction.send({ embeds: [found] }); + + } + }, + }, +} \ No newline at end of file diff --git a/package.json b/package.json index 88a8c74..a460e41 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dayz-armbands", - "version": "8.5.2", + "version": "8.6.0", "description": "A General Purpose Discord Bot for DayZ Servers.", "main": "index.js", "nodemonConfig": {