Add Image property to Guild Scheduled Events (#2151)
* Add Image property to create and modify events * Add CDN routes to get cover image * Update banner names * Update CDN.cs * Update IGuildScheduledEvent.cs
This commit is contained in:
@@ -39,5 +39,7 @@ namespace Discord.API
|
||||
public Optional<User> Creator { get; set; }
|
||||
[JsonProperty("user_count")]
|
||||
public Optional<int> UserCount { get; set; }
|
||||
[JsonProperty("image")]
|
||||
public string Image { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,5 +25,7 @@ namespace Discord.API.Rest
|
||||
public Optional<string> Description { get; set; }
|
||||
[JsonProperty("entity_type")]
|
||||
public GuildScheduledEventType Type { get; set; }
|
||||
[JsonProperty("image")]
|
||||
public Optional<Image> Image { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,5 +27,7 @@ namespace Discord.API.Rest
|
||||
public Optional<GuildScheduledEventType> Type { get; set; }
|
||||
[JsonProperty("status")]
|
||||
public Optional<GuildScheduledEventStatus> Status { get; set; }
|
||||
[JsonProperty("image")]
|
||||
public Optional<Image?> Image { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -799,7 +799,12 @@ namespace Discord.Rest
|
||||
PrivacyLevel = args.PrivacyLevel,
|
||||
StartTime = args.StartTime,
|
||||
Status = args.Status,
|
||||
Type = args.Type
|
||||
Type = args.Type,
|
||||
Image = args.CoverImage.IsSpecified
|
||||
? args.CoverImage.Value.HasValue
|
||||
? args.CoverImage.Value.Value.ToModel()
|
||||
: null
|
||||
: Optional<ImageModel?>.Unspecified
|
||||
};
|
||||
|
||||
if(args.Location.IsSpecified)
|
||||
@@ -839,6 +844,7 @@ namespace Discord.Rest
|
||||
DateTimeOffset? endTime = null,
|
||||
ulong? channelId = null,
|
||||
string location = null,
|
||||
Image? bannerImage = null,
|
||||
RequestOptions options = null)
|
||||
{
|
||||
if(location != null)
|
||||
@@ -864,6 +870,7 @@ namespace Discord.Rest
|
||||
if (endTime != null && endTime <= startTime)
|
||||
throw new ArgumentOutOfRangeException(nameof(endTime), $"{nameof(endTime)} cannot be before the start time");
|
||||
|
||||
|
||||
var apiArgs = new CreateGuildScheduledEventParams()
|
||||
{
|
||||
ChannelId = channelId ?? Optional<ulong>.Unspecified,
|
||||
@@ -872,7 +879,8 @@ namespace Discord.Rest
|
||||
Name = name,
|
||||
PrivacyLevel = privacyLevel,
|
||||
StartTime = startTime,
|
||||
Type = type
|
||||
Type = type,
|
||||
Image = bannerImage.HasValue ? bannerImage.Value.ToModel() : Optional<ImageModel>.Unspecified
|
||||
};
|
||||
|
||||
if(location != null)
|
||||
|
||||
@@ -1167,6 +1167,7 @@ namespace Discord.Rest
|
||||
/// </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="coverImage">The optional banner image for the event.</param>
|
||||
/// <param name="options">The options to be used when sending the request.</param>
|
||||
/// <returns>
|
||||
/// A task that represents the asynchronous create operation.
|
||||
@@ -1180,8 +1181,9 @@ namespace Discord.Rest
|
||||
DateTimeOffset? endTime = null,
|
||||
ulong? channelId = null,
|
||||
string location = null,
|
||||
Image? coverImage = null,
|
||||
RequestOptions options = null)
|
||||
=> GuildHelper.CreateGuildEventAsync(Discord, this, name, privacyLevel, startTime, type, description, endTime, channelId, location, options);
|
||||
=> GuildHelper.CreateGuildEventAsync(Discord, this, name, privacyLevel, startTime, type, description, endTime, channelId, location, coverImage, options);
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1198,8 +1200,8 @@ namespace Discord.Rest
|
||||
IReadOnlyCollection<ICustomSticker> IGuild.Stickers => Stickers;
|
||||
|
||||
/// <inheritdoc />
|
||||
async Task<IGuildScheduledEvent> IGuild.CreateEventAsync(string name, DateTimeOffset startTime, GuildScheduledEventType type, GuildScheduledEventPrivacyLevel privacyLevel, string description, DateTimeOffset? endTime, ulong? channelId, string location, RequestOptions options)
|
||||
=> await CreateEventAsync(name, startTime, type, privacyLevel, description, endTime, channelId, location, options).ConfigureAwait(false);
|
||||
async Task<IGuildScheduledEvent> IGuild.CreateEventAsync(string name, DateTimeOffset startTime, GuildScheduledEventType type, GuildScheduledEventPrivacyLevel privacyLevel, string description, DateTimeOffset? endTime, ulong? channelId, string location, Image? coverImage, RequestOptions options)
|
||||
=> await CreateEventAsync(name, startTime, type, privacyLevel, description, endTime, channelId, location, coverImage, options).ConfigureAwait(false);
|
||||
|
||||
/// <inheritdoc />
|
||||
async Task<IGuildScheduledEvent> IGuild.GetEventAsync(ulong id, RequestOptions options)
|
||||
|
||||
@@ -28,6 +28,9 @@ namespace Discord.Rest
|
||||
/// <inheritdoc/>
|
||||
public string Description { get; private set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string CoverImageId { get; private set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public DateTimeOffset StartTime { get; private set; }
|
||||
|
||||
@@ -98,8 +101,13 @@ namespace Discord.Rest
|
||||
EntityId = model.EntityId;
|
||||
Location = model.EntityMetadata?.Location.GetValueOrDefault();
|
||||
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/>
|
||||
public Task StartAsync(RequestOptions options = null)
|
||||
=> ModifyAsync(x => x.Status = GuildScheduledEventStatus.Active);
|
||||
|
||||
Reference in New Issue
Block a user