@@ -14,7 +14,7 @@ namespace Discord.Commands | |||||
Prefix = null; | Prefix = null; | ||||
} | } | ||||
/// <summary> Creates a <see cref="GroupAttribute"/> with the provided prefix. </summary> | /// <summary> Creates a <see cref="GroupAttribute"/> with the provided prefix. </summary> | ||||
/// <param name="prefix"> The prefix of the module group.</param> | |||||
/// <param name="prefix"> The prefix of the module group. </param> | |||||
public GroupAttribute(string prefix) | public GroupAttribute(string prefix) | ||||
{ | { | ||||
Prefix = prefix; | Prefix = prefix; | ||||
@@ -7,8 +7,11 @@ namespace Discord.Commands | |||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)] | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)] | ||||
public class NameAttribute : Attribute | public class NameAttribute : Attribute | ||||
{ | { | ||||
/// <summary> Gets the name of the command. </summary> | |||||
public string Text { get; } | public string Text { get; } | ||||
/// <summary> Marks the public name of a command, module, or parameter with the provided name. </summary> | |||||
/// <param name="text"> The public name of the object. </param> | |||||
public NameAttribute(string text) | public NameAttribute(string text) | ||||
{ | { | ||||
Text = text; | Text = text; | ||||
@@ -3,6 +3,7 @@ using System.Threading.Tasks; | |||||
namespace Discord.Commands | namespace Discord.Commands | ||||
{ | { | ||||
/// <summary> Requires the module or class to pass the specified precondition before execution can begin. </summary> | |||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true, Inherited = true)] | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true, Inherited = true)] | ||||
public abstract class PreconditionAttribute : Attribute | public abstract class PreconditionAttribute : Attribute | ||||
{ | { | ||||
@@ -2,7 +2,7 @@ using System; | |||||
namespace Discord.Commands | namespace Discord.Commands | ||||
{ | { | ||||
/// <summary> An exception thrown when a command fails to execute. </summary> | |||||
/// <summary> Thrown when a command fails to execute. </summary> | |||||
public class CommandException : Exception | public class CommandException : Exception | ||||
{ | { | ||||
/// <summary> The command that caused the exception. </summary> | /// <summary> The command that caused the exception. </summary> | ||||
@@ -1,4 +1,4 @@ | |||||
using Discord.Audio; | |||||
using Discord.Audio; | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
@@ -15,34 +15,34 @@ namespace Discord | |||||
bool IsEmbeddable { get; } | bool IsEmbeddable { get; } | ||||
/// <summary> Gets the default message notifications for users who haven't explicitly set their notification settings. </summary> | /// <summary> Gets the default message notifications for users who haven't explicitly set their notification settings. </summary> | ||||
DefaultMessageNotifications DefaultMessageNotifications { get; } | DefaultMessageNotifications DefaultMessageNotifications { get; } | ||||
/// <summary> Gets the level of mfa requirements a user must fulfill before being allowed to perform administrative actions in this guild. </summary> | |||||
/// <summary> Gets the level of Multi-Factor Authentication requirements a user must fulfill before being allowed to perform administrative actions in this guild. </summary> | |||||
MfaLevel MfaLevel { get; } | MfaLevel MfaLevel { get; } | ||||
/// <summary> Gets the level of requirements a user must fulfill before being allowed to post messages in this guild. </summary> | /// <summary> Gets the level of requirements a user must fulfill before being allowed to post messages in this guild. </summary> | ||||
VerificationLevel VerificationLevel { get; } | VerificationLevel VerificationLevel { get; } | ||||
/// <summary> Returns the id of this guild's icon, or null if one is not set. </summary> | |||||
/// <summary> Returns the ID of this guild's icon, or null if one is not set. </summary> | |||||
string IconId { get; } | string IconId { get; } | ||||
/// <summary> Returns the url to this guild's icon, or null if one is not set. </summary> | /// <summary> Returns the url to this guild's icon, or null if one is not set. </summary> | ||||
string IconUrl { get; } | string IconUrl { get; } | ||||
/// <summary> Returns the id of this guild's splash image, or null if one is not set. </summary> | |||||
/// <summary> Returns the ID of this guild's splash image, or null if one is not set. </summary> | |||||
string SplashId { get; } | string SplashId { get; } | ||||
/// <summary> Returns the url to this guild's splash image, or null if one is not set. </summary> | /// <summary> Returns the url to this guild's splash image, or null if one is not set. </summary> | ||||
string SplashUrl { get; } | string SplashUrl { get; } | ||||
/// <summary> Returns true if this guild is currently connected and ready to be used. Only applies to the WebSocket client. </summary> | /// <summary> Returns true if this guild is currently connected and ready to be used. Only applies to the WebSocket client. </summary> | ||||
bool Available { get; } | bool Available { get; } | ||||
/// <summary> Gets the id of the AFK voice channel for this guild if set, or null if not. </summary> | |||||
/// <summary> Gets the ID of the AFK voice channel for this guild if set, or null if not. </summary> | |||||
ulong? AFKChannelId { get; } | ulong? AFKChannelId { get; } | ||||
/// <summary> Gets the id of the the default channel for this guild. </summary> | |||||
/// <summary> Gets the ID of the the default channel for this guild. </summary> | |||||
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> | |||||
/// <summary> Gets the ID of the channel where randomized welcome messages are sent, or null if not. </summary> | |||||
ulong? SystemChannelId { get; } | 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> | |||||
string VoiceRegionId { get; } | string VoiceRegionId { get; } | ||||
/// <summary> Gets the IAudioClient currently associated with this guild. </summary> | |||||
/// <summary> Gets the <see cref="IAudioClient"/> currently associated with this guild. </summary> | |||||
IAudioClient AudioClient { get; } | IAudioClient AudioClient { get; } | ||||
/// <summary> Gets the built-in role containing all users in this guild. </summary> | /// <summary> Gets the built-in role containing all users in this guild. </summary> | ||||
IRole EveryoneRole { get; } | IRole EveryoneRole { get; } | ||||
@@ -67,34 +67,53 @@ namespace Discord | |||||
/// <summary> Gets a collection of all users banned on this guild. </summary> | /// <summary> Gets a collection of all users banned on this guild. </summary> | ||||
Task<IReadOnlyCollection<IBan>> GetBansAsync(RequestOptions options = null); | Task<IReadOnlyCollection<IBan>> GetBansAsync(RequestOptions options = null); | ||||
/// <summary> Bans the provided user from this guild and optionally prunes their recent messages. </summary> | /// <summary> Bans the provided user from this guild and optionally prunes their recent messages. </summary> | ||||
/// <param name="pruneDays">The number of days to remove messages from this user for - must be between [0, 7]</param> | |||||
/// <param name="user"> The user to ban. </param> | |||||
/// <param name="pruneDays"> The number of days to remove messages from this user for - must be between [0, 7]</param> | |||||
/// <param name="reason"> The reason of the ban to be written in the audit log. </param> | |||||
Task AddBanAsync(IUser user, int pruneDays = 0, string reason = null, RequestOptions options = null); | Task AddBanAsync(IUser user, int pruneDays = 0, string reason = null, RequestOptions options = null); | ||||
/// <summary> Bans the provided user id from this guild and optionally prunes their recent messages. </summary> | |||||
/// <summary> Bans the provided user ID from this guild and optionally prunes their recent messages. </summary> | |||||
/// <param name="userId"> The ID of the user to ban. </param> | |||||
/// <param name="pruneDays">The number of days to remove messages from this user for - must be between [0, 7]</param> | /// <param name="pruneDays">The number of days to remove messages from this user for - must be between [0, 7]</param> | ||||
/// <param name="reason"> The reason of the ban to be written in the audit log. </param> | |||||
Task AddBanAsync(ulong userId, int pruneDays = 0, string reason = null, RequestOptions options = null); | Task AddBanAsync(ulong userId, int pruneDays = 0, string reason = null, RequestOptions options = null); | ||||
/// <summary> Unbans the provided user if it is currently banned. </summary> | /// <summary> Unbans the provided user if it is currently banned. </summary> | ||||
Task RemoveBanAsync(IUser user, RequestOptions options = null); | Task RemoveBanAsync(IUser user, RequestOptions options = null); | ||||
/// <summary> Unbans the provided user id if it is currently banned. </summary> | |||||
/// <summary> Unbans the provided user ID if it is currently banned. </summary> | |||||
Task RemoveBanAsync(ulong userId, RequestOptions options = null); | Task RemoveBanAsync(ulong userId, RequestOptions options = null); | ||||
/// <summary> Gets a collection of all channels in this guild. </summary> | /// <summary> Gets a collection of all channels in this guild. </summary> | ||||
Task<IReadOnlyCollection<IGuildChannel>> GetChannelsAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<IReadOnlyCollection<IGuildChannel>> GetChannelsAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
/// <summary> Gets the channel in this guild with the provided id, or null if not found. </summary> | |||||
/// <summary> Gets the channel in this guild with the provided ID, or null if not found. </summary> | |||||
/// <param name="id"> The channel ID. </param> | |||||
Task<IGuildChannel> GetChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<IGuildChannel> GetChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
/// <summary> Gets a collection of all text channels in this guild. </summary> | |||||
Task<IReadOnlyCollection<ITextChannel>> GetTextChannelsAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<IReadOnlyCollection<ITextChannel>> GetTextChannelsAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
/// <summary> Gets a text channel in this guild with the provided ID, or null if not found. </summary> | |||||
/// <param name="id"> The text channel ID. </param> | |||||
Task<ITextChannel> GetTextChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<ITextChannel> GetTextChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
/// <summary> Gets a collection of all voice channels in this guild. </summary> | |||||
Task<IReadOnlyCollection<IVoiceChannel>> GetVoiceChannelsAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<IReadOnlyCollection<IVoiceChannel>> GetVoiceChannelsAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
/// <summary> Gets a collection of all category channels in this guild. </summary> | |||||
Task<IReadOnlyCollection<ICategoryChannel>> GetCategoriesAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<IReadOnlyCollection<ICategoryChannel>> GetCategoriesAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
/// <summary> Gets the voice channel in this guild with the provided ID, or null if not found. </summary> | |||||
/// <param name="id"> The text channel ID. </param> | |||||
Task<IVoiceChannel> GetVoiceChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<IVoiceChannel> GetVoiceChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
/// <summary> Gets the voice AFK channel in this guild with the provided ID, or null if not found. </summary> | |||||
Task<IVoiceChannel> GetAFKChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<IVoiceChannel> GetAFKChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
/// <summary> Gets the default system text channel in this guild with the provided ID, or null if none is set. </summary> | |||||
Task<ITextChannel> GetSystemChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<ITextChannel> GetSystemChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
/// <summary> Gets the top viewable text channel in this guild with the provided ID, or null if not found. </summary> | |||||
Task<ITextChannel> GetDefaultChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<ITextChannel> GetDefaultChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
/// <summary> Gets the embed channel in this guild. </summary> | |||||
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> | ||||
/// <param name="name"> The new name for the text channel. </param> | |||||
Task<ITextChannel> CreateTextChannelAsync(string name, RequestOptions options = null); | Task<ITextChannel> CreateTextChannelAsync(string name, RequestOptions options = null); | ||||
/// <summary> Creates a new voice channel. </summary> | /// <summary> Creates a new voice channel. </summary> | ||||
/// <param name="name"> The new name for the voice channel. </param> | |||||
Task<IVoiceChannel> CreateVoiceChannelAsync(string name, RequestOptions options = null); | Task<IVoiceChannel> CreateVoiceChannelAsync(string name, RequestOptions options = null); | ||||
/// <summary> Creates a new channel category. </summary> | /// <summary> Creates a new channel category. </summary> | ||||
/// <param name="name"> The new name for the category. </param> | |||||
Task<ICategoryChannel> CreateCategoryAsync(string name, RequestOptions options = null); | Task<ICategoryChannel> CreateCategoryAsync(string name, RequestOptions options = null); | ||||
Task<IReadOnlyCollection<IGuildIntegration>> GetIntegrationsAsync(RequestOptions options = null); | Task<IReadOnlyCollection<IGuildIntegration>> GetIntegrationsAsync(RequestOptions options = null); | ||||
@@ -103,14 +122,20 @@ namespace Discord | |||||
/// <summary> Gets a collection of all invites to this guild. </summary> | /// <summary> Gets a collection of all invites to this guild. </summary> | ||||
Task<IReadOnlyCollection<IInviteMetadata>> GetInvitesAsync(RequestOptions options = null); | Task<IReadOnlyCollection<IInviteMetadata>> GetInvitesAsync(RequestOptions options = null); | ||||
/// <summary> Gets the role in this guild with the provided id, or null if not found. </summary> | |||||
/// <summary> Gets the role in this guild with the provided ID, or null if not found. </summary> | |||||
/// <param name="id"> The role ID. </param> | |||||
IRole GetRole(ulong id); | IRole GetRole(ulong id); | ||||
/// <summary> Creates a new role. </summary> | |||||
/// <summary> Creates a new role with the provided name. </summary> | |||||
/// <param name="name"> The new name for the role. </param> | |||||
/// <param name="permissions"> The guild permission that the role should possess. </param> | |||||
/// <param name="color"> The color of the role. </param> | |||||
/// <param name="isHoisted"> Whether the role is separated from others on the sidebar. </param> | |||||
Task<IRole> CreateRoleAsync(string name, GuildPermissions? permissions = null, Color? color = null, bool isHoisted = false, RequestOptions options = null); | Task<IRole> CreateRoleAsync(string name, GuildPermissions? permissions = null, Color? color = null, bool isHoisted = false, RequestOptions options = null); | ||||
/// <summary> Gets a collection of all users in this guild. </summary> | /// <summary> Gets a collection of all users in this guild. </summary> | ||||
Task<IReadOnlyCollection<IGuildUser>> GetUsersAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); //TODO: shouldnt this be paged? | Task<IReadOnlyCollection<IGuildUser>> GetUsersAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); //TODO: shouldnt this be paged? | ||||
/// <summary> Gets the user in this guild with the provided id, or null if not found. </summary> | |||||
/// <summary> Gets the user in this guild with the provided ID, or null if not found. </summary> | |||||
/// <param name="id"> The user ID. </param> | |||||
Task<IGuildUser> GetUserAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<IGuildUser> GetUserAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
/// <summary> Gets the current user for this guild. </summary> | /// <summary> Gets the current user for this guild. </summary> | ||||
Task<IGuildUser> GetCurrentUserAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | Task<IGuildUser> GetCurrentUserAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null); | ||||
@@ -119,20 +144,29 @@ namespace Discord | |||||
/// <summary> Downloads all users for this guild if the current list is incomplete. </summary> | /// <summary> Downloads all users for this guild if the current list is incomplete. </summary> | ||||
Task DownloadUsersAsync(); | Task DownloadUsersAsync(); | ||||
/// <summary> Removes all users from this guild if they have not logged on in a provided number of days or, if simulate is true, returns the number of users that would be removed. </summary> | /// <summary> Removes all users from this guild if they have not logged on in a provided number of days or, if simulate is true, returns the number of users that would be removed. </summary> | ||||
/// <param name="days"> The number of days required for the users to be kicked. </param> | |||||
/// <param name="simulate"> Whether this prune action is a simulation. </param> | |||||
/// <return> The number of users removed from this guild. </return> | |||||
Task<int> PruneUsersAsync(int days = 30, bool simulate = false, RequestOptions options = null); | Task<int> PruneUsersAsync(int days = 30, bool simulate = false, RequestOptions options = null); | ||||
/// <summary> Gets the webhook in this guild with the provided id, or null if not found. </summary> | |||||
/// <summary> Gets the webhook in this guild with the provided ID, or null if not found. </summary> | |||||
/// <param name="id"> The webhook ID. </param> | |||||
Task<IWebhook> GetWebhookAsync(ulong id, RequestOptions options = null); | Task<IWebhook> GetWebhookAsync(ulong id, RequestOptions options = null); | ||||
/// <summary> Gets a collection of all webhooks for this guild. </summary> | /// <summary> Gets a collection of all webhooks for this guild. </summary> | ||||
Task<IReadOnlyCollection<IWebhook>> GetWebhooksAsync(RequestOptions options = null); | Task<IReadOnlyCollection<IWebhook>> GetWebhooksAsync(RequestOptions options = null); | ||||
/// <summary> Gets a specific emote from this guild. </summary> | /// <summary> Gets a specific emote from this guild. </summary> | ||||
/// <param name="id"> The guild emote ID. </param> | |||||
Task<GuildEmote> GetEmoteAsync(ulong id, RequestOptions options = null); | Task<GuildEmote> GetEmoteAsync(ulong id, RequestOptions options = null); | ||||
/// <summary> Creates a new emote in this guild. </summary> | /// <summary> Creates a new emote in this guild. </summary> | ||||
/// <param name="name"> The name of the guild emote. </param> | |||||
/// <param name="image"> The image of the new emote. </param> | |||||
/// <param name="roles"> The roles to limit the emote usage to. </param> | |||||
Task<GuildEmote> CreateEmoteAsync(string name, Image image, Optional<IEnumerable<IRole>> roles = default(Optional<IEnumerable<IRole>>), RequestOptions options = null); | Task<GuildEmote> CreateEmoteAsync(string name, Image image, Optional<IEnumerable<IRole>> roles = default(Optional<IEnumerable<IRole>>), RequestOptions options = null); | ||||
/// <summary> Modifies an existing emote in this guild. </summary> | /// <summary> Modifies an existing emote in this guild. </summary> | ||||
Task<GuildEmote> ModifyEmoteAsync(GuildEmote emote, Action<EmoteProperties> func, RequestOptions options = null); | Task<GuildEmote> ModifyEmoteAsync(GuildEmote emote, Action<EmoteProperties> func, RequestOptions options = null); | ||||
/// <summary> Deletes an existing emote from this guild. </summary> | /// <summary> Deletes an existing emote from this guild. </summary> | ||||
/// <param name="emote"> The guild emote to delete. </param> | |||||
Task DeleteEmoteAsync(GuildEmote emote, RequestOptions options = null); | Task DeleteEmoteAsync(GuildEmote emote, RequestOptions options = null); | ||||
} | } | ||||
} | |||||
} |
@@ -34,30 +34,53 @@ namespace Discord.WebSocket | |||||
private ImmutableArray<string> _features; | private ImmutableArray<string> _features; | ||||
private AudioClient _audioClient; | private AudioClient _audioClient; | ||||
/// <inheritdoc /> | |||||
public string Name { get; private set; } | public string Name { get; private set; } | ||||
/// <inheritdoc /> | |||||
public int AFKTimeout { get; private set; } | public int AFKTimeout { get; private set; } | ||||
/// <inheritdoc /> | |||||
public bool IsEmbeddable { get; private set; } | public bool IsEmbeddable { get; private set; } | ||||
/// <inheritdoc /> | |||||
public VerificationLevel VerificationLevel { get; private set; } | public VerificationLevel VerificationLevel { get; private set; } | ||||
/// <inheritdoc /> | |||||
public MfaLevel MfaLevel { get; private set; } | public MfaLevel MfaLevel { get; private set; } | ||||
/// <inheritdoc /> | |||||
public DefaultMessageNotifications DefaultMessageNotifications { get; private set; } | public DefaultMessageNotifications DefaultMessageNotifications { get; private set; } | ||||
/// <summary> Gets the number of members. </summary> | |||||
/// <remark> | |||||
/// The number of members is returned by Discord and is the most accurate. | |||||
/// You may see discrepancy between the Users collection and this. | |||||
/// </remark> | |||||
public int MemberCount { get; internal set; } | public int MemberCount { get; internal set; } | ||||
/// <summary> Gets the number of members downloaded to the local guild cache. </summary> | |||||
public int DownloadedMemberCount { get; private set; } | public int DownloadedMemberCount { get; private set; } | ||||
internal bool IsAvailable { get; private set; } | internal bool IsAvailable { get; private set; } | ||||
/// <summary> Indicates whether the client is connected to this guild. </summary> | |||||
public bool IsConnected { get; internal set; } | public bool IsConnected { get; internal set; } | ||||
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; } | internal ulong? SystemChannelId { get; private set; } | ||||
/// <inheritdoc /> | |||||
public ulong OwnerId { get; private set; } | public ulong OwnerId { get; private set; } | ||||
/// <summary> Gets the user that owns this guild. </summary> | |||||
public SocketGuildUser Owner => GetUser(OwnerId); | public SocketGuildUser Owner => GetUser(OwnerId); | ||||
/// <inheritdoc /> | |||||
public string VoiceRegionId { get; private set; } | public string VoiceRegionId { get; private set; } | ||||
/// <inheritdoc /> | |||||
public string IconId { get; private set; } | public string IconId { get; private set; } | ||||
/// <inheritdoc /> | |||||
public string SplashId { get; private set; } | public string SplashId { get; private set; } | ||||
/// <inheritdoc /> | |||||
public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id); | public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id); | ||||
/// <inheritdoc /> | |||||
public string IconUrl => CDN.GetGuildIconUrl(Id, IconId); | public string IconUrl => CDN.GetGuildIconUrl(Id, IconId); | ||||
/// <inheritdoc /> | |||||
public string SplashUrl => CDN.GetGuildSplashUrl(Id, SplashId); | public string SplashUrl => CDN.GetGuildSplashUrl(Id, SplashId); | ||||
/// <summary> Indicates whether the client has all the members downloaded to the local guild cache. </summary> | |||||
public bool HasAllMembers => MemberCount == DownloadedMemberCount;// _downloaderPromise.Task.IsCompleted; | public bool HasAllMembers => MemberCount == DownloadedMemberCount;// _downloaderPromise.Task.IsCompleted; | ||||
/// <summary> Indicates whether the guild cache is synced to this guild. </summary> | |||||
public bool IsSynced => _syncPromise.Task.IsCompleted; | public bool IsSynced => _syncPromise.Task.IsCompleted; | ||||
public Task SyncPromise => _syncPromise.Task; | public Task SyncPromise => _syncPromise.Task; | ||||
public Task DownloaderPromise => _downloaderPromise.Task; | public Task DownloaderPromise => _downloaderPromise.Task; | ||||
@@ -270,32 +293,43 @@ namespace Discord.WebSocket | |||||
} | } | ||||
//General | //General | ||||
/// <inheritdoc /> | |||||
public Task DeleteAsync(RequestOptions options = null) | public Task DeleteAsync(RequestOptions options = null) | ||||
=> GuildHelper.DeleteAsync(this, Discord, options); | => GuildHelper.DeleteAsync(this, Discord, options); | ||||
/// <inheritdoc /> | |||||
public Task ModifyAsync(Action<GuildProperties> func, RequestOptions options = null) | public Task ModifyAsync(Action<GuildProperties> func, RequestOptions options = null) | ||||
=> GuildHelper.ModifyAsync(this, Discord, func, options); | => GuildHelper.ModifyAsync(this, Discord, func, options); | ||||
/// <inheritdoc /> | |||||
public Task ModifyEmbedAsync(Action<GuildEmbedProperties> func, RequestOptions options = null) | public Task ModifyEmbedAsync(Action<GuildEmbedProperties> func, RequestOptions options = null) | ||||
=> GuildHelper.ModifyEmbedAsync(this, Discord, func, options); | => GuildHelper.ModifyEmbedAsync(this, Discord, func, options); | ||||
/// <inheritdoc /> | |||||
public Task ReorderChannelsAsync(IEnumerable<ReorderChannelProperties> args, RequestOptions options = null) | public Task ReorderChannelsAsync(IEnumerable<ReorderChannelProperties> args, RequestOptions options = null) | ||||
=> GuildHelper.ReorderChannelsAsync(this, Discord, args, options); | => GuildHelper.ReorderChannelsAsync(this, Discord, args, options); | ||||
/// <inheritdoc /> | |||||
public Task ReorderRolesAsync(IEnumerable<ReorderRoleProperties> args, RequestOptions options = null) | public Task ReorderRolesAsync(IEnumerable<ReorderRoleProperties> args, RequestOptions options = null) | ||||
=> GuildHelper.ReorderRolesAsync(this, Discord, args, options); | => GuildHelper.ReorderRolesAsync(this, Discord, args, options); | ||||
/// <inheritdoc /> | |||||
public Task LeaveAsync(RequestOptions options = null) | public Task LeaveAsync(RequestOptions options = null) | ||||
=> GuildHelper.LeaveAsync(this, Discord, options); | => GuildHelper.LeaveAsync(this, Discord, options); | ||||
//Bans | //Bans | ||||
/// <summary> Gets a collection of the banned users in this guild. </summary> | |||||
public Task<IReadOnlyCollection<RestBan>> GetBansAsync(RequestOptions options = null) | public Task<IReadOnlyCollection<RestBan>> GetBansAsync(RequestOptions options = null) | ||||
=> GuildHelper.GetBansAsync(this, Discord, options); | => GuildHelper.GetBansAsync(this, Discord, options); | ||||
/// <inheritdoc /> | |||||
public Task AddBanAsync(IUser user, int pruneDays = 0, string reason = null, RequestOptions options = null) | public Task AddBanAsync(IUser user, int pruneDays = 0, string reason = null, RequestOptions options = null) | ||||
=> GuildHelper.AddBanAsync(this, Discord, user.Id, pruneDays, reason, options); | => GuildHelper.AddBanAsync(this, Discord, user.Id, pruneDays, reason, options); | ||||
/// <inheritdoc /> | |||||
public Task AddBanAsync(ulong userId, int pruneDays = 0, string reason = null, RequestOptions options = null) | public Task AddBanAsync(ulong userId, int pruneDays = 0, string reason = null, RequestOptions options = null) | ||||
=> GuildHelper.AddBanAsync(this, Discord, userId, pruneDays, reason, options); | => GuildHelper.AddBanAsync(this, Discord, userId, pruneDays, reason, options); | ||||
/// <inheritdoc /> | |||||
public Task RemoveBanAsync(IUser user, RequestOptions options = null) | public Task RemoveBanAsync(IUser user, RequestOptions options = null) | ||||
=> GuildHelper.RemoveBanAsync(this, Discord, user.Id, options); | => GuildHelper.RemoveBanAsync(this, Discord, user.Id, options); | ||||
/// <inheritdoc /> | |||||
public Task RemoveBanAsync(ulong userId, RequestOptions options = null) | public Task RemoveBanAsync(ulong userId, RequestOptions options = null) | ||||
=> GuildHelper.RemoveBanAsync(this, Discord, userId, options); | => GuildHelper.RemoveBanAsync(this, Discord, userId, options); | ||||
@@ -441,12 +475,16 @@ namespace Discord.WebSocket | |||||
=> GuildHelper.GetWebhooksAsync(this, Discord, options); | => GuildHelper.GetWebhooksAsync(this, Discord, options); | ||||
//Emotes | //Emotes | ||||
/// <inheritdoc /> | |||||
public Task<GuildEmote> GetEmoteAsync(ulong id, RequestOptions options = null) | public Task<GuildEmote> GetEmoteAsync(ulong id, RequestOptions options = null) | ||||
=> GuildHelper.GetEmoteAsync(this, Discord, id, options); | => GuildHelper.GetEmoteAsync(this, Discord, id, options); | ||||
/// <inheritdoc /> | |||||
public Task<GuildEmote> CreateEmoteAsync(string name, Image image, Optional<IEnumerable<IRole>> roles = default(Optional<IEnumerable<IRole>>), RequestOptions options = null) | public Task<GuildEmote> CreateEmoteAsync(string name, Image image, Optional<IEnumerable<IRole>> roles = default(Optional<IEnumerable<IRole>>), RequestOptions options = null) | ||||
=> GuildHelper.CreateEmoteAsync(this, Discord, name, image, roles, options); | => GuildHelper.CreateEmoteAsync(this, Discord, name, image, roles, options); | ||||
/// <inheritdoc /> | |||||
public Task<GuildEmote> ModifyEmoteAsync(GuildEmote emote, Action<EmoteProperties> func, RequestOptions options = null) | public Task<GuildEmote> ModifyEmoteAsync(GuildEmote emote, Action<EmoteProperties> func, RequestOptions options = null) | ||||
=> GuildHelper.ModifyEmoteAsync(this, Discord, emote.Id, func, options); | => GuildHelper.ModifyEmoteAsync(this, Discord, emote.Id, func, options); | ||||
/// <inheritdoc /> | |||||
public Task DeleteEmoteAsync(GuildEmote emote, RequestOptions options = null) | public Task DeleteEmoteAsync(GuildEmote emote, RequestOptions options = null) | ||||
=> GuildHelper.DeleteEmoteAsync(this, Discord, emote.Id, options); | => GuildHelper.DeleteEmoteAsync(this, Discord, emote.Id, options); | ||||
@@ -630,71 +668,105 @@ namespace Discord.WebSocket | |||||
internal SocketGuild Clone() => MemberwiseClone() as SocketGuild; | internal SocketGuild Clone() => MemberwiseClone() as SocketGuild; | ||||
//IGuild | //IGuild | ||||
/// <inheritdoc /> | |||||
ulong? IGuild.AFKChannelId => AFKChannelId; | ulong? IGuild.AFKChannelId => AFKChannelId; | ||||
/// <inheritdoc /> | |||||
IAudioClient IGuild.AudioClient => null; | IAudioClient IGuild.AudioClient => null; | ||||
/// <inheritdoc /> | |||||
bool IGuild.Available => true; | bool IGuild.Available => true; | ||||
/// <inheritdoc /> | |||||
ulong IGuild.DefaultChannelId => DefaultChannel?.Id ?? 0; | ulong IGuild.DefaultChannelId => DefaultChannel?.Id ?? 0; | ||||
/// <inheritdoc /> | |||||
ulong? IGuild.EmbedChannelId => EmbedChannelId; | ulong? IGuild.EmbedChannelId => EmbedChannelId; | ||||
/// <inheritdoc /> | |||||
ulong? IGuild.SystemChannelId => SystemChannelId; | ulong? IGuild.SystemChannelId => SystemChannelId; | ||||
/// <inheritdoc /> | |||||
IRole IGuild.EveryoneRole => EveryoneRole; | IRole IGuild.EveryoneRole => EveryoneRole; | ||||
/// <inheritdoc /> | |||||
IReadOnlyCollection<IRole> IGuild.Roles => Roles; | IReadOnlyCollection<IRole> IGuild.Roles => Roles; | ||||
/// <inheritdoc /> | |||||
async Task<IReadOnlyCollection<IBan>> IGuild.GetBansAsync(RequestOptions options) | async Task<IReadOnlyCollection<IBan>> IGuild.GetBansAsync(RequestOptions options) | ||||
=> await GetBansAsync(options).ConfigureAwait(false); | => await GetBansAsync(options).ConfigureAwait(false); | ||||
/// <inheritdoc /> | |||||
Task<IReadOnlyCollection<IGuildChannel>> IGuild.GetChannelsAsync(CacheMode mode, RequestOptions options) | Task<IReadOnlyCollection<IGuildChannel>> IGuild.GetChannelsAsync(CacheMode mode, RequestOptions options) | ||||
=> Task.FromResult<IReadOnlyCollection<IGuildChannel>>(Channels); | => Task.FromResult<IReadOnlyCollection<IGuildChannel>>(Channels); | ||||
/// <inheritdoc /> | |||||
Task<IGuildChannel> IGuild.GetChannelAsync(ulong id, CacheMode mode, RequestOptions options) | Task<IGuildChannel> IGuild.GetChannelAsync(ulong id, CacheMode mode, RequestOptions options) | ||||
=> Task.FromResult<IGuildChannel>(GetChannel(id)); | => Task.FromResult<IGuildChannel>(GetChannel(id)); | ||||
/// <inheritdoc /> | |||||
Task<IReadOnlyCollection<ITextChannel>> IGuild.GetTextChannelsAsync(CacheMode mode, RequestOptions options) | Task<IReadOnlyCollection<ITextChannel>> IGuild.GetTextChannelsAsync(CacheMode mode, RequestOptions options) | ||||
=> Task.FromResult<IReadOnlyCollection<ITextChannel>>(TextChannels); | => Task.FromResult<IReadOnlyCollection<ITextChannel>>(TextChannels); | ||||
/// <inheritdoc /> | |||||
Task<ITextChannel> IGuild.GetTextChannelAsync(ulong id, CacheMode mode, RequestOptions options) | Task<ITextChannel> IGuild.GetTextChannelAsync(ulong id, CacheMode mode, RequestOptions options) | ||||
=> Task.FromResult<ITextChannel>(GetTextChannel(id)); | => Task.FromResult<ITextChannel>(GetTextChannel(id)); | ||||
/// <inheritdoc /> | |||||
Task<IReadOnlyCollection<IVoiceChannel>> IGuild.GetVoiceChannelsAsync(CacheMode mode, RequestOptions options) | Task<IReadOnlyCollection<IVoiceChannel>> IGuild.GetVoiceChannelsAsync(CacheMode mode, RequestOptions options) | ||||
=> Task.FromResult<IReadOnlyCollection<IVoiceChannel>>(VoiceChannels); | => Task.FromResult<IReadOnlyCollection<IVoiceChannel>>(VoiceChannels); | ||||
/// <inheritdoc /> | |||||
Task<IReadOnlyCollection<ICategoryChannel>> IGuild.GetCategoriesAsync(CacheMode mode , RequestOptions options) | Task<IReadOnlyCollection<ICategoryChannel>> IGuild.GetCategoriesAsync(CacheMode mode , RequestOptions options) | ||||
=> Task.FromResult<IReadOnlyCollection<ICategoryChannel>>(CategoryChannels); | => Task.FromResult<IReadOnlyCollection<ICategoryChannel>>(CategoryChannels); | ||||
/// <inheritdoc /> | |||||
Task<IVoiceChannel> IGuild.GetVoiceChannelAsync(ulong id, CacheMode mode, RequestOptions options) | Task<IVoiceChannel> IGuild.GetVoiceChannelAsync(ulong id, CacheMode mode, RequestOptions options) | ||||
=> Task.FromResult<IVoiceChannel>(GetVoiceChannel(id)); | => Task.FromResult<IVoiceChannel>(GetVoiceChannel(id)); | ||||
/// <inheritdoc /> | |||||
Task<IVoiceChannel> IGuild.GetAFKChannelAsync(CacheMode mode, RequestOptions options) | Task<IVoiceChannel> IGuild.GetAFKChannelAsync(CacheMode mode, RequestOptions options) | ||||
=> Task.FromResult<IVoiceChannel>(AFKChannel); | => Task.FromResult<IVoiceChannel>(AFKChannel); | ||||
/// <inheritdoc /> | |||||
Task<ITextChannel> IGuild.GetDefaultChannelAsync(CacheMode mode, RequestOptions options) | Task<ITextChannel> IGuild.GetDefaultChannelAsync(CacheMode mode, RequestOptions options) | ||||
=> Task.FromResult<ITextChannel>(DefaultChannel); | => Task.FromResult<ITextChannel>(DefaultChannel); | ||||
/// <inheritdoc /> | |||||
Task<IGuildChannel> IGuild.GetEmbedChannelAsync(CacheMode mode, RequestOptions options) | Task<IGuildChannel> IGuild.GetEmbedChannelAsync(CacheMode mode, RequestOptions options) | ||||
=> Task.FromResult<IGuildChannel>(EmbedChannel); | => Task.FromResult<IGuildChannel>(EmbedChannel); | ||||
/// <inheritdoc /> | |||||
Task<ITextChannel> IGuild.GetSystemChannelAsync(CacheMode mode, RequestOptions options) | Task<ITextChannel> IGuild.GetSystemChannelAsync(CacheMode mode, RequestOptions options) | ||||
=> Task.FromResult<ITextChannel>(SystemChannel); | => Task.FromResult<ITextChannel>(SystemChannel); | ||||
/// <inheritdoc /> | |||||
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); | ||||
/// <inheritdoc /> | |||||
async Task<IVoiceChannel> IGuild.CreateVoiceChannelAsync(string name, RequestOptions options) | async Task<IVoiceChannel> IGuild.CreateVoiceChannelAsync(string name, RequestOptions options) | ||||
=> await CreateVoiceChannelAsync(name, options).ConfigureAwait(false); | => await CreateVoiceChannelAsync(name, options).ConfigureAwait(false); | ||||
/// <inheritdoc /> | |||||
async Task<ICategoryChannel> IGuild.CreateCategoryAsync(string name, RequestOptions options) | async Task<ICategoryChannel> IGuild.CreateCategoryAsync(string name, RequestOptions options) | ||||
=> await CreateCategoryChannelAsync(name, options).ConfigureAwait(false); | => await CreateCategoryChannelAsync(name, options).ConfigureAwait(false); | ||||
/// <inheritdoc /> | |||||
async Task<IReadOnlyCollection<IGuildIntegration>> IGuild.GetIntegrationsAsync(RequestOptions options) | async Task<IReadOnlyCollection<IGuildIntegration>> IGuild.GetIntegrationsAsync(RequestOptions options) | ||||
=> await GetIntegrationsAsync(options).ConfigureAwait(false); | => await GetIntegrationsAsync(options).ConfigureAwait(false); | ||||
/// <inheritdoc /> | |||||
async Task<IGuildIntegration> IGuild.CreateIntegrationAsync(ulong id, string type, RequestOptions options) | async Task<IGuildIntegration> IGuild.CreateIntegrationAsync(ulong id, string type, RequestOptions options) | ||||
=> await CreateIntegrationAsync(id, type, options).ConfigureAwait(false); | => await CreateIntegrationAsync(id, type, options).ConfigureAwait(false); | ||||
/// <inheritdoc /> | |||||
async Task<IReadOnlyCollection<IInviteMetadata>> IGuild.GetInvitesAsync(RequestOptions options) | async Task<IReadOnlyCollection<IInviteMetadata>> IGuild.GetInvitesAsync(RequestOptions options) | ||||
=> await GetInvitesAsync(options).ConfigureAwait(false); | => await GetInvitesAsync(options).ConfigureAwait(false); | ||||
/// <inheritdoc /> | |||||
IRole IGuild.GetRole(ulong id) | IRole IGuild.GetRole(ulong id) | ||||
=> GetRole(id); | => GetRole(id); | ||||
/// <inheritdoc /> | |||||
async Task<IRole> IGuild.CreateRoleAsync(string name, GuildPermissions? permissions, Color? color, bool isHoisted, RequestOptions options) | async Task<IRole> IGuild.CreateRoleAsync(string name, GuildPermissions? permissions, Color? color, bool isHoisted, RequestOptions options) | ||||
=> await CreateRoleAsync(name, permissions, color, isHoisted, options).ConfigureAwait(false); | => await CreateRoleAsync(name, permissions, color, isHoisted, options).ConfigureAwait(false); | ||||
/// <inheritdoc /> | |||||
Task<IReadOnlyCollection<IGuildUser>> IGuild.GetUsersAsync(CacheMode mode, RequestOptions options) | Task<IReadOnlyCollection<IGuildUser>> IGuild.GetUsersAsync(CacheMode mode, RequestOptions options) | ||||
=> Task.FromResult<IReadOnlyCollection<IGuildUser>>(Users); | => Task.FromResult<IReadOnlyCollection<IGuildUser>>(Users); | ||||
/// <inheritdoc /> | |||||
Task<IGuildUser> IGuild.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) | Task<IGuildUser> IGuild.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) | ||||
=> Task.FromResult<IGuildUser>(GetUser(id)); | => Task.FromResult<IGuildUser>(GetUser(id)); | ||||
/// <inheritdoc /> | |||||
Task<IGuildUser> IGuild.GetCurrentUserAsync(CacheMode mode, RequestOptions options) | Task<IGuildUser> IGuild.GetCurrentUserAsync(CacheMode mode, RequestOptions options) | ||||
=> Task.FromResult<IGuildUser>(CurrentUser); | => Task.FromResult<IGuildUser>(CurrentUser); | ||||
/// <inheritdoc /> | |||||
Task<IGuildUser> IGuild.GetOwnerAsync(CacheMode mode, RequestOptions options) | Task<IGuildUser> IGuild.GetOwnerAsync(CacheMode mode, RequestOptions options) | ||||
=> Task.FromResult<IGuildUser>(Owner); | => Task.FromResult<IGuildUser>(Owner); | ||||
/// <inheritdoc /> | |||||
async Task<IWebhook> IGuild.GetWebhookAsync(ulong id, RequestOptions options) | async Task<IWebhook> IGuild.GetWebhookAsync(ulong id, RequestOptions options) | ||||
=> await GetWebhookAsync(id, options); | => await GetWebhookAsync(id, options); | ||||
/// <inheritdoc /> | |||||
async Task<IReadOnlyCollection<IWebhook>> IGuild.GetWebhooksAsync(RequestOptions options) | async Task<IReadOnlyCollection<IWebhook>> IGuild.GetWebhooksAsync(RequestOptions options) | ||||
=> await GetWebhooksAsync(options); | => await GetWebhooksAsync(options); | ||||
} | } | ||||