From 0d663b444c5ed61ef77bdc9c53e9bf099ea9a6b8 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 11 Jan 2025 08:45:26 -0500 Subject: [PATCH 1/5] Versioning --- CHANGELOG.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34b3e20..a89fa08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ ## v3.4.x +#### v3.4.1 +* Adding command to change nicknames + #### v3.4.0 (#25) * Added nested commands, enclose a command in brackets, braces, or parenthesis inside a longer message: `You really don't get it do you? [that's the joke.gif] You're so dense` would return the results for just `that's the joke.gif` * Improved the `/save gifsearch` interface and the code behind the scenes diff --git a/package.json b/package.json index ed51b46..558e5f5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodbot", - "version": "3.4.0", + "version": "3.4.1", "description": "Nods and Nod Accessories", "main": "main.js", "dependencies": { -- 2.45.2 From 232a8ebc21b2606c741eefddde147044ca322bac Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 11 Jan 2025 09:41:57 -0500 Subject: [PATCH 2/5] /setnick working --- functions.js | 9 +++++++++ slash-commands/setnick.js | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 slash-commands/setnick.js diff --git a/functions.js b/functions.js index 8f74288..01466b5 100644 --- a/functions.js +++ b/functions.js @@ -662,6 +662,15 @@ const functions = { return newText + ' <:spongebob:1053398825965985822>'; }, + setNick(user, nickname) { + return new Promise((resolve, reject) => { + user.setNickname(nickname).then(() => { + resolve('Nickname set.'); + }).catch(err => { + reject(err); + }); + }); + }, autoresponses: { // Specific responses for certain keywords in sent messages checkForAll(messageContent) { let responses = []; diff --git a/slash-commands/setnick.js b/slash-commands/setnick.js new file mode 100644 index 0000000..f778c9a --- /dev/null +++ b/slash-commands/setnick.js @@ -0,0 +1,36 @@ +const { SlashCommandBuilder } = require('@discordjs/builders'); +const fn = require('../functions.js'); + +module.exports = { + data: new SlashCommandBuilder() + .setName('setnick') + .setDescription('Set a user\'s nickname.') + .addUserOption(o => + o.setName('user') + .setDescription('The user to set the nickname for.') + .setRequired(true) + ) + .addStringOption(o => + o.setName('nickname') + .setDescription('The nickname to set.') + .setRequired(true) + ), + async execute(interaction) { + try { + // Defer the reply, with ephemeral set to true + await interaction.deferReply({ ephemeral: true }); + // Get the user and nickname from the interaction + const user = interaction.options.getMember('user'); + const nickname = interaction.options.getString('nickname'); + + // Set the nickname + await fn.setNick(user, nickname); + + // Reply to the interaction + await interaction.editReply(`Successfully set ${user}'s nickname to ${nickname}`); + } catch (error) { + console.error(error); + await interaction.editReply('There was an error while executing this command!'); + } + }, +}; \ No newline at end of file -- 2.45.2 From 6fad8c6cdc3eeb35aa39363b68bb8f3867f9575f Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 11 Jan 2025 09:48:44 -0500 Subject: [PATCH 3/5] Update workflow to remove the repo before cloning so every deploy is fresh --- .gitea/workflows/production-docker.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitea/workflows/production-docker.yml b/.gitea/workflows/production-docker.yml index f76f0e6..8ddd00a 100644 --- a/.gitea/workflows/production-docker.yml +++ b/.gitea/workflows/production-docker.yml @@ -24,6 +24,8 @@ jobs: git clone https://git.vfsh.dev/voidf1sh/nodbot cd nodbot else + rm -rf nodbot + git clone https://git.vfsh.dev/voidf1sh/nodbot cd nodbot git pull fi -- 2.45.2 From 8878ac76e883896db49b63d10e219224b725f041 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 11 Jan 2025 11:02:39 -0500 Subject: [PATCH 4/5] Add some custom error messages for perms and length of nick --- slash-commands/setnick.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/slash-commands/setnick.js b/slash-commands/setnick.js index f778c9a..f86b713 100644 --- a/slash-commands/setnick.js +++ b/slash-commands/setnick.js @@ -30,6 +30,12 @@ module.exports = { await interaction.editReply(`Successfully set ${user}'s nickname to ${nickname}`); } catch (error) { console.error(error); + if (error.code === 50013) { + return await interaction.editReply('I do not have permission to set the nickname of that user!'); + } + if (error.code === 50035) { + return await interaction.editReply('The nickname is too long!'); + } await interaction.editReply('There was an error while executing this command!'); } }, -- 2.45.2 From 1b77a24fb742ba41617a404444ea3a0a4af44cee Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 11 Jan 2025 11:03:56 -0500 Subject: [PATCH 5/5] Branch/Tag fix for prod workflow --- .gitea/workflows/production-docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/production-docker.yml b/.gitea/workflows/production-docker.yml index 8ddd00a..c405566 100644 --- a/.gitea/workflows/production-docker.yml +++ b/.gitea/workflows/production-docker.yml @@ -15,7 +15,7 @@ jobs: steps: - name: Pull latest from Git run: | - echo "Branch: tags/${{ gitea.ref_name }}" + echo "Branch: ${{ gitea.ref_name }}" pwd whoami mkdir -p /var/lib/act_runner/ @@ -29,7 +29,7 @@ jobs: cd nodbot git pull fi - git checkout tags/${{ gitea.ref_name }} + git checkout ${{ gitea.ref_name }} - name: Build the Docker image run: | cd /var/lib/act_runner/nodbot -- 2.45.2