Embed field names and values will be trimmed to their acceptable length to prevent errors. closes #1355

This commit is contained in:
Master Kwoth 2017-07-08 14:20:06 +02:00
parent 72e7b04319
commit aa01314b3a
4 changed files with 11 additions and 3 deletions

View File

@ -1,4 +1,5 @@
using Discord;
using NadekoBot.Extensions;
using Newtonsoft.Json;
using NLog;
using System;
@ -72,6 +73,12 @@ namespace NadekoBot.DataStructures
{
var crembed = JsonConvert.DeserializeObject<CREmbed>(input);
if(crembed.Fields != null && crembed.Fields.Length > 0)
foreach (var f in crembed.Fields)
{
f.Name = f.Name.TrimTo(256);
f.Value = f.Value.TrimTo(1024);
}
if (!crembed.IsValid)
return false;

View File

@ -79,7 +79,7 @@ namespace NadekoBot.Modules.CustomReactions
.WithTitle(GetText("new_cust_react"))
.WithDescription($"#{cr.Id}")
.AddField(efb => efb.WithName(GetText("trigger")).WithValue(key))
.AddField(efb => efb.WithName(GetText("response")).WithValue(message))
.AddField(efb => efb.WithName(GetText("response")).WithValue(message.Length > 1024 ? GetText("redacted_too_long") : message))
).ConfigureAwait(false);
}

View File

@ -33,7 +33,7 @@ namespace NadekoBot.Modules.Searches
[NadekoCommand, Usage, Description, Aliases]
public async Task Lolban()
{
const int showCount = 8;
//const int showCount = 8;
//http://api.champion.gg/stats/champs/mostBanned?api_key=YOUR_API_TOKEN&page=1&limit=2
try
{

View File

@ -35,6 +35,7 @@
"customreactions_stats_cleared": "Stats cleared for {0} custom reaction.",
"customreactions_stats_not_found": "No stats for that trigger found, no action taken.",
"customreactions_trigger": "Trigger",
"customreactions_redacted_too_long": "Redecated because it's too long.",
"nsfw_autohentai_stopped": "Autohentai stopped.",
"nsfw_not_found": "No results found.",
"pokemon_already_fainted": "{0} has already fainted.",