From 42f0fc891367eb73902216d313bdb75c151de96d Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 00:27:46 -0500 Subject: [PATCH 01/34] Update .strain embed to reflect new data source --- functions.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/functions.js b/functions.js index 39aad3e..03c4d1d 100644 --- a/functions.js +++ b/functions.js @@ -322,16 +322,16 @@ const functions = { value: `${strainInfo.effects}`, inline: true, }, - { - name: 'Treats', - value: `${strainInfo.ailments}`, - inline: true, - }, { name: 'Flavor', value: `${strainInfo.flavor}`, inline: true, }, + { + name: 'Description', + value: `${strainInfo.ailments}`, + inline: false, + }, ]); message.reply({ embeds: [ strainEmbed ]}); From 9857406edd9804da094005bfa560751e98a227c3 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 00:37:58 -0500 Subject: [PATCH 02/34] Further updates to match new data source .strain --- functions.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/functions.js b/functions.js index 03c4d1d..30bad3a 100644 --- a/functions.js +++ b/functions.js @@ -327,9 +327,14 @@ const functions = { value: `${strainInfo.flavor}`, inline: true, }, + { + name: 'Rating', + value: `${strainInfo.rating}⭐️`, + inline: true, + }, { name: 'Description', - value: `${strainInfo.ailments}`, + value: `${strainInfo.description}`, inline: false, }, ]); @@ -439,7 +444,7 @@ const functions = { }, strain(commandData, message) { const { strainName } = commandData; - const query = `SELECT id, name, type, effects, ailment, flavor FROM strains WHERE name = ${db.escape(strainName)}`; + const query = `SELECT id, name, type, effects, description, flavor, rating FROM strains WHERE name = ${db.escape(strainName)}`; db.query(query, (err, rows, fields) => { if (rows != undefined) { commandData.strainInfo = { @@ -447,8 +452,9 @@ const functions = { name: `${rows[0].name}`, type: `${rows[0].type}`, effects: `${rows[0].effects}`, - ailments: `${rows[0].ailment}`, + description: `${rows[0].description}`, flavor: `${rows[0].flavor}`, + rating: `${rows[0].rating}`, }; functions.embeds.strain(commandData, message); } From 752b86908a92fcb4570cd6ed911e0a9f2a1ae2ed Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 01:16:39 -0500 Subject: [PATCH 03/34] Implementing .strain data source change --- functions.js | 16 ++++++++++------ package.json | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/functions.js b/functions.js index 30bad3a..1a72cfe 100644 --- a/functions.js +++ b/functions.js @@ -61,7 +61,7 @@ const functions = { } } - if (isDev) console.log('Valid Commands Added to Config'); + if (isDev) console.log(`Valid Commands Added to Config\n${config.validCommands}`); }, dotCommands(client) { if (!client.dotCommands) client.dotCommands = new Discord.Collection(); @@ -133,9 +133,10 @@ const functions = { for (const row of rows) { const strain = { id: row.id, - name: row.name, + name: row.strain, }; client.strains.set(strain.name, strain); + if (isDev) console.log(strain) } if (isDev) console.log('Strains Collection Built'); } @@ -145,6 +146,7 @@ const functions = { const commandData = {}; // Split the message content at the final instance of a period const finalPeriod = message.content.lastIndexOf('.'); + if(isDev) console.log(message.content); // If the final period is the last character, or doesn't exist if (finalPeriod < 0) { if (isDev) console.log(finalPeriod); @@ -310,7 +312,8 @@ const functions = { strainEmbed.addFields([ { name: 'Strain Name', - value: `${strainInfo.name}`, + value: `${strainInfo.strain}`, + inline: true, }, { name: 'Type', @@ -444,12 +447,13 @@ const functions = { }, strain(commandData, message) { const { strainName } = commandData; - const query = `SELECT id, name, type, effects, description, flavor, rating FROM strains WHERE name = ${db.escape(strainName)}`; + const query = `SELECT id, strain, type, effects, description, flavor, rating FROM strains WHERE strain = ${db.escape(strainName)}`; db.query(query, (err, rows, fields) => { + if (err) throw err; if (rows != undefined) { commandData.strainInfo = { id: `${rows[0].id}`, - name: `${rows[0].name}`, + strain: `${rows[0].strain}`, type: `${rows[0].type}`, effects: `${rows[0].effects}`, description: `${rows[0].description}`, @@ -461,7 +465,7 @@ const functions = { }); }, strains(client) { - const query = 'SELECT id, name FROM strains'; + const query = 'SELECT id, strain FROM strains'; db.query(query, (err, rows, fields) => { if (err) throw err; functions.collections.strains(rows, client); diff --git a/package.json b/package.json index 80f6a6a..87f9215 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodbot", - "version": "3.0.0", + "version": "3.0.1", "description": "Nods and Nod Accessories.", "main": "main.js", "dependencies": { From 13203fa0a041d43e40d332e3af3669975580ab26 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 11:47:09 -0500 Subject: [PATCH 04/34] logging --- main.js | 1 + 1 file changed, 1 insertion(+) diff --git a/main.js b/main.js index 7828b3b..6ea0a28 100644 --- a/main.js +++ b/main.js @@ -30,6 +30,7 @@ const strings = require('./strings.json'); const isDev = process.env.isDev; client.once('ready', () => { + console.log(process.env) fn.collections.slashCommands(client); fn.collections.dotCommands(client); fn.collections.setvalidCommands(client); From 4a35e4d4a3f93608ff85e45c52c7f211a6e747ba Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 12:08:54 -0500 Subject: [PATCH 05/34] Removing old workflows --- .github/workflows/dev_deploy.yaml.bak | 25 ------------------------- .github/workflows/prod_deploy.yaml.bak | 25 ------------------------- 2 files changed, 50 deletions(-) delete mode 100644 .github/workflows/dev_deploy.yaml.bak delete mode 100644 .github/workflows/prod_deploy.yaml.bak diff --git a/.github/workflows/dev_deploy.yaml.bak b/.github/workflows/dev_deploy.yaml.bak deleted file mode 100644 index ae93bf1..0000000 --- a/.github/workflows/dev_deploy.yaml.bak +++ /dev/null @@ -1,25 +0,0 @@ -# name: NodBot Dev Deploy - -# on: -# push: # tells github to run this on any push to the dev branch -# branches: -# - dev - -# jobs: -# deploy: -# runs-on: ubuntu-latest -# if: github.ref == 'refs/heads/dev' # we tell Github to only execute this step if we're on our dev branch -# steps: -# - name: Deploying to Probey -# uses: appleboy/ssh-action@master # An action made to control Linux servers -# with: # We set all our secrets here for the action, these won't be shown in the action logs -# host: ${{ secrets.HOST }} -# username: ${{ secrets.USERNAME }} -# key: ${{ secrets.KEY }} -# port: ${{ secrets.PORT }} -# script: | -# cd nodbot-dev # we move into our app's folder -# git pull # we pull any changes from git -# npm prune # we remove any unused dependencies -# npm install # we install any missing dependencies -# pm2 reload nodbot-dev # we reload the app via PM2 diff --git a/.github/workflows/prod_deploy.yaml.bak b/.github/workflows/prod_deploy.yaml.bak deleted file mode 100644 index edc92cd..0000000 --- a/.github/workflows/prod_deploy.yaml.bak +++ /dev/null @@ -1,25 +0,0 @@ -# name: NodBot Production Deploy - -# on: -# push: # tells github to run this on any push to the dev branch -# branches: -# - main - -# jobs: -# deploy: -# runs-on: ubuntu-latest -# if: github.ref == 'refs/heads/main' # we tell Github to only execute this step if we're on our main branch -# steps: -# - name: Deploying to Probey -# uses: appleboy/ssh-action@master # An action made to control Linux servers -# with: # We set all our secrets here for the action, these won't be shown in the action logs -# host: ${{ secrets.HOST }} -# username: ${{ secrets.USERNAME }} -# key: ${{ secrets.KEY }} -# port: ${{ secrets.PORT }} -# script: | -# cd nodbot # we move into our app's folder -# git pull # we pull any changes from git -# npm prune # we remove any unused dependencies -# npm install # we install any missing dependencies -# pm2 reload nodbot # we reload the app via PM2 From b9332ec602050ff22e0186d1797db244c8f8289d Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 12:16:43 -0500 Subject: [PATCH 06/34] Not done --- .github/workflows/docker-image.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..d7ad099 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,19 @@ +name: Docker Image CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Build the Docker image + run: docker build . --file Dockerfile --tag v0idf1sh/nodbot:$(date +%s) + run: docker login From c5ab2681b38a90c6a619a07613d87004df3d9892 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 12:28:32 -0500 Subject: [PATCH 07/34] CI/CD Implement github actions to build and push the docker image --- .github/workflows/docker-image.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index d7ad099..cf3ceb6 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -5,6 +5,10 @@ on: branches: [ "main" ] pull_request: branches: [ "main" ] + +env: + DHUB_UNAME: {{ secrets.DHUB_UNAME }} + DHUB_PWORD: {{ secrets.DHUB_PWORD }} jobs: @@ -16,4 +20,7 @@ jobs: - uses: actions/checkout@v3 - name: Build the Docker image run: docker build . --file Dockerfile --tag v0idf1sh/nodbot:$(date +%s) - run: docker login + - 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:latest From 59f5df4b8e8600a757553c7027977ec884129f38 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 12:30:21 -0500 Subject: [PATCH 08/34] Fixed variable format --- .github/workflows/docker-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index cf3ceb6..47a8323 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -7,8 +7,8 @@ on: branches: [ "main" ] env: - DHUB_UNAME: {{ secrets.DHUB_UNAME }} - DHUB_PWORD: {{ secrets.DHUB_PWORD }} + DHUB_UNAME: ${{ secrets.DHUB_UNAME }} + DHUB_PWORD: ${{ secrets.DHUB_PWORD }} jobs: From eb98e7da854265628a00aa1d6e9e1e6a7718aa5a Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 12:34:06 -0500 Subject: [PATCH 09/34] Changed docker tag --- .github/workflows/docker-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 47a8323..76eb4f4 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -19,8 +19,8 @@ jobs: steps: - uses: actions/checkout@v3 - name: Build the Docker image - run: docker build . --file Dockerfile --tag v0idf1sh/nodbot:$(date +%s) + 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:latest + run: docker push v0idf1sh/nodbot From afa9ef568d1defde1d8996de63c603904dd37c1f Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 12:38:26 -0500 Subject: [PATCH 10/34] Removed unnecessary log --- functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions.js b/functions.js index 1a72cfe..1cea7cc 100644 --- a/functions.js +++ b/functions.js @@ -136,7 +136,7 @@ const functions = { name: row.strain, }; client.strains.set(strain.name, strain); - if (isDev) console.log(strain) + // if (isDev) console.log(strain) } if (isDev) console.log('Strains Collection Built'); } From b6d2a539762cec69c226e0eb7de2bd273df90b9b Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 12:55:05 -0500 Subject: [PATCH 11/34] Tenor search is FUBAR --- dot-commands/gif.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dot-commands/gif.js b/dot-commands/gif.js index 4b8f556..03ea658 100644 --- a/dot-commands/gif.js +++ b/dot-commands/gif.js @@ -7,6 +7,10 @@ const tenor = require('tenorjs').client({ "DateFormat": "D/MM/YYYY - H:mm:ss A" // Change this accordingly }); +// TODO: Tenor has changed API versions, switch from TenorJS (unmaintained) to axios for +// general API usage. See: https://github.com/Jinzulen/TenorJS/issues/12 +// see also: https://developers.google.com/tenor/guides/migrate-from-v1 + module.exports = { name: 'gif', description: 'Send a GIF', From b56e700466d5aa680f09c0b9dd0aad55af8106b8 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 13:00:14 -0500 Subject: [PATCH 12/34] Revert "Removed unnecessary log" This reverts commit afa9ef568d1defde1d8996de63c603904dd37c1f. --- functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions.js b/functions.js index 1cea7cc..1a72cfe 100644 --- a/functions.js +++ b/functions.js @@ -136,7 +136,7 @@ const functions = { name: row.strain, }; client.strains.set(strain.name, strain); - // if (isDev) console.log(strain) + if (isDev) console.log(strain) } if (isDev) console.log('Strains Collection Built'); } From 85700c593c08f33fe57f36158e76eba4612c842f Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 13:00:26 -0500 Subject: [PATCH 13/34] Revert "Changed docker tag" This reverts commit eb98e7da854265628a00aa1d6e9e1e6a7718aa5a. --- .github/workflows/docker-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 76eb4f4..47a8323 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -19,8 +19,8 @@ jobs: steps: - uses: actions/checkout@v3 - name: Build the Docker image - run: docker build . --file Dockerfile --tag v0idf1sh/nodbot + run: docker build . --file Dockerfile --tag v0idf1sh/nodbot:$(date +%s) - 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 + run: docker push v0idf1sh/nodbot:latest From f6edfcd36dec2ed324c1476849af5f98e2cc7ac1 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 13:00:33 -0500 Subject: [PATCH 14/34] Revert "Fixed variable format" This reverts commit 59f5df4b8e8600a757553c7027977ec884129f38. --- .github/workflows/docker-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 47a8323..cf3ceb6 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -7,8 +7,8 @@ on: branches: [ "main" ] env: - DHUB_UNAME: ${{ secrets.DHUB_UNAME }} - DHUB_PWORD: ${{ secrets.DHUB_PWORD }} + DHUB_UNAME: {{ secrets.DHUB_UNAME }} + DHUB_PWORD: {{ secrets.DHUB_PWORD }} jobs: From 5ce1c5d6036e386217c842c1479309300c22bcda Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 13:00:40 -0500 Subject: [PATCH 15/34] Revert "CI/CD" This reverts commit c5ab2681b38a90c6a619a07613d87004df3d9892. --- .github/workflows/docker-image.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index cf3ceb6..d7ad099 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -5,10 +5,6 @@ on: branches: [ "main" ] pull_request: branches: [ "main" ] - -env: - DHUB_UNAME: {{ secrets.DHUB_UNAME }} - DHUB_PWORD: {{ secrets.DHUB_PWORD }} jobs: @@ -20,7 +16,4 @@ jobs: - uses: actions/checkout@v3 - name: Build the Docker image run: docker build . --file Dockerfile --tag v0idf1sh/nodbot:$(date +%s) - - 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:latest + run: docker login From e7c7847d9d506025861cd6b0c3c36f2bb6d824cf Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 13:00:46 -0500 Subject: [PATCH 16/34] Revert "Not done" This reverts commit b9332ec602050ff22e0186d1797db244c8f8289d. --- .github/workflows/docker-image.yml | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml deleted file mode 100644 index d7ad099..0000000 --- a/.github/workflows/docker-image.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Docker Image CI - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -jobs: - - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Build the Docker image - run: docker build . --file Dockerfile --tag v0idf1sh/nodbot:$(date +%s) - run: docker login From d55e91bad7afadb9eeb43c48ba916529616fd5f0 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 13:00:53 -0500 Subject: [PATCH 17/34] Revert "Removing old workflows" This reverts commit 4a35e4d4a3f93608ff85e45c52c7f211a6e747ba. --- .github/workflows/dev_deploy.yaml.bak | 25 +++++++++++++++++++++++++ .github/workflows/prod_deploy.yaml.bak | 25 +++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 .github/workflows/dev_deploy.yaml.bak create mode 100644 .github/workflows/prod_deploy.yaml.bak diff --git a/.github/workflows/dev_deploy.yaml.bak b/.github/workflows/dev_deploy.yaml.bak new file mode 100644 index 0000000..ae93bf1 --- /dev/null +++ b/.github/workflows/dev_deploy.yaml.bak @@ -0,0 +1,25 @@ +# name: NodBot Dev Deploy + +# on: +# push: # tells github to run this on any push to the dev branch +# branches: +# - dev + +# jobs: +# deploy: +# runs-on: ubuntu-latest +# if: github.ref == 'refs/heads/dev' # we tell Github to only execute this step if we're on our dev branch +# steps: +# - name: Deploying to Probey +# uses: appleboy/ssh-action@master # An action made to control Linux servers +# with: # We set all our secrets here for the action, these won't be shown in the action logs +# host: ${{ secrets.HOST }} +# username: ${{ secrets.USERNAME }} +# key: ${{ secrets.KEY }} +# port: ${{ secrets.PORT }} +# script: | +# cd nodbot-dev # we move into our app's folder +# git pull # we pull any changes from git +# npm prune # we remove any unused dependencies +# npm install # we install any missing dependencies +# pm2 reload nodbot-dev # we reload the app via PM2 diff --git a/.github/workflows/prod_deploy.yaml.bak b/.github/workflows/prod_deploy.yaml.bak new file mode 100644 index 0000000..edc92cd --- /dev/null +++ b/.github/workflows/prod_deploy.yaml.bak @@ -0,0 +1,25 @@ +# name: NodBot Production Deploy + +# on: +# push: # tells github to run this on any push to the dev branch +# branches: +# - main + +# jobs: +# deploy: +# runs-on: ubuntu-latest +# if: github.ref == 'refs/heads/main' # we tell Github to only execute this step if we're on our main branch +# steps: +# - name: Deploying to Probey +# uses: appleboy/ssh-action@master # An action made to control Linux servers +# with: # We set all our secrets here for the action, these won't be shown in the action logs +# host: ${{ secrets.HOST }} +# username: ${{ secrets.USERNAME }} +# key: ${{ secrets.KEY }} +# port: ${{ secrets.PORT }} +# script: | +# cd nodbot # we move into our app's folder +# git pull # we pull any changes from git +# npm prune # we remove any unused dependencies +# npm install # we install any missing dependencies +# pm2 reload nodbot # we reload the app via PM2 From 247afa326ffa349ad6606d20a05d6589590bdb90 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 13:01:00 -0500 Subject: [PATCH 18/34] Revert "logging" This reverts commit 13203fa0a041d43e40d332e3af3669975580ab26. --- main.js | 1 - 1 file changed, 1 deletion(-) diff --git a/main.js b/main.js index 6ea0a28..7828b3b 100644 --- a/main.js +++ b/main.js @@ -30,7 +30,6 @@ const strings = require('./strings.json'); const isDev = process.env.isDev; client.once('ready', () => { - console.log(process.env) fn.collections.slashCommands(client); fn.collections.dotCommands(client); fn.collections.setvalidCommands(client); From cb7218152c13fafd18bb250b10a7e987f6c47d20 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 13:01:07 -0500 Subject: [PATCH 19/34] Revert "Implementing .strain data source change" This reverts commit 752b86908a92fcb4570cd6ed911e0a9f2a1ae2ed. --- functions.js | 16 ++++++---------- package.json | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/functions.js b/functions.js index 1a72cfe..30bad3a 100644 --- a/functions.js +++ b/functions.js @@ -61,7 +61,7 @@ const functions = { } } - if (isDev) console.log(`Valid Commands Added to Config\n${config.validCommands}`); + if (isDev) console.log('Valid Commands Added to Config'); }, dotCommands(client) { if (!client.dotCommands) client.dotCommands = new Discord.Collection(); @@ -133,10 +133,9 @@ const functions = { for (const row of rows) { const strain = { id: row.id, - name: row.strain, + name: row.name, }; client.strains.set(strain.name, strain); - if (isDev) console.log(strain) } if (isDev) console.log('Strains Collection Built'); } @@ -146,7 +145,6 @@ const functions = { const commandData = {}; // Split the message content at the final instance of a period const finalPeriod = message.content.lastIndexOf('.'); - if(isDev) console.log(message.content); // If the final period is the last character, or doesn't exist if (finalPeriod < 0) { if (isDev) console.log(finalPeriod); @@ -312,8 +310,7 @@ const functions = { strainEmbed.addFields([ { name: 'Strain Name', - value: `${strainInfo.strain}`, - inline: true, + value: `${strainInfo.name}`, }, { name: 'Type', @@ -447,13 +444,12 @@ const functions = { }, strain(commandData, message) { const { strainName } = commandData; - const query = `SELECT id, strain, type, effects, description, flavor, rating FROM strains WHERE strain = ${db.escape(strainName)}`; + const query = `SELECT id, name, type, effects, description, flavor, rating FROM strains WHERE name = ${db.escape(strainName)}`; db.query(query, (err, rows, fields) => { - if (err) throw err; if (rows != undefined) { commandData.strainInfo = { id: `${rows[0].id}`, - strain: `${rows[0].strain}`, + name: `${rows[0].name}`, type: `${rows[0].type}`, effects: `${rows[0].effects}`, description: `${rows[0].description}`, @@ -465,7 +461,7 @@ const functions = { }); }, strains(client) { - const query = 'SELECT id, strain FROM strains'; + const query = 'SELECT id, name FROM strains'; db.query(query, (err, rows, fields) => { if (err) throw err; functions.collections.strains(rows, client); diff --git a/package.json b/package.json index 87f9215..80f6a6a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodbot", - "version": "3.0.1", + "version": "3.0.0", "description": "Nods and Nod Accessories.", "main": "main.js", "dependencies": { From a233d18e535f81bf9ba1a6601b553fa623d5f860 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 13:01:14 -0500 Subject: [PATCH 20/34] Revert "Further updates to match new data source .strain" This reverts commit 9857406edd9804da094005bfa560751e98a227c3. --- functions.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/functions.js b/functions.js index 30bad3a..03c4d1d 100644 --- a/functions.js +++ b/functions.js @@ -327,14 +327,9 @@ const functions = { value: `${strainInfo.flavor}`, inline: true, }, - { - name: 'Rating', - value: `${strainInfo.rating}⭐️`, - inline: true, - }, { name: 'Description', - value: `${strainInfo.description}`, + value: `${strainInfo.ailments}`, inline: false, }, ]); @@ -444,7 +439,7 @@ const functions = { }, strain(commandData, message) { const { strainName } = commandData; - const query = `SELECT id, name, type, effects, description, flavor, rating FROM strains WHERE name = ${db.escape(strainName)}`; + const query = `SELECT id, name, type, effects, ailment, flavor FROM strains WHERE name = ${db.escape(strainName)}`; db.query(query, (err, rows, fields) => { if (rows != undefined) { commandData.strainInfo = { @@ -452,9 +447,8 @@ const functions = { name: `${rows[0].name}`, type: `${rows[0].type}`, effects: `${rows[0].effects}`, - description: `${rows[0].description}`, + ailments: `${rows[0].ailment}`, flavor: `${rows[0].flavor}`, - rating: `${rows[0].rating}`, }; functions.embeds.strain(commandData, message); } From e1cb5b0556ad23dbf1e3ee270af925cbd26bf507 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 13:01:20 -0500 Subject: [PATCH 21/34] Revert "Update .strain embed to reflect new data source" This reverts commit 42f0fc891367eb73902216d313bdb75c151de96d. --- functions.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/functions.js b/functions.js index 03c4d1d..39aad3e 100644 --- a/functions.js +++ b/functions.js @@ -323,14 +323,14 @@ const functions = { inline: true, }, { - name: 'Flavor', - value: `${strainInfo.flavor}`, + name: 'Treats', + value: `${strainInfo.ailments}`, inline: true, }, { - name: 'Description', - value: `${strainInfo.ailments}`, - inline: false, + name: 'Flavor', + value: `${strainInfo.flavor}`, + inline: true, }, ]); From 987b54d1c9b12fa601318a0fed38ce833b10beab Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 13:02:23 -0500 Subject: [PATCH 22/34] Removing old workflows --- .github/workflows/dev_deploy.yaml.bak | 25 ------------------------- .github/workflows/prod_deploy.yaml.bak | 25 ------------------------- 2 files changed, 50 deletions(-) delete mode 100644 .github/workflows/dev_deploy.yaml.bak delete mode 100644 .github/workflows/prod_deploy.yaml.bak diff --git a/.github/workflows/dev_deploy.yaml.bak b/.github/workflows/dev_deploy.yaml.bak deleted file mode 100644 index ae93bf1..0000000 --- a/.github/workflows/dev_deploy.yaml.bak +++ /dev/null @@ -1,25 +0,0 @@ -# name: NodBot Dev Deploy - -# on: -# push: # tells github to run this on any push to the dev branch -# branches: -# - dev - -# jobs: -# deploy: -# runs-on: ubuntu-latest -# if: github.ref == 'refs/heads/dev' # we tell Github to only execute this step if we're on our dev branch -# steps: -# - name: Deploying to Probey -# uses: appleboy/ssh-action@master # An action made to control Linux servers -# with: # We set all our secrets here for the action, these won't be shown in the action logs -# host: ${{ secrets.HOST }} -# username: ${{ secrets.USERNAME }} -# key: ${{ secrets.KEY }} -# port: ${{ secrets.PORT }} -# script: | -# cd nodbot-dev # we move into our app's folder -# git pull # we pull any changes from git -# npm prune # we remove any unused dependencies -# npm install # we install any missing dependencies -# pm2 reload nodbot-dev # we reload the app via PM2 diff --git a/.github/workflows/prod_deploy.yaml.bak b/.github/workflows/prod_deploy.yaml.bak deleted file mode 100644 index edc92cd..0000000 --- a/.github/workflows/prod_deploy.yaml.bak +++ /dev/null @@ -1,25 +0,0 @@ -# name: NodBot Production Deploy - -# on: -# push: # tells github to run this on any push to the dev branch -# branches: -# - main - -# jobs: -# deploy: -# runs-on: ubuntu-latest -# if: github.ref == 'refs/heads/main' # we tell Github to only execute this step if we're on our main branch -# steps: -# - name: Deploying to Probey -# uses: appleboy/ssh-action@master # An action made to control Linux servers -# with: # We set all our secrets here for the action, these won't be shown in the action logs -# host: ${{ secrets.HOST }} -# username: ${{ secrets.USERNAME }} -# key: ${{ secrets.KEY }} -# port: ${{ secrets.PORT }} -# script: | -# cd nodbot # we move into our app's folder -# git pull # we pull any changes from git -# npm prune # we remove any unused dependencies -# npm install # we install any missing dependencies -# pm2 reload nodbot # we reload the app via PM2 From 3ef9a1670d04a2b73fb21159640e6aa335fb485c Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 13:03:47 -0500 Subject: [PATCH 23/34] New docker build integration --- .github/workflows/docker-image.yaml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/docker-image.yaml diff --git a/.github/workflows/docker-image.yaml b/.github/workflows/docker-image.yaml new file mode 100644 index 0000000..389ffd4 --- /dev/null +++ b/.github/workflows/docker-image.yaml @@ -0,0 +1,26 @@ +name: Docker Image CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +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 \ No newline at end of file From 93f78a087a86d491be0030a0f837ff161efaae06 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 13:09:14 -0500 Subject: [PATCH 24/34] Update TenorJS version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 80f6a6a..b025877 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "dotenv": "^10.0.0", "fuzzy-search": "^3.2.1", "mysql": "^2.18.1", - "tenorjs": "^1.0.8" + "tenorjs": "^1.0.10" }, "engines": { "node": "16.x" From 6872397c58c3b6e7d079c3cd1a5881c6fc507cb9 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 13:16:54 -0500 Subject: [PATCH 25/34] Modified workflow for dev environment --- .github/workflows/docker-image.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 76eb4f4..d5fc425 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -2,9 +2,9 @@ name: Docker Image CI on: push: - branches: [ "main" ] + branches: [ "3.0.1-dev" ] pull_request: - branches: [ "main" ] + branches: [ "3.0.1-dev" ] env: DHUB_UNAME: ${{ secrets.DHUB_UNAME }} @@ -19,8 +19,8 @@ jobs: steps: - uses: actions/checkout@v3 - name: Build the Docker image - run: docker build . --file Dockerfile --tag v0idf1sh/nodbot + run: docker build . --file Dockerfile --tag v0idf1sh/nodbot-dev - 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 + run: docker push v0idf1sh/nodbot-dev From 7bc2d388021b679da50416c9224855f00e58011e Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 13:46:26 -0500 Subject: [PATCH 26/34] Migrate from TenorJS to axios --- dot-commands/gif.js | 39 +++++++++++++++++++++++++-------------- package.json | 4 ++-- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/dot-commands/gif.js b/dot-commands/gif.js index 03ea658..c7dedd7 100644 --- a/dot-commands/gif.js +++ b/dot-commands/gif.js @@ -1,11 +1,6 @@ const fn = require('../functions'); -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", // Your locale here, case-sensitivity depends on input - "MediaFilter": "minimal", // either minimal or basic, not case sensitive - "DateFormat": "D/MM/YYYY - H:mm:ss A" // Change this accordingly -}); +const axios = require('axios'); +const dotenv = require('dotenv').config(); // TODO: Tenor has changed API versions, switch from TenorJS (unmaintained) to axios for // general API usage. See: https://github.com/Jinzulen/TenorJS/issues/12 @@ -15,21 +10,37 @@ module.exports = { name: 'gif', description: 'Send a GIF', usage: '.gif', - execute(message, commandData) { + async execute(message, commandData) { // if (message.deletable) message.delete(); const client = message.client; if (!client.gifs.has(commandData.args)) { - tenor.Search.Query(commandData.args, 1).then(res => { - if (res[0] == undefined) { + if (process.env.isDev) console.log('https://tenor.googleapis.com/v2/search?' + `&q=${commandData.args}` + `&key=${process.env.tenorAPIKey}` + '&limit=1&contentfilter=off'); + const q = await axios.get( + 'https://tenor.googleapis.com/v2/search?' + + `&q=${commandData.args}` + + `&key=${process.env.tenorAPIKey}` + + '&limit=1' + + `&contentfilter=off` + ).then(res => { + if (process.env.isDev) console.log(res.data.results); + if (res.data.results[0] == undefined) { message.reply('Sorry I was unable to find a GIF of ' + commandData.args); return; }; - commandData.embed_url = res[0].media[0].gif.url; - // message.reply(fn.embeds.gif(commandData)); - // message.channel.send(`> ${commandData.author} - ${commandData.args}.gif`); - // message.channel.send(commandData.embed_url); + commandData.embed_url = res.data.results[0].url; message.reply(commandData.embed_url); }).catch(err => console.error(err)); + // tenor.Search.Query(commandData.args, "1").then(res => { + // if (res[0] == undefined) { + // message.reply('Sorry I was unable to find a GIF of ' + commandData.args); + // return; + // }; + // commandData.embed_url = res[0].media[0].gif.url; + // // message.reply(fn.embeds.gif(commandData)); + // // message.channel.send(`> ${commandData.author} - ${commandData.args}.gif`); + // // message.channel.send(commandData.embed_url); + // message.reply(commandData.embed_url); + // }).catch(err => console.error(err)); } else { // message.reply(commandData.args + ' requested by ' + message.author.username + '\n' + client.gifs.get(commandData.args).embed_url); commandData.embed_url = client.gifs.get(commandData.args).embed_url; diff --git a/package.json b/package.json index 87f9215..7e600d7 100644 --- a/package.json +++ b/package.json @@ -6,13 +6,13 @@ "dependencies": { "@discordjs/builders": "^0.6.0", "@discordjs/rest": "^0.1.0-canary.0", - "axios": "^0.21.1", + "axios": "^0.21.4", "discord-api-types": "^0.22.0", "discord.js": "^13.1.0", "dotenv": "^10.0.0", "fuzzy-search": "^3.2.1", "mysql": "^2.18.1", - "tenorjs": "^1.0.8" + "tenorjs": "^1.0.10" }, "engines": { "node": "16.x" From ed18e4e1fc007279448e02604f3e7533f5542992 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 14:26:29 -0500 Subject: [PATCH 27/34] Fixed file extension --- .github/workflows/{docker-image.yaml => docker-image.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{docker-image.yaml => docker-image.yml} (100%) diff --git a/.github/workflows/docker-image.yaml b/.github/workflows/docker-image.yml similarity index 100% rename from .github/workflows/docker-image.yaml rename to .github/workflows/docker-image.yml From f1965dde3634a23370e64c64f241c83b97c38950 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 14:28:51 -0500 Subject: [PATCH 28/34] Fixed workflow to work on main --- .github/workflows/docker-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 32dac97..19fef23 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -2,9 +2,9 @@ name: Docker Image CI on: push: - branches: [ "3.0.1-dev" ] + branches: [ "main" ] pull_request: - branches: [ "3.0.1-dev" ] + branches: [ "main" ] env: DHUB_UNAME: ${{ secrets.DHUB_UNAME }} From 43ae94b5c0e9501a9d5249d9d94204df191053d1 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 14:31:15 -0500 Subject: [PATCH 29/34] Fixed workflow to build the correct prod tag --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 19fef23..389ffd4 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -19,7 +19,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Build the Docker image - run: docker build . --file Dockerfile --tag v0idf1sh/nodbot-dev + 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 From 7c1c788b3a4b3e6a144a8ab99fa3a2203d5c69b5 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 15:18:38 -0500 Subject: [PATCH 30/34] Update startup message to ping owner --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index 6ea0a28..61716ef 100644 --- a/main.js +++ b/main.js @@ -41,7 +41,7 @@ client.once('ready', () => { fn.download.strains(client); console.log('Ready!'); client.channels.fetch(statusChannelId).then(channel => { - channel.send(`I'm ready! ${new Date().toISOString()}`); + channel.send(`<@${process.env.ownerId}> I'm ready! ${new Date().toISOString()}`); }); }); From c01a5d85dde028c39c9982133843e3a5b8b97c23 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 15:20:06 -0500 Subject: [PATCH 31/34] Cooler ready message --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index 61716ef..dddcd5d 100644 --- a/main.js +++ b/main.js @@ -41,7 +41,7 @@ client.once('ready', () => { fn.download.strains(client); console.log('Ready!'); client.channels.fetch(statusChannelId).then(channel => { - channel.send(`<@${process.env.ownerId}> I'm ready! ${new Date().toISOString()}`); + channel.send(`${new Date().toISOString()} -- <@${process.env.ownerId}>\nNodding Activated.`); }); }); From 7a735fdf445a9d4063ca2deb20c8bd6240f2b842 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 15:35:23 -0500 Subject: [PATCH 32/34] newerer start message --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index dddcd5d..88f1541 100644 --- a/main.js +++ b/main.js @@ -41,7 +41,7 @@ client.once('ready', () => { fn.download.strains(client); console.log('Ready!'); client.channels.fetch(statusChannelId).then(channel => { - channel.send(`${new Date().toISOString()} -- <@${process.env.ownerId}>\nNodding Activated.`); + channel.send(`${new Date().toISOString()} -- <@${process.env.ownerId}>\nStartup Sequence Complete`); }); }); From 1854ab839773d29b75d3a392ab5c6e48c031f807 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 15:44:08 -0500 Subject: [PATCH 33/34] . --- functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions.js b/functions.js index 1cea7cc..b5f2c97 100644 --- a/functions.js +++ b/functions.js @@ -332,7 +332,7 @@ const functions = { }, { name: 'Rating', - value: `${strainInfo.rating}⭐️`, + value: `${strainInfo.rating}⭐️s`, inline: true, }, { From f62538ee0c7cdf05ac6aa567bfa409e17ef24b40 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 2 Dec 2022 15:45:27 -0500 Subject: [PATCH 34/34] FUCK --- functions.js | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/functions.js b/functions.js index 077abd4..b5f2c97 100644 --- a/functions.js +++ b/functions.js @@ -61,7 +61,7 @@ const functions = { } } - if (isDev) console.log('Valid Commands Added to Config'); + if (isDev) console.log(`Valid Commands Added to Config\n${config.validCommands}`); }, dotCommands(client) { if (!client.dotCommands) client.dotCommands = new Discord.Collection(); @@ -133,9 +133,10 @@ const functions = { for (const row of rows) { const strain = { id: row.id, - name: row.name, + name: row.strain, }; client.strains.set(strain.name, strain); + // if (isDev) console.log(strain) } if (isDev) console.log('Strains Collection Built'); } @@ -145,6 +146,7 @@ const functions = { const commandData = {}; // Split the message content at the final instance of a period const finalPeriod = message.content.lastIndexOf('.'); + if(isDev) console.log(message.content); // If the final period is the last character, or doesn't exist if (finalPeriod < 0) { if (isDev) console.log(finalPeriod); @@ -310,7 +312,8 @@ const functions = { strainEmbed.addFields([ { name: 'Strain Name', - value: `${strainInfo.name}`, + value: `${strainInfo.strain}`, + inline: true, }, { name: 'Type', @@ -323,8 +326,8 @@ const functions = { inline: true, }, { - name: 'Treats', - value: `${strainInfo.ailments}`, + name: 'Flavor', + value: `${strainInfo.flavor}`, inline: true, }, { @@ -332,6 +335,11 @@ const functions = { value: `${strainInfo.rating}⭐️s`, inline: true, }, + { + name: 'Description', + value: `${strainInfo.description}`, + inline: false, + }, ]); message.reply({ embeds: [ strainEmbed ]}); @@ -439,23 +447,25 @@ const functions = { }, strain(commandData, message) { const { strainName } = commandData; - const query = `SELECT id, name, type, effects, ailment, flavor FROM strains WHERE name = ${db.escape(strainName)}`; + const query = `SELECT id, strain, type, effects, description, flavor, rating FROM strains WHERE strain = ${db.escape(strainName)}`; db.query(query, (err, rows, fields) => { + if (err) throw err; if (rows != undefined) { commandData.strainInfo = { id: `${rows[0].id}`, - name: `${rows[0].name}`, + strain: `${rows[0].strain}`, type: `${rows[0].type}`, effects: `${rows[0].effects}`, - ailments: `${rows[0].ailment}`, + description: `${rows[0].description}`, flavor: `${rows[0].flavor}`, + rating: `${rows[0].rating}`, }; functions.embeds.strain(commandData, message); } }); }, strains(client) { - const query = 'SELECT id, name FROM strains'; + const query = 'SELECT id, strain FROM strains'; db.query(query, (err, rows, fields) => { if (err) throw err; functions.collections.strains(rows, client);