Limit string argument length to avoid "embed description too long" errors (#174)

This PR fixes an error that would appear if a string that's way too long
was passed as a command argument by limiting the string's length

![image](https://github.com/LabsDevelopment/Octobot/assets/61277953/8f8267fd-d382-4a24-b92d-5f9966d7563b)
This commit is contained in:
Octol1ttle 2023-10-28 23:10:16 +05:00 committed by GitHub
parent cf7007f269
commit 0ba357e4c7
Signed by: GitHub
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 7 deletions

View file

@ -1,4 +1,5 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Text;
using JetBrains.Annotations;
using Octobot.Data;
@ -69,7 +70,8 @@ public class MuteCommandGroup : CommandGroup
[UsedImplicitly]
public async Task<Result> ExecuteMute(
[Description("Member to mute")] IUser target,
[Description("Mute reason")] string reason,
[Description("Mute reason")] [MaxLength(256)]
string reason,
[Description("Mute duration")] TimeSpan duration)
{
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var executorId))
@ -233,7 +235,8 @@ public class MuteCommandGroup : CommandGroup
[UsedImplicitly]
public async Task<Result> ExecuteUnmute(
[Description("Member to unmute")] IUser target,
[Description("Unmute reason")] string reason)
[Description("Unmute reason")] [MaxLength(256)]
string reason)
{
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var executorId))
{