From 0b505bfb0f7a5538ba178657a4824d3f7e8b14e7 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 7 Jan 2023 13:35:23 -0500 Subject: [PATCH 1/5] Versioning Updates --- README.md | 10 +++++++++- package.json | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 34bc147..14a66f6 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/package.json b/package.json index 9b73aa0..4f1e746 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodbot", - "version": "3.0.4", + "version": "3.0.5", "description": "Nods and Nod Accessories.", "main": "main.js", "dependencies": { From 057206cc15b581707c94b618767d6e1983906712 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 7 Jan 2023 13:35:34 -0500 Subject: [PATCH 2/5] Add basic file for the command --- slash-commands/savestrain.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 slash-commands/savestrain.js diff --git a/slash-commands/savestrain.js b/slash-commands/savestrain.js new file mode 100644 index 0000000..662d301 --- /dev/null +++ b/slash-commands/savestrain.js @@ -0,0 +1,17 @@ +const { SlashCommandBuilder } = require('@discordjs/builders'); +const fn = require('../functions.js'); +const { emoji } = require('../strings.json'); + +module.exports = { + data: new SlashCommandBuilder() + .setName('savestrain') + .setDescription('Store a new Strain in the database!') + .addStringOption(option => + option.setName('strain-name') + .setDescription('What is the phrase?') + .setRequired(true)), + async execute(interaction) { + fn.upload.joint(interaction.options.getString('joint-content'), interaction.client); + interaction.reply({ content: `The joint has been rolled${emoji.joint}`, ephemeral: true }); + }, +}; \ No newline at end of file From 30b385aa5eb82f7d7fcffcaacd2c6ac9d73641db Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 7 Jan 2023 13:36:38 -0500 Subject: [PATCH 3/5] Fix formatting --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 14a66f6..794bfb4 100644 --- a/README.md +++ b/README.md @@ -101,8 +101,8 @@ clientId= ## 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 +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 From eef525851922ff41ad9a394714caa3fd4b01072d Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 7 Jan 2023 15:27:26 -0500 Subject: [PATCH 4/5] Updating dependencies --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4f1e746..8bd982e 100644 --- a/package.json +++ b/package.json @@ -4,11 +4,11 @@ "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", From 4cea0f293c583feb6bb12f9d2308f6bb49eb9108 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 7 Jan 2023 15:27:47 -0500 Subject: [PATCH 5/5] Add ability to save new strains --- functions.js | 19 ++++++++++++++- slash-commands/savestrain.js | 47 ++++++++++++++++++++++++++++++++---- 2 files changed, 60 insertions(+), 6 deletions(-) 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/slash-commands/savestrain.js b/slash-commands/savestrain.js index 662d301..3cc90f8 100644 --- a/slash-commands/savestrain.js +++ b/slash-commands/savestrain.js @@ -2,16 +2,53 @@ 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('strain-name') - .setDescription('What is the phrase?') - .setRequired(true)), + 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.joint(interaction.options.getString('joint-content'), interaction.client); - interaction.reply({ content: `The joint has been rolled${emoji.joint}`, ephemeral: true }); + 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