Browse Source

Add Image property to create and modify events

pull/2151/head
Quin Lynch 3 years ago
parent
commit
69477eedb2
7 changed files with 31 additions and 8 deletions
  1. +5
    -0
      src/Discord.Net.Core/Entities/Guilds/GuildScheduledEventsProperties.cs
  2. +2
    -0
      src/Discord.Net.Core/Entities/Guilds/IGuild.cs
  3. +2
    -0
      src/Discord.Net.Rest/API/Rest/CreateGuildScheduledEventParams.cs
  4. +2
    -0
      src/Discord.Net.Rest/API/Rest/ModifyGuildScheduledEventParams.cs
  5. +10
    -2
      src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
  6. +5
    -3
      src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
  7. +5
    -3
      src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs

+ 5
- 0
src/Discord.Net.Core/Entities/Guilds/GuildScheduledEventsProperties.cs View File

@@ -54,5 +54,10 @@ namespace Discord
/// Gets or sets the status of the event. /// Gets or sets the status of the event.
/// </summary> /// </summary>
public Optional<GuildScheduledEventStatus> Status { get; set; } public Optional<GuildScheduledEventStatus> Status { get; set; }

/// <summary>
/// Gets or sets the banner image of the event.
/// </summary>
public Optional<Image?> Image { get; set; }
} }
} }

+ 2
- 0
src/Discord.Net.Core/Entities/Guilds/IGuild.cs View File

@@ -1105,6 +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="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.
@@ -1118,6 +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,
RequestOptions options = null); RequestOptions options = null);


/// <summary> /// <summary>


+ 2
- 0
src/Discord.Net.Rest/API/Rest/CreateGuildScheduledEventParams.cs View File

@@ -25,5 +25,7 @@ namespace Discord.API.Rest
public Optional<string> Description { get; set; } public Optional<string> Description { get; set; }
[JsonProperty("entity_type")] [JsonProperty("entity_type")]
public GuildScheduledEventType Type { get; set; } public GuildScheduledEventType Type { get; set; }
[JsonProperty("image")]
public Optional<Image> Image { get; set; }
} }
} }

+ 2
- 0
src/Discord.Net.Rest/API/Rest/ModifyGuildScheduledEventParams.cs View File

@@ -27,5 +27,7 @@ namespace Discord.API.Rest
public Optional<GuildScheduledEventType> Type { get; set; } public Optional<GuildScheduledEventType> Type { get; set; }
[JsonProperty("status")] [JsonProperty("status")]
public Optional<GuildScheduledEventStatus> Status { get; set; } public Optional<GuildScheduledEventStatus> Status { get; set; }
[JsonProperty("image")]
public Optional<Image?> Image { get; set; }
} }
} }

+ 10
- 2
src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs View File

@@ -799,7 +799,12 @@ namespace Discord.Rest
PrivacyLevel = args.PrivacyLevel, PrivacyLevel = args.PrivacyLevel,
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()
: null
: Optional<ImageModel?>.Unspecified
}; };


if(args.Location.IsSpecified) if(args.Location.IsSpecified)
@@ -839,6 +844,7 @@ namespace Discord.Rest
DateTimeOffset? endTime = null, DateTimeOffset? endTime = null,
ulong? channelId = null, ulong? channelId = null,
string location = null, string location = null,
Image? bannerImage = null,
RequestOptions options = null) RequestOptions options = null)
{ {
if(location != null) if(location != null)
@@ -864,6 +870,7 @@ namespace Discord.Rest
if (endTime != null && endTime <= startTime) if (endTime != null && endTime <= startTime)
throw new ArgumentOutOfRangeException(nameof(endTime), $"{nameof(endTime)} cannot be before the start time"); throw new ArgumentOutOfRangeException(nameof(endTime), $"{nameof(endTime)} cannot be before the start time");


var apiArgs = new CreateGuildScheduledEventParams() var apiArgs = new CreateGuildScheduledEventParams()
{ {
ChannelId = channelId ?? Optional<ulong>.Unspecified, ChannelId = channelId ?? Optional<ulong>.Unspecified,
@@ -872,7 +879,8 @@ namespace Discord.Rest
Name = name, Name = name,
PrivacyLevel = privacyLevel, PrivacyLevel = privacyLevel,
StartTime = startTime, StartTime = startTime,
Type = type
Type = type,
Image = bannerImage.HasValue ? bannerImage.Value.ToModel() : Optional<ImageModel>.Unspecified
}; };


if(location != null) if(location != null)


+ 5
- 3
src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs View File

@@ -1167,6 +1167,7 @@ namespace Discord.Rest
/// </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="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.
@@ -1180,8 +1181,9 @@ namespace Discord.Rest
DateTimeOffset? endTime = null, DateTimeOffset? endTime = null,
ulong? channelId = null, ulong? channelId = null,
string location = null, string location = null,
Image? bannerImage = null,
RequestOptions options = 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, bannerImage, options);


#endregion #endregion


@@ -1198,8 +1200,8 @@ namespace Discord.Rest
IReadOnlyCollection<ICustomSticker> IGuild.Stickers => Stickers; IReadOnlyCollection<ICustomSticker> IGuild.Stickers => Stickers;


/// <inheritdoc /> /// <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? bannerImage, RequestOptions options)
=> await CreateEventAsync(name, startTime, type, privacyLevel, description, endTime, channelId, location, bannerImage, options).ConfigureAwait(false);


/// <inheritdoc /> /// <inheritdoc />
async Task<IGuildScheduledEvent> IGuild.GetEventAsync(ulong id, RequestOptions options) async Task<IGuildScheduledEvent> IGuild.GetEventAsync(ulong id, RequestOptions options)


+ 5
- 3
src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs View File

@@ -1295,6 +1295,7 @@ namespace Discord.WebSocket
/// </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="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.
@@ -1308,6 +1309,7 @@ namespace Discord.WebSocket
DateTimeOffset? endTime = null, DateTimeOffset? endTime = null,
ulong? channelId = null, ulong? channelId = null,
string location = null, string location = null,
Image? bannerImage = null,
RequestOptions options = null) RequestOptions options = null)
{ {
// requirements taken from https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-permissions-requirements // requirements taken from https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-permissions-requirements
@@ -1324,7 +1326,7 @@ namespace Discord.WebSocket
break; break;
} }


return GuildHelper.CreateGuildEventAsync(Discord, this, name, privacyLevel, startTime, type, description, endTime, channelId, location, options);
return GuildHelper.CreateGuildEventAsync(Discord, this, name, privacyLevel, startTime, type, description, endTime, channelId, location, bannerImage, options);
} }




@@ -1803,8 +1805,8 @@ namespace Discord.WebSocket
/// <inheritdoc /> /// <inheritdoc />
IReadOnlyCollection<ICustomSticker> IGuild.Stickers => Stickers; IReadOnlyCollection<ICustomSticker> IGuild.Stickers => Stickers;
/// <inheritdoc /> /// <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? bannerImage, RequestOptions options)
=> await CreateEventAsync(name, startTime, type, privacyLevel, description, endTime, channelId, location, bannerImage, options).ConfigureAwait(false);
/// <inheritdoc /> /// <inheritdoc />
async Task<IGuildScheduledEvent> IGuild.GetEventAsync(ulong id, RequestOptions options) async Task<IGuildScheduledEvent> IGuild.GetEventAsync(ulong id, RequestOptions options)
=> await GetEventAsync(id, options).ConfigureAwait(false); => await GetEventAsync(id, options).ConfigureAwait(false);


Loading…
Cancel
Save