diff --git a/_clear-commands.js b/_clear-commands.js deleted file mode 100644 index 869c90d..0000000 --- a/_clear-commands.js +++ /dev/null @@ -1,27 +0,0 @@ -// dotenv for handling environment variables -const dotenv = require('dotenv'); -dotenv.config(); - -const { REST } = require('@discordjs/rest'); -const { Routes } = require('discord-api-types/v9'); -const clientId = process.env.clientId; -const { guildId } = require('../config.json'); -const token = process.env.TOKEN; - -const rest = new REST({ version: '9' }).setToken(token); - -(async () => { - try { - console.log('Started refreshing application (/) commands.'); - - await rest.put( - Routes.applicationGuildCommands(clientId, guildId), - { body: '' }, - ); - - console.log('Successfully reloaded application (/) commands.'); - process.exit(); - } catch (error) { - console.error(error); - } -})(); \ No newline at end of file diff --git a/_deploy-commands.js b/_deploy-commands.js deleted file mode 100644 index 5ba21ce..0000000 --- a/_deploy-commands.js +++ /dev/null @@ -1,40 +0,0 @@ -// dotenv for handling environment variables -const dotenv = require('dotenv'); -dotenv.config(); - -const { REST } = require('@discordjs/rest'); -const { Routes } = require('discord-api-types/v9'); -const { guildId } = require('./config.json'); -const clientId = process.env.clientId; -const token = process.env.TOKEN; -const fs = require('fs'); - -const commands = []; -const commandFiles = fs.readdirSync('./slash-commands').filter(file => file.endsWith('.js')); - -for (const file of commandFiles) { - const command = require(`./slash-commands/${file}`); - if (command.data != undefined) { - commands.push(command.data.toJSON()); - } -} - -console.log(commands); - -const rest = new REST({ version: '9' }).setToken(token); - -(async () => { - try { - console.log('Started refreshing application (/) commands.'); - - await rest.put( - Routes.applicationGuildCommands(clientId, guildId), - { body: commands }, - ); - - console.log('Successfully reloaded application (/) commands.'); - process.exit(); - } catch (error) { - console.error(error); - } -})(); \ No newline at end of file diff --git a/_deploy-global.js b/_deploy-global.js deleted file mode 100644 index cd7b8ce..0000000 --- a/_deploy-global.js +++ /dev/null @@ -1,39 +0,0 @@ -// dotenv for handling environment variables -const dotenv = require('dotenv'); -dotenv.config(); - -const { REST } = require('@discordjs/rest'); -const { Routes } = require('discord-api-types/v9'); -const clientId = process.env.clientId; -const token = process.env.TOKEN; -const fs = require('fs'); - -const commands = []; -const commandFiles = fs.readdirSync('./slash-commands').filter(file => file.endsWith('.js')); - -for (const file of commandFiles) { - const command = require(`./slash-commands/${file}`); - if (command.data != undefined) { - commands.push(command.data.toJSON()); - } -} - -console.log(commands); - -const rest = new REST({ version: '9' }).setToken(token); - -(async () => { - try { - console.log('Started refreshing application (/) commands.'); - - await rest.put( - Routes.applicationCommands(clientId), - { body: commands }, - ); - - console.log('Successfully reloaded application (/) commands.'); - process.exit(); - } catch (error) { - console.error(error); - } -})(); \ No newline at end of file diff --git a/functions.js b/functions.js index fad81b8..9cdcd27 100644 --- a/functions.js +++ b/functions.js @@ -27,7 +27,6 @@ const axios = require('axios'); // Various imports from other files const config = require('./config.json'); const strings = require('./strings.json'); -const slashCommandFiles = fs.readdirSync('./slash-commands/').filter(file => file.endsWith('.js')); const dotCommandFiles = fs.readdirSync('./dot-commands/').filter(file => file.endsWith('.js')); const customEmbeds = require('./CustomModules/Embeds.js'); diff --git a/main.js b/main.js index 1e49d7f..3749e28 100644 --- a/main.js +++ b/main.js @@ -24,8 +24,6 @@ const { GifData, CommandData } = require('./CustomModules/NodBot.js'); const isDev = process.env.IS_DEV; client.once('ready', async () => { - fn.collections.interactionStorage(client); - fn.collections.slashCommands(client); fn.collections.dotCommands(client); fn.collections.setvalidCommands(client); fn.collections.roaches(client); @@ -44,181 +42,6 @@ client.once('ready', async () => { }); }); -// slash-commands -client.on('interactionCreate', async interaction => { - if (interaction.isCommand()) { - if (isDev) { - console.log('Interaction ID: ' + interaction.id); - } - const { commandName } = interaction; - - if (!client.iStorage.has(interaction.id)) { - new InteractionStorage(interaction.id, interaction); - } - - if (client.slashCommands.has(commandName)) { - client.slashCommands.get(commandName).execute(interaction); - } else { - interaction.reply('Sorry, I don\'t have access to that command.'); - console.error('Slash command attempted to run but not found: ' + commandName); - } - } - - if (interaction.isButton()) { - if (isDev) console.log('Origin Interaction ID: ' + interaction.message.interaction.id); - if (isDev) console.log('Button ID: ' + interaction.component.customId); - // Get some meta info from strings - const index = strings.temp.gifIndex; - const limit = strings.temp.gifLimit; - let newIndex; - const buttonId = interaction.component.customId; - switch (buttonId) { - case 'prevGif': - newIndex = index - 1; - strings.temp.gifIndex = newIndex; - // If we're leaving the last GIF, enable the Next GIF button - if (index == limit) { - // Re-Send Previous GIF button - const prevButton = new MessageButton().setCustomId('prevGif').setLabel('Previous GIF').setStyle('SECONDARY'); - // Re-Send Confirm GIF Button - const confirmButton = new MessageButton().setCustomId('confirmGif').setLabel('Confirm').setStyle('PRIMARY'); - // Enable Next GIF Button - const nextButton = new MessageButton().setCustomId('nextGif').setLabel('Next GIF').setStyle('SECONDARY'); - // Re-Send Cancel Button - const cancelButton = new MessageButton().setCustomId('cancelGif').setLabel('Cancel').setStyle('DANGER'); - // Put all the above into an ActionRow to be sent as a component of the reply - const row = new MessageActionRow().addComponents(prevButton, confirmButton, nextButton, cancelButton); - - interaction.update({ content: strings.temp.gifs[newIndex].embed_url, components: [row] }); - break; - } - // If we're going into the first GIF, disable the Previous GIF button - if (newIndex == 0) { - // Disable Previous GIF button - const prevButton = new MessageButton().setCustomId('prevGif').setLabel('Previous GIF').setStyle('SECONDARY').setDisabled(); - // Re-Send Confirm GIF Button - const confirmButton = new MessageButton().setCustomId('confirmGif').setLabel('Confirm').setStyle('PRIMARY'); - // Re-Send Next GIF Button - const nextButton = new MessageButton().setCustomId('nextGif').setLabel('Next GIF').setStyle('SECONDARY'); - // Re-Send Cancel Button - const cancelButton = new MessageButton().setCustomId('cancelGif').setLabel('Canceled').setStyle('DANGER'); - // Put all the above into an ActionRow to be sent as a component of the reply - const row = new MessageActionRow().addComponents(prevButton, confirmButton, nextButton, cancelButton); - - interaction.update({ content: strings.temp.gifs[newIndex].embed_url, components: [row] }); - break; - } - - interaction.update(strings.temp.gifs[newIndex].embed_url); - break; - case 'confirmGif': - // const gifData = { - // name: strings.temp.gifName, - // url: strings.temp.gifs[strings.temp.gifIndex].embed_url, - // }; - const gifData = new GifData().setInfo(strings.temp.gifName, strings.temp.gifs[strings.temp.gifIndex].embed_url); - fn.upload.gif(gifData, client); - interaction.update({ content: `I've saved the GIF as ${gifData.name}.gif`, components: [] }); - fn.download.gifs(interaction.client); - break; - case 'nextGif': - newIndex = index + 1; - strings.temp.gifIndex = newIndex; - // If we're leaving the first GIF, enable the Previous GIF button - if (index == 0) { - // Enable Previous GIF button - const prevButton = new MessageButton().setCustomId('prevGif').setLabel('Previous GIF').setStyle('SECONDARY').setDisabled(false); - // Re-Send Confirm GIF Button - const confirmButton = new MessageButton().setCustomId('confirmGif').setLabel('Confirm').setStyle('PRIMARY'); - // Re-Send Next GIF Button - const nextButton = new MessageButton().setCustomId('nextGif').setLabel('Next GIF').setStyle('SECONDARY'); - // Re-Send Cancel Button - const cancelButton = new MessageButton().setCustomId('cancelGif').setLabel('Cancel').setStyle('DANGER'); - // Put all the above into an ActionRow to be sent as a component of the reply - const row = new MessageActionRow().addComponents(prevButton, confirmButton, nextButton, cancelButton); - - interaction.update({ content: strings.temp.gifs[newIndex].embed_url, components: [row] }); - break; - } - // If we're going into the last GIF, disable the Next GIF button - if (newIndex == strings.temp.gifLimit) { - // Re-Send Previous GIF button - const prevButton = new MessageButton().setCustomId('prevGif').setLabel('Previous GIF').setStyle('SECONDARY'); - // Re-Send Confirm GIF Button - const confirmButton = new MessageButton().setCustomId('confirmGif').setLabel('Confirm').setStyle('PRIMARY'); - // Disable Next GIF Button - const nextButton = new MessageButton().setCustomId('nextGif').setLabel('Next GIF').setStyle('SECONDARY').setDisabled(); - // Re-Send Cancel Button - const cancelButton = new MessageButton().setCustomId('cancelGif').setLabel('Canceled').setStyle('DANGER'); - // Put all the above into an ActionRow to be sent as a component of the reply - const row = new MessageActionRow().addComponents(prevButton, confirmButton, nextButton, cancelButton); - - interaction.update({ content: strings.temp.gifs[newIndex].embed_url, components: [row] }); - break; - } - - interaction.update(strings.temp.gifs[newIndex].embed_url); - break; - case 'cancelGif': - // Previous GIF button - const prevButton = new MessageButton().setCustomId('prevGif').setLabel('Previous GIF').setStyle('SECONDARY').setDisabled(); - // Confirm GIF Button - const confirmButton = new MessageButton().setCustomId('confirmGif').setLabel('Confirm').setStyle('PRIMARY').setDisabled(); - // Next GIF Button - const nextButton = new MessageButton().setCustomId('nextGif').setLabel('Next GIF').setStyle('SECONDARY').setDisabled(); - // Cancel Button - const cancelButton = new MessageButton().setCustomId('cancelGif').setLabel('Canceled').setStyle('DANGER'); - // Put all the above into an ActionRow to be sent as a component of the reply - const row = new MessageActionRow().addComponents(prevButton, confirmButton, nextButton, cancelButton); - interaction.component.setDisabled(true); - - interaction.update({ content: 'Canceled.', components: [row] }); - break; - default: - ButtonHandlers.baseEvent(interaction); - break; - } - } - - // Handle autocomplete requests - if (interaction.isAutocomplete()) { - switch (interaction.commandName) { - case 'strain': - const searchString = interaction.options.getFocused(); - const choices = fn.weed.strain.lookup(searchString, interaction.client); - await interaction.respond( - choices.map(choice => ({ name: choice, value: choice })) - ); - break; - case "edit": - //TODO - switch (interaction.options.getSubcommand()) { - case 'gif': - const gifQuery = interaction.options.getFocused(); - const gifChoices = fn.search.gifs(gifQuery, interaction.client); - await interaction.respond( - gifChoices.map(choice => ({ name: choice, value: choice })) - ); - break; - case 'pasta': - const pastaQuery = interaction.options.getFocused(); - const pastaChoices = fn.search.pastas(pastaQuery, interaction.client); - await interaction.respond( - pastaChoices.map(choice => ({ name: choice, value: choice })) - ); - break; - - default: - break; - } - break; - - default: - break; - } - } -}); - // dot-commands client.on('messageCreate', message => { // Some basic checking to prevent running unnecessary code diff --git a/slash-commands/closereq.js b/slash-commands/closereq.js deleted file mode 100644 index 13e5c02..0000000 --- a/slash-commands/closereq.js +++ /dev/null @@ -1,16 +0,0 @@ -const { SlashCommandBuilder } = require('@discordjs/builders'); -const fn = require('../functions.js'); - -module.exports = { - data: new SlashCommandBuilder() - .setName('closereq') - .setDescription('Close a request by ID, retrieved from /requests') - .addStringOption(option => - option.setName('requestid') - .setDescription('The ID of the request you\'d like to close.') - .setRequired(true)), - async execute(interaction) { - const requestId = interaction.options.getString('requestid'); - fn.closeRequest(requestId, interaction); - }, -}; \ No newline at end of file diff --git a/slash-commands/edit.js b/slash-commands/edit.js deleted file mode 100644 index 975e933..0000000 --- a/slash-commands/edit.js +++ /dev/null @@ -1,110 +0,0 @@ -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 { MessageActionRow, MessageButton } = require('discord.js'); -const { GifData, PastaData } = require('../CustomModules/NodBot'); -const fn = require('../functions.js'); -const strings = require('../strings.json'); -const { emoji } = strings; - -module.exports = { - data: new SlashCommandBuilder() - .setName('edit') - .setDescription('Edit content in Nodbot\'s database.') -// GIF - .addSubcommand(subcommand => - subcommand - .setName('gif') - .setDescription('Edit a GIF URL') - .addStringOption(option => - option - .setName('name') - .setDescription('The name of the GIF to edit') - .setRequired(true) - .setAutocomplete(true) - ) - .addStringOption(option => - option - .setName('url') - .setDescription('The new URL') - .setRequired(true) - ) - ) -// Pasta - .addSubcommand(subcommand => - subcommand - .setName('pasta') - .setDescription('Edit a copypasta\'s content') - .addStringOption(option => - option - .setName('name') - .setDescription('The name of the copypasta') - .setRequired(true) - .setAutocomplete(true) - ) - .addStringOption(option => - option - .setName('content') - .setDescription('The new content of the copypasta') - .setRequired(true) - ) - ), - async execute(interaction) { - await interaction.deferReply({ ephemeral: true }); - try { - // Code Here... - const subcommand = interaction.options.getSubcommand(); - switch (subcommand) { -// GIF - case "gif": - //TODO - await this.editGif(interaction, interaction.options.getString('name'), interaction.options.getString('url')); - break; -// Joint - case "joint": - //TODO - break; -// MD - case "md": - //TODO - break; -// Pasta - case "pasta": - //TODO - await this.editPasta(interaction, interaction.options.getString('name'), interaction.options.getString('content')); - break; -// Strain - case "strain": - //TODO - break; - 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}`); - } - }, - async editGif(interaction, name, url) { - const gifData = new GifData().setInfo(name, url); - await fn.upload.gif(gifData, interaction.client); - await fn.download.gifs(interaction.client); - await interaction.editReply(`I've updated ${gifData.name}.gif`); - }, - async editPasta(interaction, name, content) { - const pastaData = new PastaData().setInfo(name, content); - await fn.upload.pasta(pastaData, interaction.client); - await fn.download.gifs(interaction.client); - await interaction.editReply(`I've updated ${name}.pasta`); - } -}; \ No newline at end of file diff --git a/slash-commands/gifs.js b/slash-commands/gifs.js deleted file mode 100644 index c372cc0..0000000 --- a/slash-commands/gifs.js +++ /dev/null @@ -1,30 +0,0 @@ -const { SlashCommandBuilder } = require('@discordjs/builders'); -const { config } = require('dotenv'); -const fn = require('../functions.js'); -const indexer = require('../CustomModules/Indexer.js'); - -module.exports = { - data: new SlashCommandBuilder() - .setName('gifs') - .setDescription('Get a list of currently saved GIFs.'), - execute(interaction) { - if (!interaction.client.gifs) { - interaction.reply('For some reason I don\'t have access to the collection of gifs. Sorry about that!'); - return; - } - let iStorage = interaction.client.iStorage.get(interaction.id); - 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.member.displayName - }; - interaction.reply(fn.embeds.gifs(commandData, indexedGifs)); - } -}; \ No newline at end of file diff --git a/slash-commands/help.js b/slash-commands/help.js deleted file mode 100644 index 084f2d1..0000000 --- a/slash-commands/help.js +++ /dev/null @@ -1,11 +0,0 @@ -const { SlashCommandBuilder } = require('@discordjs/builders'); -const fn = require('../functions.js'); - -module.exports = { - data: new SlashCommandBuilder() - .setName('help') - .setDescription('Send the help page.'), - async execute(interaction) { - await interaction.reply(fn.embeds.help(interaction)); - } -}; \ No newline at end of file diff --git a/slash-commands/jenny.js b/slash-commands/jenny.js deleted file mode 100644 index b0e1f23..0000000 --- a/slash-commands/jenny.js +++ /dev/null @@ -1,11 +0,0 @@ -const { SlashCommandBuilder } = require('@discordjs/builders'); -const fn = require('../functions.js'); - -module.exports = { - data: new SlashCommandBuilder() - .setName('jenny') - .setDescription('Jenny?'), - async execute(interaction) { - interaction.reply('867-5309'); - }, -}; \ No newline at end of file diff --git a/slash-commands/joint.js b/slash-commands/joint.js deleted file mode 100644 index 9bd6f92..0000000 --- a/slash-commands/joint.js +++ /dev/null @@ -1,17 +0,0 @@ -const { SlashCommandBuilder } = require('@discordjs/builders'); -const fn = require('../functions.js'); -const { emoji } = require('../strings.json'); - -module.exports = { - data: new SlashCommandBuilder() - .setName('joint') - .setDescription('Replies with a random cannabis-related quote.'), - async execute(interaction) { - let joints = []; - for (const entry of interaction.client.joints.map(joint => joint.content)) { - joints.push(entry); - } - const randIndex = Math.floor(Math.random() * joints.length); - interaction.reply(`${joints[randIndex]} ${emoji.joint}`); - }, -}; \ No newline at end of file diff --git a/slash-commands/joints.js b/slash-commands/joints.js deleted file mode 100644 index bca4490..0000000 --- a/slash-commands/joints.js +++ /dev/null @@ -1,29 +0,0 @@ -const { SlashCommandBuilder } = require('@discordjs/builders'); -const fn = require('../functions.js'); -const indexer = require('../CustomModules/Indexer.js'); - -module.exports = { - data: new SlashCommandBuilder() - .setName('joints') - .setDescription('Send a list of all the /joint phrases.'), - async execute(interaction) { - 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.member.displayName - }; - interaction.reply(fn.embeds.joints(commandData, indexedJoints)); - }, -}; \ No newline at end of file diff --git a/slash-commands/lenny.js b/slash-commands/lenny.js deleted file mode 100644 index 58bb358..0000000 --- a/slash-commands/lenny.js +++ /dev/null @@ -1,11 +0,0 @@ -const { SlashCommandBuilder } = require('@discordjs/builders'); -const fn = require('../functions.js'); - -module.exports = { - data: new SlashCommandBuilder() - .setName('lenny') - .setDescription('( ͡° ͜ʖ ͡°)'), - async execute(interaction) { - interaction.reply('( ͡° ͜ʖ ͡°)'); - }, -}; \ No newline at end of file diff --git a/slash-commands/pastas.js b/slash-commands/pastas.js deleted file mode 100644 index 8d43578..0000000 --- a/slash-commands/pastas.js +++ /dev/null @@ -1,30 +0,0 @@ -const { SlashCommandBuilder } = require('@discordjs/builders'); -const { config } = require('dotenv'); -const fn = require('../functions.js'); -const indexer = require('../CustomModules/Indexer.js'); - -module.exports = { - data: new SlashCommandBuilder() - .setName('pastas') - .setDescription('Get a list of currently saved copypastas.'), - async execute(interaction) { - if (!interaction.client.pastas) { - interaction.reply({ content: 'For some reason I don\'t have access to the collection of copypastas. Sorry about that!', ephemeral: true }); - return; - } - let iStorage = interaction.client.iStorage.get(interaction.id); - let indexedPastas = indexer(interaction.client.pastas, 0); - indexedPastas.pastasString = new String(); - - iStorage.page = 0; - - for (const pasta of indexedPastas.thisPage) { - indexedPastas.pastasString += `${pasta.name}.pasta\n`; - } - const commandData = { - command: "/pastas", - author: interaction.member.displayName - }; - interaction.reply(fn.embeds.pastas(commandData, indexedPastas)); - }, -}; \ No newline at end of file diff --git a/slash-commands/ping.js b/slash-commands/ping.js deleted file mode 100644 index b3ba2c6..0000000 --- a/slash-commands/ping.js +++ /dev/null @@ -1,11 +0,0 @@ -const { SlashCommandBuilder } = require('@discordjs/builders'); -const fn = require('../functions.js'); - -module.exports = { - data: new SlashCommandBuilder() - .setName('ping') - .setDescription('Check that the bot is alive and responding.'), - async execute(interaction) { - await interaction.reply({ content: 'Pong!', ephemeral: true }); - }, -}; \ No newline at end of file diff --git a/slash-commands/reload.js b/slash-commands/reload.js deleted file mode 100644 index c6543c0..0000000 --- a/slash-commands/reload.js +++ /dev/null @@ -1,20 +0,0 @@ -const { SlashCommandBuilder } = require('@discordjs/builders'); -const fn = require('../functions.js'); - -module.exports = { - data: new SlashCommandBuilder() - .setName('reload') - .setDescription('Reload all saved content, useful if saving something fails.'), - async execute(interaction) { - const { client } = interaction; - fn.collections.slashCommands(client); - fn.collections.dotCommands(client); - fn.collections.setvalidCommands(client); - fn.download.gifs(client); - fn.download.pastas(client); - fn.download.joints(client); - fn.download.requests(client); - fn.download.strains(client); - interaction.reply({ content: 'Reloaded!', ephemeral: true }); - }, -}; \ No newline at end of file diff --git a/slash-commands/requests.js b/slash-commands/requests.js deleted file mode 100644 index fbc8b3b..0000000 --- a/slash-commands/requests.js +++ /dev/null @@ -1,31 +0,0 @@ -const { SlashCommandBuilder } = require('@discordjs/builders'); -const { config } = require('dotenv'); -const fn = require('../functions.js'); -const indexer = require('../CustomModules/Indexer.js'); - -module.exports = { - data: new SlashCommandBuilder() - .setName('requests') - .setDescription('Get a list of Active requests from the database'), - async execute(interaction) { - if (!interaction.client.requests) { - interaction.reply('For some reason I don\'t have access to the collection of requests. Sorry about that!'); - return; - } - let iStorage = interaction.client.iStorage.get(interaction.id); - let indexedRequests = indexer(interaction.client.requests, 0); - indexedRequests.requestsString = new String(); - - iStorage.page = 0; - - for (const request of indexedRequests.thisPage) { - indexedRequests.requestsString += `[${request.id}]: ${request.request} (submitted by ${request.author})\n`; - } - - const commandData = { - command: "/requests", - author: interaction.member.displayName - }; - interaction.reply(fn.embeds.requests(commandData, indexedRequests)); - }, -}; \ No newline at end of file diff --git a/slash-commands/save.js b/slash-commands/save.js deleted file mode 100644 index 28f7533..0000000 --- a/slash-commands/save.js +++ /dev/null @@ -1,232 +0,0 @@ -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 { MessageActionRow, MessageButton } = 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 { emoji } = strings; - -module.exports = { - data: new SlashCommandBuilder() - .setName('save') - .setDescription('Save content to Nodbot\'s database.') -// GIF Search - .addSubcommand(subcommand => - subcommand - .setName('gifsearch') - .setDescription('Search Tenor for a GIF.') - .addStringOption(option => - option - .setName('query') - .setDescription('Search Query') - .setRequired(true)) - .addStringOption(option => - option - .setName('name') - .setDescription('What to save the gif as') - .setRequired(true)) - ) -// GIF URL - .addSubcommand(subcommand => - subcommand - .setName('gifurl') - .setDescription('Specify a URL to save.') - .addStringOption(option => - option - .setName('url') - .setDescription('URL Link to the GIF') - .setRequired(true)) - .addStringOption(option => - option - .setName('name') - .setDescription('What to save the gif as') - .setRequired(true)) - ) -// Joint - .addSubcommand(subcommand => - subcommand - .setName('joint') - .setDescription('Roll a joint and stash it in the database.') - .addStringOption(option => - option - .setName('joint-content') - .setDescription('Phrase to save') - .setRequired(true) - ) - ) -// MD - .addSubcommand(subcommand => - subcommand - .setName('md') - .setDescription('Add medical advice to the database.') - .addStringOption(option => - option - .setName('advice-content') - .setDescription('Advice to save') - .setRequired(true) - ) - ) -// Pasta - .addSubcommand(subcommand => - subcommand - .setName('pasta') - .setDescription('Save a copypasta to the database.') - .addStringOption(option => - option - .setName('pasta-name') - .setDescription('Title of the copypasta') - .setRequired(true) - ) - .addStringOption(option => - option - .setName('pasta-content') - .setDescription('Content of the copypasta') - .setRequired(true) - ) - ) -// Strain - .addSubcommand(subcommand => - subcommand - .setName('strain') - .setDescription('Store a new Strain in the database!') - .addStringOption(option => - option - .setName('name') - .setDescription('Name of the Strain') - .setRequired(true)) - .addStringOption(option => - option - .setName('type') - .setDescription('Indica/Sativa/Hybrid') - .setRequired(true) - .addChoices( - { name: "Indica", value: "Indica" }, - { name: "Hybrid", value: "Hybrid" }, - { name: "Sativa", value: "Sativa" } - ) - ) - .addStringOption(option => - option - .setName('effects') - .setDescription('The effects given by the strain') - .setRequired(false)) - .addStringOption(option => - option - .setName('flavor') - .setDescription('Flavor notes') - .setRequired(false)) - .addStringOption(option => - option - .setName('rating') - .setDescription('Number of stars') - .setRequired(false)) - .addStringOption(option => - option - .setName('description') - .setDescription('Description of the strain') - .setRequired(false)) - ), - async execute(interaction) { - await interaction.deferReply({ ephemeral: true }); - try { - // Code Here... - const subcommand = interaction.options.getSubcommand(); - switch (subcommand) { -// GIF Search - case "gifsearch": - // TODO Check on option names - const actionRow = customEmbeds.gifSearchAR(); - - // Get the query - const query = interaction.options.getString('query'); - strings.temp.gifName = interaction.options.getString('name').toLowerCase(); - - // Search Tenor for the GIF - tenor.Search.Query(query, '10').then(res => { - strings.temp.gifs = []; - strings.temp.gifIndex = 0; - strings.temp.gifLimit = res.length - 1; - strings.temp.gifUserId = interaction.user.id; - - if (res[0] == undefined) { - interaction.editReply('Sorry I was unable to find a GIF of ' + query); - return; - } - for (const row of res) { - strings.temp.gifs.push({ - embed_url: row.media_formats.gif.url, - }); - } - interaction.editReply({ content: strings.temp.gifs[0].embed_url, components: [actionRow], ephemeral: true }); - }); - break; -// GIF URL - case "gifurl": - //TODO Check on option names - // const gifData = { - // name: interaction.options.getString('name').toLowerCase(), - // url: interaction.options.getString('url'), - // }; - const gifData = new GifData().setInfo(interaction.options.getString('name').toLowerCase(), interaction.options.getString('url')); - fn.upload.gif(gifData, interaction.client); - interaction.editReply({ content: `I've saved the GIF as ${gifData.name}.gif`, ephemeral: true }); - fn.download.gifs(interaction.client); - break; -// Joint - case "joint": - //TODO - fn.upload.joint(interaction.options.getString('joint-content'), interaction.client); - interaction.editReply({ content: `The joint has been rolled${emoji.joint}`, ephemeral: true }); - break; -// MD - case "md": - //TODO - fn.upload.medicalAdvice(interaction.options.getString('advice-content'), interaction.client); - interaction.editReply({ content: `The advice has been saved!`, ephemeral: true }); - break; -// Pasta - case "pasta": - //TODO - const pastaData = { - name: interaction.options.getString('pasta-name').toLowerCase(), - content: interaction.options.getString('pasta-content'), - }; - await fn.upload.pasta(pastaData, interaction.client); - interaction.editReply({content: `The copypasta has been saved as ${pastaData.name}.pasta`, ephemeral: true }); - break; -// Strain - case "strain": - //TODO - fn.upload.strain(interaction).then(res => { - interaction.editReply({ - content: `The strain information has been saved. (${interaction.options.getString('name')})`, - ephemeral: true - }); - }).catch(err => { - console.log(`E: ${err}`); - interaction.editReply({ - content: 'There was a problem saving the strain.', - ephemeral: true - }); - }); - 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 diff --git a/slash-commands/setup.js b/slash-commands/setup.js deleted file mode 100644 index fb955dd..0000000 --- a/slash-commands/setup.js +++ /dev/null @@ -1,15 +0,0 @@ -// UNDER DEVELOPMENT -// This *should* create the tables required to use Nodbot, -// assuming you have a database set up with proper permissions. - -const { SlashCommandBuilder } = require('@discordjs/builders'); -const fn = require('../functions.js'); - -module.exports = { - data: new SlashCommandBuilder() - .setName('setup') - .setDescription('Create the tables required to use Nodbot'), - async execute(interaction) { - await interaction.reply({ content: fn.upload.setup(), ephemeral: true }); - }, -}; \ No newline at end of file diff --git a/slash-commands/strain.js b/slash-commands/strain.js deleted file mode 100644 index 74cf8d3..0000000 --- a/slash-commands/strain.js +++ /dev/null @@ -1,17 +0,0 @@ -const { SlashCommandBuilder } = require('@discordjs/builders'); -const fn = require('../functions.js'); - -module.exports = { - data: new SlashCommandBuilder() - .setName('strain') - .setDescription('Look up information about a cannabis strain.') - .addStringOption(option => - option - .setName('name') - .setDescription('Strain Name') - .setRequired(true) - .setAutocomplete(true)), - async execute(interaction) { - fn.download.strain(interaction.options.getString('name'), interaction); - }, -}; \ No newline at end of file diff --git a/slash-commands/template b/slash-commands/template deleted file mode 100644 index c214fae..0000000 --- a/slash-commands/template +++ /dev/null @@ -1,11 +0,0 @@ -const { SlashCommandBuilder } = require('@discordjs/builders'); -const fn = require('../functions.js'); - -module.exports = { - data: new SlashCommandBuilder() - .setName('') - .setDescription(''), - async execute(interaction) { - await - }, -}; \ No newline at end of file diff --git a/slash-commands/truth.js b/slash-commands/truth.js deleted file mode 100644 index 9107844..0000000 --- a/slash-commands/truth.js +++ /dev/null @@ -1,11 +0,0 @@ -const { SlashCommandBuilder } = require('@discordjs/builders'); -const fn = require('../functions.js'); - -module.exports = { - data: new SlashCommandBuilder() - .setName('truth') - .setDescription('The truth about the MHallihan Flight Simulator'), - async execute(interaction) { - await interaction.reply('https://www.twitch.tv/hochmania/clip/EsteemedSlickDootStinkyCheese-hncmP8aIP8_WQb_a?filter=clips&range=all&sort=time'); - }, -}; \ No newline at end of file