Implement welcome message channels (#819)
This commit is contained in:
committed by
Christopher F
parent
e25054bb3b
commit
30e867a183
@@ -60,6 +60,14 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Optional<ulong?> AfkChannelId { get; set; }
|
public Optional<ulong?> AfkChannelId { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// The ITextChannel where System messages should be sent.
|
||||||
|
/// </summary>
|
||||||
|
public Optional<ITextChannel> SystemChannel { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// The ID of the ITextChannel where System messages should be sent.
|
||||||
|
/// </summary>
|
||||||
|
public Optional<ulong?> SystemChannelId { get; set; }
|
||||||
|
/// <summary>
|
||||||
/// The owner of this guild.
|
/// The owner of this guild.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Optional<IUser> Owner { get; set; }
|
public Optional<IUser> Owner { get; set; }
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ namespace Discord
|
|||||||
ulong DefaultChannelId { get; }
|
ulong DefaultChannelId { get; }
|
||||||
/// <summary> Gets the id of the embed channel for this guild if set, or null if not. </summary>
|
/// <summary> Gets the id of the embed channel for this guild if set, or null if not. </summary>
|
||||||
ulong? EmbedChannelId { get; }
|
ulong? EmbedChannelId { get; }
|
||||||
|
/// <summary> Gets the id of the channel where randomized welcome messages are sent, or null if not. </summary>
|
||||||
|
ulong? SystemChannelId { get; }
|
||||||
/// <summary> Gets the id of the user that created this guild. </summary>
|
/// <summary> Gets the id of the user that created this guild. </summary>
|
||||||
ulong OwnerId { get; }
|
ulong OwnerId { get; }
|
||||||
/// <summary> Gets the id of the region hosting this guild's voice channels. </summary>
|
/// <summary> Gets the id of the region hosting this guild's voice channels. </summary>
|
||||||
@@ -84,6 +86,7 @@ namespace Discord
|
|||||||
Task<IReadOnlyCollection<IVoiceChannel>> GetVoiceChannelsAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
|
Task<IReadOnlyCollection<IVoiceChannel>> GetVoiceChannelsAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
|
||||||
Task<IVoiceChannel> GetVoiceChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
|
Task<IVoiceChannel> GetVoiceChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
|
||||||
Task<IVoiceChannel> GetAFKChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
|
Task<IVoiceChannel> GetAFKChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
|
||||||
|
Task<ITextChannel> GetSystemChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
|
||||||
Task<ITextChannel> GetDefaultChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
|
Task<ITextChannel> GetDefaultChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
|
||||||
Task<IGuildChannel> GetEmbedChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
|
Task<IGuildChannel> GetEmbedChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
|
||||||
/// <summary> Creates a new text channel. </summary>
|
/// <summary> Creates a new text channel. </summary>
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ namespace Discord.API
|
|||||||
public bool EmbedEnabled { get; set; }
|
public bool EmbedEnabled { get; set; }
|
||||||
[JsonProperty("embed_channel_id")]
|
[JsonProperty("embed_channel_id")]
|
||||||
public ulong? EmbedChannelId { get; set; }
|
public ulong? EmbedChannelId { get; set; }
|
||||||
|
[JsonProperty("system_channel_id")]
|
||||||
|
public ulong? SystemChannelId { get; set; }
|
||||||
[JsonProperty("verification_level")]
|
[JsonProperty("verification_level")]
|
||||||
public VerificationLevel VerificationLevel { get; set; }
|
public VerificationLevel VerificationLevel { get; set; }
|
||||||
[JsonProperty("voice_states")]
|
[JsonProperty("voice_states")]
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ namespace Discord.API.Rest
|
|||||||
public Optional<DefaultMessageNotifications> DefaultMessageNotifications { get; set; }
|
public Optional<DefaultMessageNotifications> DefaultMessageNotifications { get; set; }
|
||||||
[JsonProperty("afk_timeout")]
|
[JsonProperty("afk_timeout")]
|
||||||
public Optional<int> AfkTimeout { get; set; }
|
public Optional<int> AfkTimeout { get; set; }
|
||||||
|
[JsonProperty("system_channel_id")]
|
||||||
|
public Optional<ulong?> SystemChannelId { get; set; }
|
||||||
[JsonProperty("icon")]
|
[JsonProperty("icon")]
|
||||||
public Optional<Image?> Icon { get; set; }
|
public Optional<Image?> Icon { get; set; }
|
||||||
[JsonProperty("splash")]
|
[JsonProperty("splash")]
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ namespace Discord.Rest
|
|||||||
{
|
{
|
||||||
AfkChannelId = args.AfkChannelId,
|
AfkChannelId = args.AfkChannelId,
|
||||||
AfkTimeout = args.AfkTimeout,
|
AfkTimeout = args.AfkTimeout,
|
||||||
|
SystemChannelId = args.SystemChannelId,
|
||||||
DefaultMessageNotifications = args.DefaultMessageNotifications,
|
DefaultMessageNotifications = args.DefaultMessageNotifications,
|
||||||
Icon = args.Icon.IsSpecified ? args.Icon.Value?.ToModel() : Optional.Create<ImageModel?>(),
|
Icon = args.Icon.IsSpecified ? args.Icon.Value?.ToModel() : Optional.Create<ImageModel?>(),
|
||||||
Name = args.Name,
|
Name = args.Name,
|
||||||
@@ -39,6 +40,11 @@ namespace Discord.Rest
|
|||||||
else if (args.AfkChannelId.IsSpecified)
|
else if (args.AfkChannelId.IsSpecified)
|
||||||
apiArgs.AfkChannelId = args.AfkChannelId.Value;
|
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)
|
if (args.Owner.IsSpecified)
|
||||||
apiArgs.OwnerId = args.Owner.Value.Id;
|
apiArgs.OwnerId = args.Owner.Value.Id;
|
||||||
else if (args.OwnerId.IsSpecified)
|
else if (args.OwnerId.IsSpecified)
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ namespace Discord.Rest
|
|||||||
|
|
||||||
public ulong? AFKChannelId { get; private set; }
|
public ulong? AFKChannelId { get; private set; }
|
||||||
public ulong? EmbedChannelId { get; private set; }
|
public ulong? EmbedChannelId { get; private set; }
|
||||||
|
public ulong? SystemChannelId { get; private set; }
|
||||||
public ulong OwnerId { get; private set; }
|
public ulong OwnerId { get; private set; }
|
||||||
public string VoiceRegionId { get; private set; }
|
public string VoiceRegionId { get; private set; }
|
||||||
public string IconId { get; private set; }
|
public string IconId { get; private set; }
|
||||||
@@ -58,6 +59,7 @@ namespace Discord.Rest
|
|||||||
{
|
{
|
||||||
AFKChannelId = model.AFKChannelId;
|
AFKChannelId = model.AFKChannelId;
|
||||||
EmbedChannelId = model.EmbedChannelId;
|
EmbedChannelId = model.EmbedChannelId;
|
||||||
|
SystemChannelId = model.SystemChannelId;
|
||||||
AFKTimeout = model.AFKTimeout;
|
AFKTimeout = model.AFKTimeout;
|
||||||
IsEmbeddable = model.EmbedEnabled;
|
IsEmbeddable = model.EmbedEnabled;
|
||||||
IconId = model.Icon;
|
IconId = model.Icon;
|
||||||
@@ -201,6 +203,16 @@ namespace Discord.Rest
|
|||||||
return await GuildHelper.GetChannelAsync(this, Discord, embedId.Value, options).ConfigureAwait(false);
|
return await GuildHelper.GetChannelAsync(this, Discord, embedId.Value, options).ConfigureAwait(false);
|
||||||
return null;
|
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)
|
public Task<RestTextChannel> CreateTextChannelAsync(string name, RequestOptions options = null)
|
||||||
=> GuildHelper.CreateTextChannelAsync(this, Discord, name, options);
|
=> GuildHelper.CreateTextChannelAsync(this, Discord, name, options);
|
||||||
public Task<RestVoiceChannel> CreateVoiceChannelAsync(string name, RequestOptions options = null)
|
public Task<RestVoiceChannel> CreateVoiceChannelAsync(string name, RequestOptions options = null)
|
||||||
@@ -320,6 +332,13 @@ namespace Discord.Rest
|
|||||||
else
|
else
|
||||||
return null;
|
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)
|
async Task<ITextChannel> IGuild.CreateTextChannelAsync(string name, RequestOptions options)
|
||||||
=> await CreateTextChannelAsync(name, options).ConfigureAwait(false);
|
=> await CreateTextChannelAsync(name, options).ConfigureAwait(false);
|
||||||
async Task<IVoiceChannel> IGuild.CreateVoiceChannelAsync(string name, RequestOptions options)
|
async Task<IVoiceChannel> IGuild.CreateVoiceChannelAsync(string name, RequestOptions options)
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ namespace Discord.WebSocket
|
|||||||
|
|
||||||
internal ulong? AFKChannelId { get; private set; }
|
internal ulong? AFKChannelId { get; private set; }
|
||||||
internal ulong? EmbedChannelId { get; private set; }
|
internal ulong? EmbedChannelId { get; private set; }
|
||||||
|
internal ulong? SystemChannelId { get; private set; }
|
||||||
public ulong OwnerId { get; private set; }
|
public ulong OwnerId { get; private set; }
|
||||||
public SocketGuildUser Owner => GetUser(OwnerId);
|
public SocketGuildUser Owner => GetUser(OwnerId);
|
||||||
public string VoiceRegionId { get; private set; }
|
public string VoiceRegionId { get; private set; }
|
||||||
@@ -81,6 +82,14 @@ namespace Discord.WebSocket
|
|||||||
return id.HasValue ? GetChannel(id.Value) : null;
|
return id.HasValue ? GetChannel(id.Value) : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public SocketTextChannel SystemChannel
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var id = SystemChannelId;
|
||||||
|
return id.HasValue ? GetTextChannel(id.Value) : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
public IReadOnlyCollection<SocketTextChannel> TextChannels
|
public IReadOnlyCollection<SocketTextChannel> TextChannels
|
||||||
=> Channels.Select(x => x as SocketTextChannel).Where(x => x != null).ToImmutableArray();
|
=> Channels.Select(x => x as SocketTextChannel).Where(x => x != null).ToImmutableArray();
|
||||||
public IReadOnlyCollection<SocketVoiceChannel> VoiceChannels
|
public IReadOnlyCollection<SocketVoiceChannel> VoiceChannels
|
||||||
@@ -191,6 +200,7 @@ namespace Discord.WebSocket
|
|||||||
{
|
{
|
||||||
AFKChannelId = model.AFKChannelId;
|
AFKChannelId = model.AFKChannelId;
|
||||||
EmbedChannelId = model.EmbedChannelId;
|
EmbedChannelId = model.EmbedChannelId;
|
||||||
|
SystemChannelId = model.SystemChannelId;
|
||||||
AFKTimeout = model.AFKTimeout;
|
AFKTimeout = model.AFKTimeout;
|
||||||
IsEmbeddable = model.EmbedEnabled;
|
IsEmbeddable = model.EmbedEnabled;
|
||||||
IconId = model.Icon;
|
IconId = model.Icon;
|
||||||
@@ -607,6 +617,7 @@ namespace Discord.WebSocket
|
|||||||
bool IGuild.Available => true;
|
bool IGuild.Available => true;
|
||||||
ulong IGuild.DefaultChannelId => DefaultChannel?.Id ?? 0;
|
ulong IGuild.DefaultChannelId => DefaultChannel?.Id ?? 0;
|
||||||
ulong? IGuild.EmbedChannelId => EmbedChannelId;
|
ulong? IGuild.EmbedChannelId => EmbedChannelId;
|
||||||
|
ulong? IGuild.SystemChannelId => SystemChannelId;
|
||||||
IRole IGuild.EveryoneRole => EveryoneRole;
|
IRole IGuild.EveryoneRole => EveryoneRole;
|
||||||
IReadOnlyCollection<IRole> IGuild.Roles => Roles;
|
IReadOnlyCollection<IRole> IGuild.Roles => Roles;
|
||||||
|
|
||||||
@@ -631,6 +642,8 @@ namespace Discord.WebSocket
|
|||||||
=> Task.FromResult<ITextChannel>(DefaultChannel);
|
=> Task.FromResult<ITextChannel>(DefaultChannel);
|
||||||
Task<IGuildChannel> IGuild.GetEmbedChannelAsync(CacheMode mode, RequestOptions options)
|
Task<IGuildChannel> IGuild.GetEmbedChannelAsync(CacheMode mode, RequestOptions options)
|
||||||
=> Task.FromResult<IGuildChannel>(EmbedChannel);
|
=> Task.FromResult<IGuildChannel>(EmbedChannel);
|
||||||
|
Task<ITextChannel> IGuild.GetSystemChannelAsync(CacheMode mode, RequestOptions options)
|
||||||
|
=> Task.FromResult<ITextChannel>(SystemChannel);
|
||||||
async Task<ITextChannel> IGuild.CreateTextChannelAsync(string name, RequestOptions options)
|
async Task<ITextChannel> IGuild.CreateTextChannelAsync(string name, RequestOptions options)
|
||||||
=> await CreateTextChannelAsync(name, options).ConfigureAwait(false);
|
=> await CreateTextChannelAsync(name, options).ConfigureAwait(false);
|
||||||
async Task<IVoiceChannel> IGuild.CreateVoiceChannelAsync(string name, RequestOptions options)
|
async Task<IVoiceChannel> IGuild.CreateVoiceChannelAsync(string name, RequestOptions options)
|
||||||
|
|||||||
Reference in New Issue
Block a user