From d8753a8c1fed1264388c99b63a5f0b7586410ac6 Mon Sep 17 00:00:00 2001 From: moonleay Date: Tue, 19 Dec 2023 10:59:31 +0100 Subject: [PATCH] fix: updated Error messages to better fit the HTTP standard Signed-off-by: moonleay --- .../extensions/FeatureManageExtension.kt | 2 +- .../extensions/SendPlannerExtension.kt | 22 +++++++++++++++++-- .../extensions/UpdateRolesExtension.kt | 4 ++-- .../moonleay/lilJudd/features/TimeManager.kt | 12 +++++----- 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/FeatureManageExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/FeatureManageExtension.kt index ef1c52a..21e7bec 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/FeatureManageExtension.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/FeatureManageExtension.kt @@ -51,7 +51,7 @@ class FeatureManageExtension : Extension() { this.respond { this.embed { this.color = EmbedColor.ERROR.color - this.title = "403: Forbidden" + this.title = "401: Not Authorized" this.description = "You cannot edit features, as you don't have the Administrator permission." this.footer { diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt index 87a6abb..acd59f4 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt @@ -49,13 +49,31 @@ class SendPlannerExtension : Extension() { .hasPermission(Permission.Administrator) ) { val res = this.respond { - this.content = "You need to be an administrator to use this command." + this.embed { + this.color = EmbedColor.ERROR.color + this.title = "401: Not Authorized" + this.description = + "You need the Administrator permission to use this command." + this.footer { + this.icon = user.asUser().avatar?.cdnUrl?.toUrl() + this.text = MessageUtil.getFooter(user) + } + } } res.delete() return@action } val res = this.respond { - this.content = "OK." + this.embed { + this.color = EmbedColor.INFO.color + this.title = "200: Success" + this.description = "Sending the planner.\n" + + "This may take a while, please be patient." + this.footer { + this.icon = user.asUser().avatar?.cdnUrl?.toUrl() + this.text = MessageUtil.getFooter(user) + } + } } res.delete() // Delete the response val c = this.getChannel().asChannel() diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/UpdateRolesExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/UpdateRolesExtension.kt index 8d8e986..1d0ad06 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/UpdateRolesExtension.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/UpdateRolesExtension.kt @@ -44,9 +44,9 @@ class UpdateRolesExtension : Extension() { this.respond { this.embed { this.color = EmbedColor.ERROR.color - this.title = "403: Forbidden" + this.title = "401: Not Authorized" this.description = - "You cannot update roles, as you don't have the Administrator permission." + "You need the Administrator permission to use this command." this.footer { this.icon = user.asUser().avatar?.cdnUrl?.toUrl() this.text = MessageUtil.getFooter(user) diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt b/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt index 87018df..a9cc7be 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt @@ -166,14 +166,14 @@ object TimeManager : IFeature { EmbedColor.SUCCESS, "200: Success", "The feature was enabled in channel ${args.channel.data.name.value}", - u.asUser().username + "#" + u.asUser().discriminator + u.asUser().username ) } return MessageUtil.getEmbed( EmbedColor.ERROR, - "403: Forbidden", + "409: Conflict", "The feature is already enabled in this channel.", - u.asUser().username + "#" + u.asUser().discriminator + u.asUser().username ) } @@ -192,15 +192,15 @@ object TimeManager : IFeature { EmbedColor.SUCCESS, "200: Success", "The feature was disabled.", - u.asUser().username + "#" + u.asUser().discriminator + u.asUser().username ) } // Do nothing; not in db return MessageUtil.getEmbed( EmbedColor.ERROR, - "403: Forbidden", + "409: Conflict", "The feature is already disabled in this channel.", - u.asUser().username + "#" + u.asUser().discriminator + u.asUser().username ) } }