@@ -208,6 +208,9 @@ namespace Discord | |||||
public static string GetStickerUrl(ulong stickerId, StickerFormatType format = StickerFormatType.Png) | public static string GetStickerUrl(ulong stickerId, StickerFormatType format = StickerFormatType.Png) | ||||
=> $"{DiscordConfig.CDNUrl}stickers/{stickerId}.{FormatToExtension(format)}"; | => $"{DiscordConfig.CDNUrl}stickers/{stickerId}.{FormatToExtension(format)}"; | ||||
public static string GetEventCoverImageUrl(ulong guildId, ulong eventId, string assetId, ImageFormat format = ImageFormat.Auto, ushort size = 1024) | |||||
=> $"{DiscordConfig.CDNUrl}guild-events/{guildId}/{eventId}/{assetId}.{FormatToExtension(format, assetId)}?size={size}"; | |||||
private static string FormatToExtension(StickerFormatType format) | private static string FormatToExtension(StickerFormatType format) | ||||
{ | { | ||||
return format switch | return format switch | ||||
@@ -58,6 +58,6 @@ namespace Discord | |||||
/// <summary> | /// <summary> | ||||
/// Gets or sets the banner image of the event. | /// Gets or sets the banner image of the event. | ||||
/// </summary> | /// </summary> | ||||
public Optional<Image?> Image { get; set; } | |||||
public Optional<Image?> CoverImage { get; set; } | |||||
} | } | ||||
} | } |
@@ -1105,7 +1105,7 @@ namespace Discord | |||||
/// </param> | /// </param> | ||||
/// <param name="speakers">A collection of speakers for the event.</param> | /// <param name="speakers">A collection of speakers for the event.</param> | ||||
/// <param name="location">The location of the event; links are supported</param> | /// <param name="location">The location of the event; links are supported</param> | ||||
/// <param name="bannerImage">The optional banner image for the event.</param> | |||||
/// <param name="coverImage">The optional banner image for the event.</param> | |||||
/// <param name="options">The options to be used when sending the request.</param> | /// <param name="options">The options to be used when sending the request.</param> | ||||
/// <returns> | /// <returns> | ||||
/// A task that represents the asynchronous create operation. | /// A task that represents the asynchronous create operation. | ||||
@@ -1119,7 +1119,7 @@ namespace Discord | |||||
DateTimeOffset? endTime = null, | DateTimeOffset? endTime = null, | ||||
ulong? channelId = null, | ulong? channelId = null, | ||||
string location = null, | string location = null, | ||||
Image? bannerImage = null, | |||||
Image? coverImage = null, | |||||
RequestOptions options = null); | RequestOptions options = null); | ||||
/// <summary> | /// <summary> | ||||
@@ -39,6 +39,11 @@ namespace Discord | |||||
/// </remarks> | /// </remarks> | ||||
string Description { get; } | string Description { get; } | ||||
/// <summary> | |||||
/// Gets the banner asset id of the event. | |||||
/// </summary> | |||||
string CoverImageId { get; } | |||||
/// <summary> | /// <summary> | ||||
/// Gets the start time of the event. | /// Gets the start time of the event. | ||||
/// </summary> | /// </summary> | ||||
@@ -80,6 +85,14 @@ namespace Discord | |||||
/// </summary> | /// </summary> | ||||
int? UserCount { get; } | int? UserCount { get; } | ||||
/// <summary> | |||||
/// Gets this events banner image url | |||||
/// </summary> | |||||
/// <param name="format">The format to return.</param> | |||||
/// <param name="size">The size of the image to return in. This can be any power of two between 16 and 2048. | |||||
/// <returns></returns> | |||||
string GetCoverImageUrl(ImageFormat format = ImageFormat.Auto, ushort size = 1024); | |||||
/// <summary> | /// <summary> | ||||
/// Starts the event. | /// Starts the event. | ||||
/// </summary> | /// </summary> | ||||
@@ -39,5 +39,7 @@ namespace Discord.API | |||||
public Optional<User> Creator { get; set; } | public Optional<User> Creator { get; set; } | ||||
[JsonProperty("user_count")] | [JsonProperty("user_count")] | ||||
public Optional<int> UserCount { get; set; } | public Optional<int> UserCount { get; set; } | ||||
[JsonProperty("image")] | |||||
public string Image { get; set; } | |||||
} | } | ||||
} | } |
@@ -800,9 +800,9 @@ namespace Discord.Rest | |||||
StartTime = args.StartTime, | StartTime = args.StartTime, | ||||
Status = args.Status, | Status = args.Status, | ||||
Type = args.Type, | Type = args.Type, | ||||
Image = args.Image.IsSpecified | |||||
? args.Image.Value.HasValue | |||||
? args.Image.Value.Value.ToModel() | |||||
Image = args.CoverImage.IsSpecified | |||||
? args.CoverImage.Value.HasValue | |||||
? args.CoverImage.Value.Value.ToModel() | |||||
: null | : null | ||||
: Optional<ImageModel?>.Unspecified | : Optional<ImageModel?>.Unspecified | ||||
}; | }; | ||||
@@ -28,6 +28,9 @@ namespace Discord.Rest | |||||
/// <inheritdoc/> | /// <inheritdoc/> | ||||
public string Description { get; private set; } | public string Description { get; private set; } | ||||
/// <inheritdoc/> | |||||
public string CoverImageId { get; private set; } | |||||
/// <inheritdoc/> | /// <inheritdoc/> | ||||
public DateTimeOffset StartTime { get; private set; } | public DateTimeOffset StartTime { get; private set; } | ||||
@@ -98,8 +101,13 @@ namespace Discord.Rest | |||||
EntityId = model.EntityId; | EntityId = model.EntityId; | ||||
Location = model.EntityMetadata?.Location.GetValueOrDefault(); | Location = model.EntityMetadata?.Location.GetValueOrDefault(); | ||||
UserCount = model.UserCount.ToNullable(); | UserCount = model.UserCount.ToNullable(); | ||||
CoverImageId = model.Image; | |||||
} | } | ||||
/// <inheritdoc/> | |||||
public string GetCoverImageUrl(ImageFormat format = ImageFormat.Auto, ushort size = 1024) | |||||
=> CDN.GetEventCoverImageUrl(Guild.Id, Id, CoverImageId, format, size); | |||||
/// <inheritdoc/> | /// <inheritdoc/> | ||||
public Task StartAsync(RequestOptions options = null) | public Task StartAsync(RequestOptions options = null) | ||||
=> ModifyAsync(x => x.Status = GuildScheduledEventStatus.Active); | => ModifyAsync(x => x.Status = GuildScheduledEventStatus.Active); | ||||
@@ -35,6 +35,9 @@ namespace Discord.WebSocket | |||||
/// <inheritdoc/> | /// <inheritdoc/> | ||||
public string Description { get; private set; } | public string Description { get; private set; } | ||||
/// <inheritdoc/> | |||||
public string CoverImageId { get; private set; } | |||||
/// <inheritdoc/> | /// <inheritdoc/> | ||||
public DateTimeOffset StartTime { get; private set; } | public DateTimeOffset StartTime { get; private set; } | ||||
@@ -109,8 +112,13 @@ namespace Discord.WebSocket | |||||
StartTime = model.ScheduledStartTime; | StartTime = model.ScheduledStartTime; | ||||
Status = model.Status; | Status = model.Status; | ||||
UserCount = model.UserCount.ToNullable(); | UserCount = model.UserCount.ToNullable(); | ||||
CoverImageId = model.Image; | |||||
} | } | ||||
/// <inheritdoc/> | |||||
public string GetCoverImageUrl(ImageFormat format = ImageFormat.Auto, ushort size = 1024) | |||||
=> CDN.GetEventCoverImageUrl(Guild.Id, Id, CoverImageId, format, size); | |||||
/// <inheritdoc/> | /// <inheritdoc/> | ||||
public Task DeleteAsync(RequestOptions options = null) | public Task DeleteAsync(RequestOptions options = null) | ||||
=> GuildHelper.DeleteEventAsync(Discord, this, options); | => GuildHelper.DeleteEventAsync(Discord, this, options); | ||||