diff --git a/README.md b/README.md index 34bc147..794bfb4 100644 --- a/README.md +++ b/README.md @@ -97,4 +97,12 @@ tenorAPIKey= ownerId= statusChannelId= clientId= -``` \ No newline at end of file +``` + +## Changes + +v3.0.1 - Migrate TenorJS API Endpoint +v3.0.2 - Add medical advice commands +v3.0.3 - Fix broken `/requests` command +v3.0.4 - Add ability to use multiple aliases +v3.0.5 - Add ability to save strains \ No newline at end of file diff --git a/functions.js b/functions.js index 70aec19..919ce0e 100644 --- a/functions.js +++ b/functions.js @@ -351,7 +351,7 @@ const functions = { }, { name: 'Rating', - value: `${strainInfo.rating}⭐️s`, + value: `⭐️${strainInfo.rating}`, inline: true, }, { @@ -440,6 +440,23 @@ const functions = { if (err) throw err; functions.download.medicalAdvice(client); }); + }, + strain(interaction) { + const strain = db.escape(interaction.options.getString('name')); + const type = db.escape(interaction.options.getString('type')); + const effects = db.escape(( interaction.options.getString('effects') || 'Unkown' )); + const description = db.escape(( interaction.options.getString('description') || 'Unknown' )); + const flavor = db.escape(( interaction.options.getString('flavor') || 'Unknown' )); + const rating = db.escape(( interaction.options.getString('rating') || '3' )); + const strainQuery = `INSERT INTO strains (strain, type, effects, description, flavor, rating) VALUES (${strain}, ${type}, ${effects}, ${description}, ${flavor}, ${rating})`; + console.log(strainQuery); + return new Promise((resolve, reject) => { + db.query(strainQuery, (err, rows, fields) => { + if (err) reject(err); + functions.download.strains(interaction.client); + resolve(); + }); + }) } }, download: { diff --git a/package.json b/package.json index 9b73aa0..8bd982e 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,14 @@ { "name": "nodbot", - "version": "3.0.4", + "version": "3.0.5", "description": "Nods and Nod Accessories.", "main": "main.js", "dependencies": { - "@discordjs/builders": "^0.6.0", + "@discordjs/builders": "^0.16.0", "@discordjs/rest": "^0.1.0-canary.0", "axios": "^0.21.4", "discord-api-types": "^0.22.0", - "discord.js": "^13.1.0", + "discord.js": "~13.11.0", "dotenv": "^10.0.0", "fuzzy-search": "^3.2.1", "mysql": "^2.18.1", diff --git a/slash-commands/savestrain.js b/slash-commands/savestrain.js new file mode 100644 index 0000000..3cc90f8 --- /dev/null +++ b/slash-commands/savestrain.js @@ -0,0 +1,54 @@ +const { SlashCommandBuilder } = require('@discordjs/builders'); +const fn = require('../functions.js'); +const { emoji } = require('../strings.json'); + +// Strain Name | Type | Effects | Flavor | Rating | Description + +module.exports = { + data: new SlashCommandBuilder() + .setName('savestrain') + .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) { + fn.upload.strain(interaction).then(res => { + interaction.reply({ + content: `The strain information has been saved. (${interaction.options.getString('name')})`, + ephemeral: true + }); + }).catch(err => { + console.log(`E: ${err}`); + interaction.reply({ + content: 'There was a problem saving the strain.', + ephemeral: true + }); + }); + }, +}; \ No newline at end of file