From 3542ddcf819c51a1d7ad8b10ca48752522e77e59 Mon Sep 17 00:00:00 2001 From: Taken Date: Sat, 25 Nov 2023 17:38:33 +0100 Subject: [PATCH] Finished timeout command --- package-lock.json | 30 ++++++++++++++++++++++++++++-- package.json | 5 +++-- src/commands/timeout.js | 7 ++++--- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 857c839..153fa91 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,14 +7,15 @@ "": { "name": "illegitimate-bot", "version": "1.0.0", - "license": "ISC", + "license": "GPL-3.0-only", "dependencies": { "axios": "^1.3.4", "discord.js": "^14.8.0", "dotenv": "^16.0.3", "log-beautify": "^1.2.0", "mongoose": "^7.0.1", - "ms": "^2.1.3" + "ms": "^2.1.3", + "pretty-ms": "^8.0.0" } }, "node_modules/@discordjs/builders": { @@ -553,6 +554,31 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" }, + "node_modules/parse-ms": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/parse-ms/-/parse-ms-3.0.0.tgz", + "integrity": "sha512-Tpb8Z7r7XbbtBTrM9UhpkzzaMrqA2VXMT3YChzYltwV3P3pM6t8wl7TvpMnSTosz1aQAdVib7kdoys7vYOPerw==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/pretty-ms": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-8.0.0.tgz", + "integrity": "sha512-ASJqOugUF1bbzI35STMBUpZqdfYKlJugy6JBziGi2EE+AL5JPJGSzvpeVXojxrr0ViUYoToUjb5kjSEGf7Y83Q==", + "dependencies": { + "parse-ms": "^3.0.0" + }, + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/proxy-from-env": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", diff --git a/package.json b/package.json index 0d9b4e4..8001be7 100644 --- a/package.json +++ b/package.json @@ -10,13 +10,14 @@ "prod:build:user": "node scripts/deploy-commands.js --dev" }, "author": "Taken", - "license": "ISC", + "license": "GPL-3.0-only", "dependencies": { "axios": "^1.3.4", "discord.js": "^14.8.0", "dotenv": "^16.0.3", "log-beautify": "^1.2.0", "mongoose": "^7.0.1", - "ms": "^2.1.3" + "ms": "^2.1.3", + "pretty-ms": "^8.0.0" } } diff --git a/src/commands/timeout.js b/src/commands/timeout.js index 03fb0e8..d7b4a31 100644 --- a/src/commands/timeout.js +++ b/src/commands/timeout.js @@ -6,7 +6,6 @@ module.exports = { name: "timeout", description: "Times out a memeber", type: "slash", - dev: true, data: new SlashCommandBuilder() .setName("timeout") @@ -34,11 +33,13 @@ module.exports = { await interaction.deferReply() + const { default: prettyms } = await import("pretty-ms") const target1 = interaction.options.getUser("user") const target = interaction.guild.members.cache.get(target1.id) const timeString = interaction.options.getString("time") const reason = interaction.options.getString("reason") || "No reason provided" const time = ms(timeString) + const prettyTime = prettyms(time, { verbose: true }) const embedColor = Number(color.replace("#", "0x")) if (target.bot) { @@ -111,7 +112,7 @@ module.exports = { await target.timeout(time, reason) await interaction.editReply({ embeds: [{ - description: "Updated timeout of " + userMention(target.id) + " to " + timeString + " for " + reason, + description: "Updated timeout of " + userMention(target.id) + " to " + prettyTime + " for " + reason, color: embedColor, footer: { text: "ID: " + target.id, @@ -126,7 +127,7 @@ module.exports = { await target.timeout(time, reason) await interaction.editReply({ embeds: [{ - description: "Timed out " + userMention(target.id) + " for " + timeString + " for " + reason, + description: "Timed out " + userMention(target.id) + " for " + prettyTime + " for " + reason, color: embedColor, footer: { text: "ID: " + target.id,