[Fix] GetEventCoverImageUrl throwing NRE in case event cover image is null (#2818)
* return null instead of throwing NRE * fix xmldoc
This commit is contained in:
@@ -223,7 +223,7 @@ namespace Discord
|
|||||||
=> $"{DiscordConfig.CDNUrl}stickers/{stickerId}.{FormatToExtension(format)}";
|
=> $"{DiscordConfig.CDNUrl}stickers/{stickerId}.{FormatToExtension(format)}";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns an events cover image url.
|
/// Returns an events cover image url. <see langword="null"/> if the assetId <see langword="null"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="guildId">The guild id that the event is in.</param>
|
/// <param name="guildId">The guild id that the event is in.</param>
|
||||||
/// <param name="eventId">The id of the event.</param>
|
/// <param name="eventId">The id of the event.</param>
|
||||||
@@ -232,7 +232,9 @@ namespace Discord
|
|||||||
/// <param name="size">The size of the image.</param>
|
/// <param name="size">The size of the image.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static string GetEventCoverImageUrl(ulong guildId, ulong eventId, string assetId, ImageFormat format = ImageFormat.Auto, ushort size = 1024)
|
public static string GetEventCoverImageUrl(ulong guildId, ulong eventId, string assetId, ImageFormat format = ImageFormat.Auto, ushort size = 1024)
|
||||||
=> $"{DiscordConfig.CDNUrl}guild-events/{eventId}/{assetId}.{FormatToExtension(format, assetId)}?size={size}";
|
=> string.IsNullOrEmpty(assetId)
|
||||||
|
? null
|
||||||
|
: $"{DiscordConfig.CDNUrl}guild-events/{eventId}/{assetId}.{FormatToExtension(format, assetId)}?size={size}";
|
||||||
|
|
||||||
private static string FormatToExtension(StickerFormatType format)
|
private static string FormatToExtension(StickerFormatType format)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ namespace Discord.Rest
|
|||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string GetCoverImageUrl(ImageFormat format = ImageFormat.Auto, ushort size = 1024)
|
public string GetCoverImageUrl(ImageFormat format = ImageFormat.Auto, ushort size = 1024)
|
||||||
=> CDN.GetEventCoverImageUrl(Guild.Id, Id, CoverImageId, format, size);
|
=> CDN.GetEventCoverImageUrl(GuildId, Id, CoverImageId, format, size);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public Task StartAsync(RequestOptions options = null)
|
public Task StartAsync(RequestOptions options = null)
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ namespace Discord.WebSocket
|
|||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string GetCoverImageUrl(ImageFormat format = ImageFormat.Auto, ushort size = 1024)
|
public string GetCoverImageUrl(ImageFormat format = ImageFormat.Auto, ushort size = 1024)
|
||||||
=> CDN.GetEventCoverImageUrl(Guild.Id, Id, CoverImageId, format, size);
|
=> CDN.GetEventCoverImageUrl(GuildId, Id, CoverImageId, format, size);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public Task DeleteAsync(RequestOptions options = null)
|
public Task DeleteAsync(RequestOptions options = null)
|
||||||
|
|||||||
Reference in New Issue
Block a user