mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-01-31 09:09:00 +03:00
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:
parent
cf7007f269
commit
0ba357e4c7
5 changed files with 19 additions and 7 deletions
|
@ -1,4 +1,5 @@
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Octobot.Data;
|
using Octobot.Data;
|
||||||
|
@ -72,7 +73,8 @@ public class BanCommandGroup : CommandGroup
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public async Task<Result> ExecuteBanAsync(
|
public async Task<Result> ExecuteBanAsync(
|
||||||
[Description("User to ban")] IUser target,
|
[Description("User to ban")] IUser target,
|
||||||
[Description("Ban reason")] string reason,
|
[Description("Ban reason")] [MaxLength(256)]
|
||||||
|
string reason,
|
||||||
[Description("Ban duration")] TimeSpan? duration = null)
|
[Description("Ban duration")] TimeSpan? duration = null)
|
||||||
{
|
{
|
||||||
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var executorId))
|
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var executorId))
|
||||||
|
@ -216,7 +218,8 @@ public class BanCommandGroup : CommandGroup
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public async Task<Result> ExecuteUnban(
|
public async Task<Result> ExecuteUnban(
|
||||||
[Description("User to unban")] IUser target,
|
[Description("User to unban")] IUser target,
|
||||||
[Description("Unban reason")] string reason)
|
[Description("Unban reason")] [MaxLength(256)]
|
||||||
|
string reason)
|
||||||
{
|
{
|
||||||
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var executorId))
|
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var executorId))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Octobot.Data;
|
using Octobot.Data;
|
||||||
using Octobot.Extensions;
|
using Octobot.Extensions;
|
||||||
|
@ -67,7 +68,8 @@ public class KickCommandGroup : CommandGroup
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public async Task<Result> ExecuteKick(
|
public async Task<Result> ExecuteKick(
|
||||||
[Description("Member to kick")] IUser target,
|
[Description("Member to kick")] IUser target,
|
||||||
[Description("Kick reason")] string reason)
|
[Description("Kick reason")] [MaxLength(256)]
|
||||||
|
string reason)
|
||||||
{
|
{
|
||||||
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var executorId))
|
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var executorId))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Octobot.Data;
|
using Octobot.Data;
|
||||||
|
@ -69,7 +70,8 @@ public class MuteCommandGroup : CommandGroup
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public async Task<Result> ExecuteMute(
|
public async Task<Result> ExecuteMute(
|
||||||
[Description("Member to mute")] IUser target,
|
[Description("Member to mute")] IUser target,
|
||||||
[Description("Mute reason")] string reason,
|
[Description("Mute reason")] [MaxLength(256)]
|
||||||
|
string reason,
|
||||||
[Description("Mute duration")] TimeSpan duration)
|
[Description("Mute duration")] TimeSpan duration)
|
||||||
{
|
{
|
||||||
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var executorId))
|
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var executorId))
|
||||||
|
@ -233,7 +235,8 @@ public class MuteCommandGroup : CommandGroup
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public async Task<Result> ExecuteUnmute(
|
public async Task<Result> ExecuteUnmute(
|
||||||
[Description("Member to unmute")] IUser target,
|
[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))
|
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var executorId))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Octobot.Data;
|
using Octobot.Data;
|
||||||
|
@ -119,7 +120,8 @@ public class RemindCommandGroup : CommandGroup
|
||||||
public async Task<Result> ExecuteReminderAsync(
|
public async Task<Result> ExecuteReminderAsync(
|
||||||
[Description("After what period of time mention the reminder")]
|
[Description("After what period of time mention the reminder")]
|
||||||
TimeSpan @in,
|
TimeSpan @in,
|
||||||
[Description("Reminder text")] string text)
|
[Description("Reminder text")] [MaxLength(512)]
|
||||||
|
string text)
|
||||||
{
|
{
|
||||||
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var executorId))
|
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var executorId))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
@ -167,7 +168,8 @@ public class SettingsCommandGroup : CommandGroup
|
||||||
public async Task<Result> ExecuteEditSettingsAsync(
|
public async Task<Result> ExecuteEditSettingsAsync(
|
||||||
[Description("The setting whose value you want to change")]
|
[Description("The setting whose value you want to change")]
|
||||||
AllOptionsEnum setting,
|
AllOptionsEnum setting,
|
||||||
[Description("Setting value")] string value)
|
[Description("Setting value")] [MaxLength(512)]
|
||||||
|
string value)
|
||||||
{
|
{
|
||||||
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var executorId))
|
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var executorId))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue