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

@@ -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)