From e843275ba1efd1ae2a45a7548fe6bbbb806a6ed9 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sun, 29 Sep 2024 12:17:07 -0400 Subject: [PATCH] Fix references to guild names when not needed --- CustomModules/ButtonHandlers.js | 10 +-- slash-commands/gifs.js | 2 +- slash-commands/joints.js | 2 +- slash-commands/pastas.js | 2 +- slash-commands/requests.js | 2 +- slash-commands/save.js | 2 +- slash-commands/view.js | 114 ++++++++++++++++++++++++++++++++ 7 files changed, 124 insertions(+), 10 deletions(-) create mode 100644 slash-commands/view.js diff --git a/CustomModules/ButtonHandlers.js b/CustomModules/ButtonHandlers.js index 610bbf0..81aa980 100644 --- a/CustomModules/ButtonHandlers.js +++ b/CustomModules/ButtonHandlers.js @@ -81,7 +81,7 @@ module.exports = { indexedGifs.gifsString += `[${gif.name}.gif](${gif.url})\n`; } - interaction.update(fn.embeds.gifs({command: "/gifs", author: interaction.member.displayName}, indexedGifs)); + interaction.update(fn.embeds.gifs({command: "/gifs", author: interaction.user.username}, indexedGifs)); }, pastasPage(interaction) { const iStorage = interaction.client.iStorage.get(interaction.message.interaction.id); @@ -107,7 +107,7 @@ module.exports = { indexedPastas.pastasString += `${pasta.name}.pasta\n`; } - interaction.update(fn.embeds.pastas({command: "/pastas", author: interaction.member.displayName}, indexedPastas)); + interaction.update(fn.embeds.pastas({command: "/pastas", author: interaction.user.username}, indexedPastas)); }, requestsPage(interaction) { const iStorage = interaction.client.iStorage.get(interaction.message.interaction.id); @@ -133,7 +133,7 @@ module.exports = { indexedRequests.requestsString += `[${request.id}]: ${request.request} (submitted by ${request.author})\n`; } - interaction.update(fn.embeds.requests({command: "/requests", author: interaction.member.displayName}, indexedRequests)); + interaction.update(fn.embeds.requests({command: "/requests", author: interaction.user.username}, indexedRequests)); }, jointsPage(interaction) { const iStorage = interaction.client.iStorage.get(interaction.message.interaction.id); @@ -159,7 +159,7 @@ module.exports = { indexedJoints.jointsString += `${joint.content}\n`; } - interaction.update(fn.embeds.joints({command: "/joints", author: interaction.member.displayName}, indexedJoints)); + interaction.update(fn.embeds.joints({command: "/joints", author: interaction.user.username}, indexedJoints)); }, gifSearchPage(interaction) { const iStorage = interaction.client.iStorage.get(interaction.message.interaction.id); @@ -197,7 +197,7 @@ module.exports = { indexedGifs.query = iStorage.query; indexedGifs.gifName = iStorage.gifName; // Generate the embed - const gifEmbed = customEmbeds.core.gifSearch({ author: interaction.member.displayName }, indexedGifs); + const gifEmbed = customEmbeds.core.gifSearch({ author: interaction.user.username }, indexedGifs); // Update the interaction interaction.update({ embeds: [gifEmbed], components: [gifSearchAR], ephemeral: true }); } diff --git a/slash-commands/gifs.js b/slash-commands/gifs.js index c372cc0..d44847e 100644 --- a/slash-commands/gifs.js +++ b/slash-commands/gifs.js @@ -23,7 +23,7 @@ module.exports = { } const commandData = { command: "/gifs", - author: interaction.member.displayName + author: interaction.user.username }; interaction.reply(fn.embeds.gifs(commandData, indexedGifs)); } diff --git a/slash-commands/joints.js b/slash-commands/joints.js index bca4490..8bcb435 100644 --- a/slash-commands/joints.js +++ b/slash-commands/joints.js @@ -22,7 +22,7 @@ module.exports = { } const commandData = { command: "/joints", - author: interaction.member.displayName + author: interaction.user.username }; interaction.reply(fn.embeds.joints(commandData, indexedJoints)); }, diff --git a/slash-commands/pastas.js b/slash-commands/pastas.js index 8d43578..5a5c6f4 100644 --- a/slash-commands/pastas.js +++ b/slash-commands/pastas.js @@ -23,7 +23,7 @@ module.exports = { } const commandData = { command: "/pastas", - author: interaction.member.displayName + author: interaction.user.username }; interaction.reply(fn.embeds.pastas(commandData, indexedPastas)); }, diff --git a/slash-commands/requests.js b/slash-commands/requests.js index fbc8b3b..18ec28b 100644 --- a/slash-commands/requests.js +++ b/slash-commands/requests.js @@ -24,7 +24,7 @@ module.exports = { const commandData = { command: "/requests", - author: interaction.member.displayName + author: interaction.user.username }; interaction.reply(fn.embeds.requests(commandData, indexedRequests)); }, diff --git a/slash-commands/save.js b/slash-commands/save.js index fdc990b..a4f8cae 100644 --- a/slash-commands/save.js +++ b/slash-commands/save.js @@ -179,7 +179,7 @@ module.exports = { gifPage.query = query; gifPage.gifName = gifName; // Generate the embed - const gifEmbed = Embeds.core.gifSearch({ author: interaction.member.displayName }, gifPage); + const gifEmbed = Embeds.core.gifSearch({ author: interaction.user.username }, gifPage); interaction.editReply({ embeds: [gifEmbed], components: [actionRow], ephemeral: true }); }); break; diff --git a/slash-commands/view.js b/slash-commands/view.js new file mode 100644 index 0000000..f31c2b4 --- /dev/null +++ b/slash-commands/view.js @@ -0,0 +1,114 @@ +const tenor = require('tenorjs').client({ + 'Key': process.env.tenorAPIKey, // https://tenor.com/developer/keyregistration + 'Filter': 'off', // "off", "low", "medium", "high", not case sensitive + 'Locale': 'en_US', + 'MediaFilter': 'minimal', + 'DateFormat': 'D/MM/YYYY - H:mm:ss A', +}); + +const { SlashCommandBuilder } = require('@discordjs/builders'); +const { Collection } = require('discord.js'); +const fn = require('../functions.js'); +const strings = require('../strings.json'); +const { GifData } = require('../CustomModules/NodBot.js'); +const customEmbeds = require('../CustomModules/Embeds.js'); +const Indexer = require('../CustomModules/Indexer.js'); +const Embeds = require('../CustomModules/Embeds.js'); +const { emoji } = strings; + +module.exports = { + data: new SlashCommandBuilder() + .setName('view') + .setDescription('View content saved in Nodbot\'s database.') +// GIFs + .addSubcommand(subcommand => + subcommand + .setName('gifs') + .setDescription('Display all saved GIFs.') + ) +// Joints + .addSubcommand(subcommand => + subcommand + .setName('joints') + .setDescription('Display all saved joints.') + ) +// Pastas + .addSubcommand(subcommand => + subcommand + .setName('pastas') + .setDescription('Display all saved copypastas.') + ) +// Requests + .addSubcommand(subcommand => + subcommand + .setName('requests') + .setDescription('Display all saved requests.') + ), + async execute(interaction) { + await interaction.deferReply({ ephemeral: true }); + try { + // Code Here... + const subcommand = interaction.options.getSubcommand(); + const iStorage = interaction.client.iStorage.get(interaction.id); + let commandData = { + author: interaction.user.username + } + switch (subcommand) { +// GIFs + case "gifs": + if (!interaction.client.gifs) { + interaction.reply('For some reason I don\'t have access to the collection of gifs. Sorry about that!'); + return; + } + let indexedGifs = Indexer(interaction.client.gifs, 0); + indexedGifs.gifsString = new String(); + + iStorage.page = 0; + + for (const gif of indexedGifs.thisPage) { + indexedGifs.gifsString += `[${gif.name}.gif](${gif.url})\n`; + } + const commandData = { + command: "/gifs", + author: interaction.user.username + }; + interaction.reply(fn.embeds.gifs(commandData, indexedGifs)); + break; +// Joints + case "joints": + if (!interaction.client.joints) { + interaction.reply('For some reason I don\'t have access to the collection of joints. Sorry about that!'); + return; + } + let iStorage = interaction.client.iStorage.get(interaction.id); + let indexedJoints = indexer(interaction.client.joints, 0); + indexedJoints.jointsString = new String(); + + iStorage.page = 0; + + for (const joint of indexedJoints.thisPage) { + indexedJoints.jointsString += `${joint.content}\n`; + } + const commandData = { + command: "/joints", + author: interaction.user.username + }; + interaction.reply(fn.embeds.joints(commandData, indexedJoints)); + break; +// Pastas + case "pastas": + break; +// Requests + case "requests": + break; +// Default + default: + break; + } + } catch (err) { + const errorId = fn.generateErrorId(); + console.error(`${errorId}: err`); + await interaction.editReply(`Sorry, an error has occured. Error ID: ${errorId}`); + } + } +}; \ No newline at end of file