From e4450c8417624b71d779cb4f41692538f9165e10 Mon Sep 17 00:00:00 2001
From: sowgro <tpoke.ferrari@gmail.com>
Date: Sat, 2 Sep 2023 19:12:47 -0400
Subject: first commit

---
 .../structures/ContextMenuCommandInteraction.js    | 64 ++++++++++++++++++++++
 1 file changed, 64 insertions(+)
 create mode 100644 node_modules/discord.js/src/structures/ContextMenuCommandInteraction.js

(limited to 'node_modules/discord.js/src/structures/ContextMenuCommandInteraction.js')

diff --git a/node_modules/discord.js/src/structures/ContextMenuCommandInteraction.js b/node_modules/discord.js/src/structures/ContextMenuCommandInteraction.js
new file mode 100644
index 0000000..fc49ca5
--- /dev/null
+++ b/node_modules/discord.js/src/structures/ContextMenuCommandInteraction.js
@@ -0,0 +1,64 @@
+'use strict';
+
+const { lazy } = require('@discordjs/util');
+const { ApplicationCommandOptionType } = require('discord-api-types/v10');
+const CommandInteraction = require('./CommandInteraction');
+const CommandInteractionOptionResolver = require('./CommandInteractionOptionResolver');
+
+const getMessage = lazy(() => require('./Message').Message);
+
+/**
+ * Represents a context menu interaction.
+ * @extends {CommandInteraction}
+ */
+class ContextMenuCommandInteraction extends CommandInteraction {
+  constructor(client, data) {
+    super(client, data);
+    /**
+     * The target of the interaction, parsed into options
+     * @type {CommandInteractionOptionResolver}
+     */
+    this.options = new CommandInteractionOptionResolver(
+      this.client,
+      this.resolveContextMenuOptions(data.data),
+      this.transformResolved(data.data.resolved),
+    );
+
+    /**
+     * The id of the target of this interaction
+     * @type {Snowflake}
+     */
+    this.targetId = data.data.target_id;
+  }
+
+  /**
+   * Resolves and transforms options received from the API for a context menu interaction.
+   * @param {APIApplicationCommandInteractionData} data The interaction data
+   * @returns {CommandInteractionOption[]}
+   * @private
+   */
+  resolveContextMenuOptions({ target_id, resolved }) {
+    const result = [];
+
+    if (resolved.users?.[target_id]) {
+      result.push(
+        this.transformOption({ name: 'user', type: ApplicationCommandOptionType.User, value: target_id }, resolved),
+      );
+    }
+
+    if (resolved.messages?.[target_id]) {
+      result.push({
+        name: 'message',
+        type: '_MESSAGE',
+        value: target_id,
+        message:
+          this.channel?.messages._add(resolved.messages[target_id]) ??
+          new (getMessage())(this.client, resolved.messages[target_id]),
+      });
+    }
+
+    return result;
+  }
+}
+
+module.exports = ContextMenuCommandInteraction;
-- 
cgit v1.2.3