Merge pull request #1838 from shikhir-arora/1.9

Allow for optional "url" field for embed title [clickable]
This commit is contained in:
Master Kwoth 2017-11-17 02:45:38 +01:00 committed by GitHub
commit 1e606c246e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -1,4 +1,4 @@
using System; using System;
using Discord; using Discord;
using NadekoBot.Extensions; using NadekoBot.Extensions;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -12,6 +12,7 @@ namespace NadekoBot.Common
public string PlainText { get; set; } public string PlainText { get; set; }
public string Title { get; set; } public string Title { get; set; }
public string Description { get; set; } public string Description { get; set; }
public string url { get; set; }
public CREmbedFooter Footer { get; set; } public CREmbedFooter Footer { get; set; }
public string Thumbnail { get; set; } public string Thumbnail { get; set; }
public string Image { get; set; } public string Image { get; set; }
@ -26,6 +27,7 @@ namespace NadekoBot.Common
public bool IsValid => public bool IsValid =>
!string.IsNullOrWhiteSpace(Title) || !string.IsNullOrWhiteSpace(Title) ||
!string.IsNullOrWhiteSpace(Description) || !string.IsNullOrWhiteSpace(Description) ||
!string.IsNullOrWhiteSpace(url) ||
!string.IsNullOrWhiteSpace(Thumbnail) || !string.IsNullOrWhiteSpace(Thumbnail) ||
!string.IsNullOrWhiteSpace(Image) || !string.IsNullOrWhiteSpace(Image) ||
(Footer != null && (!string.IsNullOrWhiteSpace(Footer.Text) || !string.IsNullOrWhiteSpace(Footer.IconUrl))) || (Footer != null && (!string.IsNullOrWhiteSpace(Footer.Text) || !string.IsNullOrWhiteSpace(Footer.IconUrl))) ||
@ -39,6 +41,8 @@ namespace NadekoBot.Common
embed.WithTitle(Title); embed.WithTitle(Title);
if (!string.IsNullOrWhiteSpace(Description)) if (!string.IsNullOrWhiteSpace(Description))
embed.WithDescription(Description); embed.WithDescription(Description);
if (url != null && Uri.IsWellFormedUriString(url, UriKind.Absolute))
embed.WithUrl(url);
embed.WithColor(new Discord.Color(Color)); embed.WithColor(new Discord.Color(Color));
if (Footer != null) if (Footer != null)
embed.WithFooter(efb => embed.WithFooter(efb =>

View File

@ -1,4 +1,4 @@
using Discord; using Discord;
using Discord.Commands; using Discord.Commands;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using NadekoBot.Extensions; using NadekoBot.Extensions;