Implement welcome message channels (#819)

This commit is contained in:
Chris Johnston
2017-09-23 14:00:08 -07:00
committed by Christopher F
parent e25054bb3b
commit 30e867a183
7 changed files with 53 additions and 0 deletions

View File

@@ -25,6 +25,8 @@ namespace Discord.API
public bool EmbedEnabled { get; set; }
[JsonProperty("embed_channel_id")]
public ulong? EmbedChannelId { get; set; }
[JsonProperty("system_channel_id")]
public ulong? SystemChannelId { get; set; }
[JsonProperty("verification_level")]
public VerificationLevel VerificationLevel { get; set; }
[JsonProperty("voice_states")]

View File

@@ -18,6 +18,8 @@ namespace Discord.API.Rest
public Optional<DefaultMessageNotifications> DefaultMessageNotifications { get; set; }
[JsonProperty("afk_timeout")]
public Optional<int> AfkTimeout { get; set; }
[JsonProperty("system_channel_id")]
public Optional<ulong?> SystemChannelId { get; set; }
[JsonProperty("icon")]
public Optional<Image?> Icon { get; set; }
[JsonProperty("splash")]

View File

@@ -26,6 +26,7 @@ namespace Discord.Rest
{
AfkChannelId = args.AfkChannelId,
AfkTimeout = args.AfkTimeout,
SystemChannelId = args.SystemChannelId,
DefaultMessageNotifications = args.DefaultMessageNotifications,
Icon = args.Icon.IsSpecified ? args.Icon.Value?.ToModel() : Optional.Create<ImageModel?>(),
Name = args.Name,
@@ -39,6 +40,11 @@ namespace Discord.Rest
else if (args.AfkChannelId.IsSpecified)
apiArgs.AfkChannelId = args.AfkChannelId.Value;
if (args.SystemChannel.IsSpecified)
apiArgs.SystemChannelId = args.SystemChannel.Value.Id;
else if (args.SystemChannelId.IsSpecified)
apiArgs.SystemChannelId = args.SystemChannelId.Value;
if (args.Owner.IsSpecified)
apiArgs.OwnerId = args.Owner.Value.Id;
else if (args.OwnerId.IsSpecified)

View File

@@ -26,6 +26,7 @@ namespace Discord.Rest
public ulong? AFKChannelId { get; private set; }
public ulong? EmbedChannelId { get; private set; }
public ulong? SystemChannelId { get; private set; }
public ulong OwnerId { get; private set; }
public string VoiceRegionId { get; private set; }
public string IconId { get; private set; }
@@ -58,6 +59,7 @@ namespace Discord.Rest
{
AFKChannelId = model.AFKChannelId;
EmbedChannelId = model.EmbedChannelId;
SystemChannelId = model.SystemChannelId;
AFKTimeout = model.AFKTimeout;
IsEmbeddable = model.EmbedEnabled;
IconId = model.Icon;
@@ -201,6 +203,16 @@ namespace Discord.Rest
return await GuildHelper.GetChannelAsync(this, Discord, embedId.Value, options).ConfigureAwait(false);
return null;
}
public async Task<RestTextChannel> GetSystemChannelAsync(RequestOptions options = null)
{
var systemId = SystemChannelId;
if (systemId.HasValue)
{
var channel = await GuildHelper.GetChannelAsync(this, Discord, systemId.Value, options).ConfigureAwait(false);
return channel as RestTextChannel;
}
return null;
}
public Task<RestTextChannel> CreateTextChannelAsync(string name, RequestOptions options = null)
=> GuildHelper.CreateTextChannelAsync(this, Discord, name, options);
public Task<RestVoiceChannel> CreateVoiceChannelAsync(string name, RequestOptions options = null)
@@ -320,6 +332,13 @@ namespace Discord.Rest
else
return null;
}
async Task<ITextChannel> IGuild.GetSystemChannelAsync(CacheMode mode, RequestOptions options)
{
if (mode == CacheMode.AllowDownload)
return await GetSystemChannelAsync(options).ConfigureAwait(false);
else
return null;
}
async Task<ITextChannel> IGuild.CreateTextChannelAsync(string name, RequestOptions options)
=> await CreateTextChannelAsync(name, options).ConfigureAwait(false);
async Task<IVoiceChannel> IGuild.CreateVoiceChannelAsync(string name, RequestOptions options)