From 3a6ca87b00f6642f8c3277f4cc29ea7775749598 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 7 Jan 2023 12:28:55 -0500 Subject: [PATCH 01/26] Adding medical advice --- dot-commands/md.js | 16 ++++++++++++++++ functions.js | 28 +++++++++++++++++++++++++++- main.js | 1 + slash-commands/savemd.js | 17 +++++++++++++++++ 4 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 dot-commands/md.js create mode 100644 slash-commands/savemd.js diff --git a/dot-commands/md.js b/dot-commands/md.js new file mode 100644 index 0000000..01eea4a --- /dev/null +++ b/dot-commands/md.js @@ -0,0 +1,16 @@ +const fn = require('../functions.js'); +// const { emoji } = require('../strings.json'); + +module.exports = { + name: 'md', + description: 'Get some medical advice.', + usage: '.md', + execute(message, commandData) { + let medicalAdviceArr = []; + for (const entry of message.client.medicalAdviceColl.map(medicalAdvice => medicalAdvice.content)) { + medicalAdviceArr.push(entry); + } + const randIndex = Math.floor(Math.random() * medicalAdviceArr.length); + message.reply(`${medicalAdviceArr[randIndex]}`); + } +} \ No newline at end of file diff --git a/functions.js b/functions.js index 0048b3a..306afc7 100644 --- a/functions.js +++ b/functions.js @@ -139,7 +139,19 @@ const functions = { // if (isDev) console.log(strain) } if (isDev) console.log('Strains Collection Built'); - } + }, + medicalAdvice(rows, client) { + if (!client.medicalAdviceCol) client.medicalAdviceColl = new Discord.Collection(); + client.medicalAdviceColl.clear(); + for (const row of rows) { + const medicalAdvice = { + id: row.id, + content: row.content + }; + client.medicalAdviceColl.set(medicalAdvice.id, medicalAdvice); + } + if (isDev) console.log('Medical Advice Collection Built'); + }, }, dot: { getCommandData(message) { @@ -414,6 +426,13 @@ const functions = { } else { return 'Sorry, you don\'t have permission to do that.'; } + }, + medicalAdvice(content, client) { + const query = `INSERT INTO medical_advice (content) VALUES (${db.escape(content)})`; + db.query(query, (err, rows, fields) => { + if (err) throw err; + functions.download.medicalAdvice(client); + }); } }, download: { @@ -470,6 +489,13 @@ const functions = { functions.collections.strains(rows, client); }); }, + medicalAdvice(client) { + const query = 'SELECT * FROM medical_advice ORDER BY id ASC'; + db.query(query, (err, rows, fields) => { + if (err) throw err; + functions.collections.medicalAdvice(rows, client); + }); + } }, weed: { strain: { diff --git a/main.js b/main.js index d7d66a8..85c118e 100644 --- a/main.js +++ b/main.js @@ -38,6 +38,7 @@ client.once('ready', () => { fn.download.joints(client); fn.download.requests(client); fn.download.strains(client); + fn.download.medicalAdvice(client); console.log('Ready!'); client.channels.fetch(statusChannelId).then(channel => { channel.send(`${new Date().toISOString()} -- <@${process.env.ownerId}>\nStartup Sequence Complete`); diff --git a/slash-commands/savemd.js b/slash-commands/savemd.js new file mode 100644 index 0000000..8391da3 --- /dev/null +++ b/slash-commands/savemd.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('savemd') + .setDescription('Add medical advice to NodBot\'s Database!') + .addStringOption(option => + option.setName('advice-content') + .setDescription('What is the advice?') + .setRequired(true)), + async execute(interaction) { + fn.upload.medicalAdvice(interaction.options.getString('advice-content'), interaction.client); + interaction.reply({ content: `The advice has been saved!`, ephemeral: true }); + }, +}; \ No newline at end of file From a0c82942d29c8f10c04ab906f651f10b4359571d Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 7 Jan 2023 12:30:47 -0500 Subject: [PATCH 02/26] Increment version number --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a0054ce..5724e30 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodbot", - "version": "3.0.0", + "version": "3.0.2", "description": "Nods and Nod Accessories.", "main": "main.js", "dependencies": { From a2f67f30f8b23ba9a56892d4c361befcc364a6b9 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 7 Jan 2023 12:45:08 -0500 Subject: [PATCH 03/26] Increment version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5724e30..81c41bb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodbot", - "version": "3.0.2", + "version": "3.0.3", "description": "Nods and Nod Accessories.", "main": "main.js", "dependencies": { From cc42ebe48e770cd4515813b7dbb4facfb7135d06 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 7 Jan 2023 12:47:45 -0500 Subject: [PATCH 04/26] Fix Requests to only return 10 most recent request --- functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions.js b/functions.js index 306afc7..3f7f227 100644 --- a/functions.js +++ b/functions.js @@ -437,7 +437,7 @@ const functions = { }, download: { requests(client) { - const query = 'SELECT * FROM requests WHERE status = \'Active\' ORDER BY id ASC'; + const query = 'SELECT * FROM requests WHERE status = \'Active\' ORDER BY id DESC LIMIT 10'; db.query(query, (err, rows, fields) => { if (err) throw err; functions.collections.requests(rows, client); From ad2fd5c1c3feb158c700f8b07b360e83b03d1829 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 7 Jan 2023 13:15:54 -0500 Subject: [PATCH 05/26] Add the ability to use an array of aliases --- functions.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/functions.js b/functions.js index 3f7f227..70aec19 100644 --- a/functions.js +++ b/functions.js @@ -56,10 +56,13 @@ const functions = { setvalidCommands(client) { for (const entry of client.dotCommands.map(command => command)) { config.validCommands.push(entry.name); - if (entry.alias != undefined) { + if (Array.isArray(entry.alias)) { + entry.alias.forEach(element => { + config.validCommands.push(element); + }); + } else if (entry.alias != undefined) { config.validCommands.push(entry.alias); } - } if (isDev) console.log(`Valid Commands Added to Config\n${config.validCommands}`); }, @@ -69,7 +72,11 @@ const functions = { for (const file of dotCommandFiles) { const dotCommand = require(`./dot-commands/${file}`); client.dotCommands.set(dotCommand.name, dotCommand); - if (dotCommand.alias != undefined) { + if (Array.isArray(dotCommand.alias)) { + dotCommand.alias.forEach(element => { + client.dotCommands.set(element, dotCommand); + }); + } else if (dotCommand.alias != undefined) { client.dotCommands.set(dotCommand.alias, dotCommand); } } From c20dbeafaf30fb8859f18be3113fb4c9c0023650 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 7 Jan 2023 13:16:00 -0500 Subject: [PATCH 06/26] Increment Version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 81c41bb..9b73aa0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodbot", - "version": "3.0.3", + "version": "3.0.4", "description": "Nods and Nod Accessories.", "main": "main.js", "dependencies": { From 9f0d22c34f6db8bd56b10de42627164bbae2d80a Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 7 Jan 2023 13:16:05 -0500 Subject: [PATCH 07/26] Add new aliases --- dot-commands/joint.js | 1 + 1 file changed, 1 insertion(+) diff --git a/dot-commands/joint.js b/dot-commands/joint.js index 733dade..2ce3202 100644 --- a/dot-commands/joint.js +++ b/dot-commands/joint.js @@ -5,6 +5,7 @@ module.exports = { name: 'joint', description: 'Send a random weed-themed phrase.', usage: '.joint', + alias: ['bong', 'blunt', 'bowl', 'pipe'], execute(message, commandData) { let joints = []; for (const entry of message.client.joints.map(joint => joint.content)) { From 0b505bfb0f7a5538ba178657a4824d3f7e8b14e7 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 7 Jan 2023 13:35:23 -0500 Subject: [PATCH 08/26] 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 09/26] 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 10/26] 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 11/26] 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 12/26] 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 From c600aa30bd8b1a8cd9cf09009f194297bf831287 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 7 Jan 2023 19:29:13 -0500 Subject: [PATCH 13/26] Versioning --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8bd982e..d9d7146 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodbot", - "version": "3.0.5", + "version": "3.0.6", "description": "Nods and Nod Accessories.", "main": "main.js", "dependencies": { From 5d33431d275a8aeee853a89dd04490e6fd6be28c Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 7 Jan 2023 20:00:15 -0500 Subject: [PATCH 14/26] Move strain to slash, add autocomplete --- dot-commands/{strain.js => strain.js.bak} | 0 functions.js | 22 +++++++--------------- main.js | 13 +++++++++++++ slash-commands/strain.js | 17 +++++++++++++++++ 4 files changed, 37 insertions(+), 15 deletions(-) rename dot-commands/{strain.js => strain.js.bak} (100%) create mode 100644 slash-commands/strain.js diff --git a/dot-commands/strain.js b/dot-commands/strain.js.bak similarity index 100% rename from dot-commands/strain.js rename to dot-commands/strain.js.bak diff --git a/functions.js b/functions.js index 919ce0e..72e9c65 100644 --- a/functions.js +++ b/functions.js @@ -323,11 +323,9 @@ const functions = { return { embeds: [requestsEmbed], ephemeral: true }; }, - strain(commandData, message) { + strain(strainInfo, interaction) { const strainEmbed = new Discord.MessageEmbed() - .setTimestamp() - .setFooter(commandData.author); - const { strainInfo } = commandData; + .setTimestamp(); strainEmbed.addFields([ { name: 'Strain Name', @@ -361,7 +359,7 @@ const functions = { }, ]); - message.reply({ embeds: [ strainEmbed ]}); + interaction.reply({ embeds: [ strainEmbed ]}); }, }, collect: { @@ -488,12 +486,11 @@ const functions = { functions.collections.joints(rows, client); }); }, - strain(commandData, message) { - const { strainName } = commandData; + strain(strainName, interaction) { const query = `SELECT id, strain, type, effects, description, flavor, rating FROM strains WHERE strain = ${db.escape(strainName)}`; db.query(query, (err, rows, fields) => { if (rows != undefined) { - commandData.strainInfo = { + const strainInfo = { id: `${rows[0].id}`, strain: `${rows[0].strain}`, type: `${rows[0].type}`, @@ -502,7 +499,7 @@ const functions = { flavor: `${rows[0].flavor}`, rating: `${rows[0].rating}`, }; - functions.embeds.strain(commandData, message); + functions.embeds.strain(strainInfo, interaction); } }); }, @@ -525,12 +522,7 @@ const functions = { strain: { lookup(strainName, client) { const strainSearcher = new FuzzySearch(client.strains.map(e => e.name)); - const name = strainSearcher.search(strainName)[0]; - if (name != undefined) { - return name; - } else { - return false; - } + return strainSearcher.search(strainName).slice(0,25); }, submit(strainName) { const query = `` diff --git a/main.js b/main.js index 85c118e..f215e21 100644 --- a/main.js +++ b/main.js @@ -173,6 +173,19 @@ client.on('interactionCreate', async interaction => { break; } } + + // Handle autocomplete requests + if (interaction.isAutocomplete()) { + if (interaction.commandName == '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 })) + ) + } else { + return; + } + } }); // dot-commands diff --git a/slash-commands/strain.js b/slash-commands/strain.js new file mode 100644 index 0000000..74cf8d3 --- /dev/null +++ b/slash-commands/strain.js @@ -0,0 +1,17 @@ +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 From a1f5d6d5a17c8675769aa3e88f05b1ec5837d525 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 7 Jan 2023 20:08:25 -0500 Subject: [PATCH 15/26] Versioning --- README.md | 4 +++- package.json | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 794bfb4..07c4a95 100644 --- a/README.md +++ b/README.md @@ -105,4 +105,6 @@ 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.5 - Add ability to save strains +v3.0.6 - Move `.strain` to `/strain` and add Autocomplete +v3.0.7 - Add `.spongebob` replies \ No newline at end of file diff --git a/package.json b/package.json index d9d7146..84c4e54 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodbot", - "version": "3.0.6", + "version": "3.0.7", "description": "Nods and Nod Accessories.", "main": "main.js", "dependencies": { From 73adc1036b9198c1f7418c18e8525b42cae8d74a Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 7 Jan 2023 20:22:06 -0500 Subject: [PATCH 16/26] Add replies to spongebob --- dot-commands/spongebob.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/dot-commands/spongebob.js b/dot-commands/spongebob.js index b3ba9a1..692bd83 100644 --- a/dot-commands/spongebob.js +++ b/dot-commands/spongebob.js @@ -10,8 +10,21 @@ module.exports = { // message.reply(fn.spongebob(commandData)).then(() => { // message.delete(); // }); - message.channel.send(fn.spongebob(commandData)).then(() => { - message.delete(); - }); + if (message.reference != undefined) { + const repliedMessageId = message.reference.messageId; + message.channel.messages.fetch(repliedMessageId) + .then(repliedMessage => { + repliedMessage.reply(fn.spongebob({ args: repliedMessage.content })).then(() => { + message.delete(); + }); + }) + .catch(err => { + console.error(err); + }); + } else { + message.channel.send(fn.spongebob(commandData)).then(() => { + message.delete(); + }); + } } } \ No newline at end of file From 2d81f3fa11daa34bf93f78360ed766c0ac26012b Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 7 Jan 2023 20:32:38 -0500 Subject: [PATCH 17/26] Versioning --- README.md | 3 ++- package.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 07c4a95..7d31f60 100644 --- a/README.md +++ b/README.md @@ -107,4 +107,5 @@ v3.0.3 - Fix broken `/requests` command v3.0.4 - Add ability to use multiple aliases v3.0.5 - Add ability to save strains v3.0.6 - Move `.strain` to `/strain` and add Autocomplete -v3.0.7 - Add `.spongebob` replies \ No newline at end of file +v3.0.7 - Add `.spongebob` replies +v3.0.8 - Add ability to open requests by pages \ No newline at end of file diff --git a/package.json b/package.json index 84c4e54..93cfb21 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodbot", - "version": "3.0.7", + "version": "3.0.8", "description": "Nods and Nod Accessories.", "main": "main.js", "dependencies": { From c1759f7d81b003c8fc3c4ee20c8ea78b09ca9dce Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 7 Jan 2023 20:57:03 -0500 Subject: [PATCH 18/26] Add page selection to requests --- functions.js | 2 +- slash-commands/requests.js | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/functions.js b/functions.js index 72e9c65..025c020 100644 --- a/functions.js +++ b/functions.js @@ -459,7 +459,7 @@ const functions = { }, download: { requests(client) { - const query = 'SELECT * FROM requests WHERE status = \'Active\' ORDER BY id DESC LIMIT 10'; + const query = 'SELECT * FROM requests WHERE status = \'Active\' ORDER BY id DESC'; db.query(query, (err, rows, fields) => { if (err) throw err; functions.collections.requests(rows, client); diff --git a/slash-commands/requests.js b/slash-commands/requests.js index 75caa80..039504e 100644 --- a/slash-commands/requests.js +++ b/slash-commands/requests.js @@ -5,8 +5,14 @@ const fn = require('../functions.js'); module.exports = { data: new SlashCommandBuilder() .setName('requests') - .setDescription('Get a list of Active requests from the database'), + .setDescription('Get a list of Active requests from the database') + .addStringOption(option => + option + .setName('page') + .setDescription('Page Number') + .setRequired(true)), async execute(interaction) { + const pageNum = interaction.options.getString('page'); const commandData = { author: interaction.user.tag, command: interaction.commandName, @@ -19,12 +25,14 @@ module.exports = { request: e.request, }; }); - for (const row of requestsMap) { - commandData.requests.push({ - id: row.id, - author: row.author, - request: row.request, - }); + for (let i = ( 10 * ( pageNum - 1 ) ); i < ( 10 * pageNum ); i++) { + if (requestsMap[i] != undefined) { + commandData.requests.push({ + id: requestsMap[i].id, + author: requestsMap[i].author, + request: requestsMap[i].request, + }); + } } interaction.reply(fn.embeds.requests(commandData)); }, From d58542db5b1d769d6836d587404a9cf850fa08c4 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sun, 12 Feb 2023 21:12:21 -0500 Subject: [PATCH 19/26] Improved docker logging --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a0b785a..951298e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,4 +5,4 @@ WORKDIR /usr/src/app COPY package.json ./ RUN npm install COPY . . -CMD [ "node", "main.js" ] \ No newline at end of file +CMD "node main.js 2> /logs/nodbot.error 1> /logs/nodbot.log" \ No newline at end of file From 8b6beb0b06faadf1625c84adb7cde7fe2cb4e472 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sun, 12 Feb 2023 21:17:14 -0500 Subject: [PATCH 20/26] Restructure CMD --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 951298e..7b75fef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,4 +5,4 @@ WORKDIR /usr/src/app COPY package.json ./ RUN npm install COPY . . -CMD "node main.js 2> /logs/nodbot.error 1> /logs/nodbot.log" \ No newline at end of file +CMD ["/bin/sh", "-c", "node main.js 2> /logs/nodbot.error 1> /logs/nodbot.log"] \ No newline at end of file From c35cfbf96203f641373d0328b44b98ab1fd4370b Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sun, 12 Feb 2023 21:22:21 -0500 Subject: [PATCH 21/26] Fix deletable message bug --- dot-commands/spongebob.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dot-commands/spongebob.js b/dot-commands/spongebob.js index 692bd83..f886a27 100644 --- a/dot-commands/spongebob.js +++ b/dot-commands/spongebob.js @@ -15,7 +15,7 @@ module.exports = { message.channel.messages.fetch(repliedMessageId) .then(repliedMessage => { repliedMessage.reply(fn.spongebob({ args: repliedMessage.content })).then(() => { - message.delete(); + if (message.deletable) message.delete(); }); }) .catch(err => { @@ -23,7 +23,7 @@ module.exports = { }); } else { message.channel.send(fn.spongebob(commandData)).then(() => { - message.delete(); + if (message.deletable) message.delete(); }); } } From 2cf8132a65f23c7558da1f12b0c1d88f62e21001 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sun, 9 Apr 2023 12:27:28 -0400 Subject: [PATCH 22/26] Versioning --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 93cfb21..96ddccb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodbot", - "version": "3.0.8", + "version": "3.1.0", "description": "Nods and Nod Accessories.", "main": "main.js", "dependencies": { @@ -8,7 +8,7 @@ "@discordjs/rest": "^0.1.0-canary.0", "axios": "^0.21.4", "discord-api-types": "^0.22.0", - "discord.js": "~13.11.0", + "discord.js": "^14.9.0", "dotenv": "^10.0.0", "fuzzy-search": "^3.2.1", "mysql": "^2.18.1", From e1474b935f3abf0a5adaf83ea8a6bac3d6c31ad9 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sun, 9 Apr 2023 12:31:58 -0400 Subject: [PATCH 23/26] Update CI/CD to manual only --- .github/workflows/docker-image.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 76eb4f4..dc265da 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,10 +1,7 @@ name: Docker Image CI on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] + workflow_dispatch: env: DHUB_UNAME: ${{ secrets.DHUB_UNAME }} From 36e25f5e34e63fe795feab9ed5007e434912f393 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sun, 9 Apr 2023 12:41:47 -0400 Subject: [PATCH 24/26] Rollback to D.js v13 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 96ddccb..7c84570 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "@discordjs/rest": "^0.1.0-canary.0", "axios": "^0.21.4", "discord-api-types": "^0.22.0", - "discord.js": "^14.9.0", + "discord.js": "^13.15.1", "dotenv": "^10.0.0", "fuzzy-search": "^3.2.1", "mysql": "^2.18.1", From 57238ce57a975f07be8ac6eddc5977ad11707380 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Thu, 13 Apr 2023 20:16:33 -0400 Subject: [PATCH 25/26] Add variety to ong --- main.js | 5 ++++- strings.json | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index f215e21..0ee3d91 100644 --- a/main.js +++ b/main.js @@ -197,7 +197,10 @@ client.on('messageCreate', message => { const lowerContent = message.content.toLowerCase(); if (lowerContent.includes('big') && lowerContent.includes('doinks')) message.reply('gang.'); if (lowerContent.includes('ligma')) message.reply('ligma balls, goteem'); - if (lowerContent.includes('frfr') || lowerContent.includes('fr fr') || lowerContent.includes('bussin') || lowerContent.includes(' ong') || lowerContent.startsWith('ong')) message.reply('ongggg no :billed_cap: fr fr str8 bussin'); + if (lowerContent.includes('frfr') || lowerContent.includes('fr fr') || lowerContent.includes('bussin') || lowerContent.includes(' ong') || lowerContent.startsWith('ong')) { + const randIndex = Math.floor(Math.random() * strings.capbacks.length); + message.reply(strings.capbacks[randIndex]); + } // Break the message down into its components and analyze it const commandData = fn.dot.getCommandData(message); diff --git a/strings.json b/strings.json index ccc342e..bcf8a14 100644 --- a/strings.json +++ b/strings.json @@ -14,5 +14,13 @@ "urls": { "avatar": "https://cdn.discordapp.com/avatars/513184762073055252/12227aa23a06d5178853e59b72c7487b.webp?size=128" }, + "capbacks": [ + "on god?!", + "fr fr?!", + "no cap?!", + "no cap fr", + "bussin fr, no cap", + "ongggg no :billed_cap: fr fr" + ], "temp": {} } \ No newline at end of file From 1f85b97467a7970f4c9ffa7c01c46cdd36cf55c1 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 4 Aug 2023 20:06:09 -0400 Subject: [PATCH 26/26] CI/CD Update for Gitea Actions --- .github/workflows/docker-image.yml | 23 ---------------- .github/workflows/pe-docker.yml | 35 +++++++++++++++++++++++++ .github/workflows/production-docker.yml | 35 +++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 23 deletions(-) delete mode 100644 .github/workflows/docker-image.yml create mode 100644 .github/workflows/pe-docker.yml create mode 100644 .github/workflows/production-docker.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml deleted file mode 100644 index dc265da..0000000 --- a/.github/workflows/docker-image.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Docker Image CI - -on: - workflow_dispatch: - -env: - DHUB_UNAME: ${{ secrets.DHUB_UNAME }} - DHUB_PWORD: ${{ secrets.DHUB_PWORD }} - -jobs: - - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Build the Docker image - run: docker build . --file Dockerfile --tag v0idf1sh/nodbot - - name: Log into Docker Hub - run: docker login -u $DHUB_UNAME -p $DHUB_PWORD - - name: Push image to Docker Hub - run: docker push v0idf1sh/nodbot diff --git a/.github/workflows/pe-docker.yml b/.github/workflows/pe-docker.yml new file mode 100644 index 0000000..003f963 --- /dev/null +++ b/.github/workflows/pe-docker.yml @@ -0,0 +1,35 @@ +name: NodBot Production Dockerization + +on: + commit: + branches: + - pe + +env: + DHUB_UNAME: ${{ secrets.DHUB_UNAME }} + DHUB_PWORD: ${{ secrets.DHUB_PWORD }} + +jobs: + + build: + + runs-on: self-hosted + + steps: + - name: Pull latest from Git + run: | + pwd + whoami + cd /root/nodbot + git pull + git checkout pe + - name: Build the Docker image + run: | + cd /root/nodbot + docker build . --file Dockerfile --tag v0idf1sh/nodbot-pe + - name: Log into Docker Hub + run: docker login -u $DHUB_UNAME -p $DHUB_PWORD + - name: Push image to Docker Hub + run: | + cd /root/nodbot + docker push v0idf1sh/nodbot-pe \ No newline at end of file diff --git a/.github/workflows/production-docker.yml b/.github/workflows/production-docker.yml new file mode 100644 index 0000000..d4e5c6b --- /dev/null +++ b/.github/workflows/production-docker.yml @@ -0,0 +1,35 @@ +name: NodBot Production Dockerization + +on: + pull_request: + branches: + - main + +env: + DHUB_UNAME: ${{ secrets.DHUB_UNAME }} + DHUB_PWORD: ${{ secrets.DHUB_PWORD }} + +jobs: + + build: + + runs-on: self-hosted + + steps: + - name: Pull latest from Git + run: | + pwd + whoami + cd /root/nodbot + git pull + git checkout $GITHUB_HEAD_REF + - name: Build the Docker image + run: | + cd /root/nodbot + docker build . --file Dockerfile --tag v0idf1sh/nodbot + - name: Log into Docker Hub + run: docker login -u $DHUB_UNAME -p $DHUB_PWORD + - name: Push image to Docker Hub + run: | + cd /root/nodbot + docker push v0idf1sh/nodbot \ No newline at end of file