From b9ba5a8e9173b4ddd63ad55c3d328fa8d70f3f60 Mon Sep 17 00:00:00 2001 From: jmhayes3 <22490346+jmhayes3@users.noreply.github.com> Date: Fri, 23 Aug 2024 02:49:23 -0500 Subject: [PATCH] add upload command --- commands/core/upload.js | 19 +++++++++++++++++++ development.md | 11 ----------- package.json | 2 +- 3 files changed, 20 insertions(+), 12 deletions(-) create mode 100644 commands/core/upload.js delete mode 100644 development.md diff --git a/commands/core/upload.js b/commands/core/upload.js new file mode 100644 index 0000000..aa2b4a6 --- /dev/null +++ b/commands/core/upload.js @@ -0,0 +1,19 @@ +const { readFile } = require('fs/promises'); +const { SlashCommandBuilder, AttachmentBuilder } = require('discord.js'); + +module.exports = { + data: new SlashCommandBuilder() + .setName('upload') + .setDescription('Upload a file.'), + async execute(interaction) { + await interaction.deferReply(); + + const image_file = await readFile('./data/image.jpg'); + const image_name = "data/image.jpg"; + const attachment = new AttachmentBuilder(image_file, { name: image_name }); + console.log("Attachment:", attachment); + + const response = "File uploaded."; + await interaction.followUp({ content: response }); + }, +}; diff --git a/development.md b/development.md deleted file mode 100644 index fb14abc..0000000 --- a/development.md +++ /dev/null @@ -1,11 +0,0 @@ -# Development - -## Bot Commands - -For fully functional slash commands, there are three important pieces of code that need to be written. They are: - -1. The individual command files, containing their definitions and functionality. -2. The command handler, which dynamically reads the files and executes the commands. -3. The command deployment script, to register your slash commands with Discord so they appear in the interface. - -These steps can be done in any order, but all are required before the commands are fully functional. diff --git a/package.json b/package.json index 2f4ba80..576e1c6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "binksjs", "version": "0.1.0", - "main": "main.js", + "main": "index.js", "scripts": { "test": "npm run lint", "lint": "npx eslint ."