diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ff4af24..b41a923 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -32,6 +32,9 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Add version.txt + run: git describe --tags --abbrev=0 > version.txt + - name: Build and push uses: docker/build-push-action@v2 with: diff --git a/.gitignore b/.gitignore index fd09255..fad8d35 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .vscode +version.txt # Logs logs diff --git a/README.md b/README.md index a2fa92d..e128760 100644 --- a/README.md +++ b/README.md @@ -67,4 +67,7 @@ Update packages `npm update` Better way to update packages (Will tell you about any new versions, including major) -`npx npm-check-updates` provide `-u` for the program to update them itself \ No newline at end of file +`npx npm-check-updates` provide `-u` for the program to update them itself + +Get current Junior version +`git describe --tags --abbrev=0 > version.txt` \ No newline at end of file diff --git a/commands/version.js b/commands/version.js new file mode 100644 index 0000000..f66e527 --- /dev/null +++ b/commands/version.js @@ -0,0 +1,24 @@ +const { SlashCommandBuilder } = require('@discordjs/builders'); +const fs = require('fs'); + +module.exports = { + data: new SlashCommandBuilder() + .setName('version') + .setDescription('Replies with Junior\'s current version.'), + async execute(interaction) { + fs.readFile('version.txt', 'utf8', (err, data) => { + if (err) { + console.error(err); + return interaction.reply({ + content: 'Error, version unknown.', + ephemeral: true + }); + } + + return interaction.reply({ + content: 'v' + data, + ephemeral: true + }); + }); + }, +}; \ No newline at end of file