Class SocketGuild
Represents a WebSocket-based guild object.
Inherited Members
Namespace: Kook.WebSocket
Assembly: Kook.Net.WebSocket.dll
Syntax
public class SocketGuild : SocketEntity<ulong>, IEntity<ulong>, IGuild, IEntity<ulong>, IDisposable, IUpdateable
Properties
AutoDeleteTime
Banner
BoostLevel
Gets the level of guild boosting in this guild.
Declaration
public BoostLevel BoostLevel { get; }
Property Value
BoostLevel
The level of guild boosting in this guild. |
Implements
BoostSubscriptionCount
BoostSubscriptions
Gets a dictionary of all boost subscriptions for this guild.
Declaration
public ImmutableDictionary<IUser, IReadOnlyCollection<BoostSubscriptionMetadata>> BoostSubscriptions { get; }
Property Value
ImmutableDictionary<IUser, IReadOnlyCollection<BoostSubscriptionMetadata>>
A read-only dictionary containing all boost subscription metadata for this guild grouped by users;
or |
Remarks
warning
Only when AlwaysDownloadBoostSubscriptions is set to true
will this property be populated upon startup. Due to the lack of event support for boost subscriptions,
this property will never be updated. The changes of BoostSubscriptionCount will trigger the update
of this property, but KOOK gateway will not publish this event resulting from the changes of total boost subscription
count. To fetch the latest boost subscription data, use DownloadBoostSubscriptionsAsync(RequestOptions) or
DownloadBoostSubscriptionsAsync(IEnumerable<IGuild>, RequestOptions) upon a KookSocketClient to
manually download the latest boost subscription data, or GetBoostSubscriptionsAsync(RequestOptions).
See Also
BufferBoostSubscriptionCount
CategoryChannels
Gets a collection of all stage channels in this guild.
Declaration
public IReadOnlyCollection<SocketCategoryChannel> CategoryChannels { get; }
Property Value
IReadOnlyCollection<SocketCategoryChannel>
A read-only collection of stage channels found within this guild. |
Channels
Gets a collection of all channels in this guild.
Declaration
public IReadOnlyCollection<SocketGuildChannel> Channels { get; }
Property Value
IReadOnlyCollection<SocketGuildChannel>
A read-only collection of generic channels found within this guild. |
CurrentUser
Gets the current logged-in user.
Declaration
public SocketGuildUser CurrentUser { get; }
Property Value
SocketGuildUser
|
DefaultChannel
Gets the default text channel for this guild.
Declaration
public SocketTextChannel DefaultChannel { get; }
Property Value
SocketTextChannel
A SocketTextChannel representing the default text channel for this guild. |
Remarks
This property retrieves default text channel for this guild.
DefaultChannelId
DownloadedMemberCount
Gets the number of members downloaded to the local guild cache.
Declaration
public int DownloadedMemberCount { get; }
Property Value
Int32
|
Emotes
Gets a collection of all custom emotes for this guild.
Declaration
public IReadOnlyCollection<GuildEmote> Emotes { get; }
Property Value
IReadOnlyCollection<GuildEmote>
A read-only collection of all custom emotes for this guild. |
See Also
EveryoneRole
Gets the built-in role containing all users in this guild.
Declaration
public SocketRole EveryoneRole { get; }
Property Value
SocketRole
A role object that represents an |
Features
Gets the features of this guild.
Declaration
public GuildFeatures Features { get; }
Property Value
GuildFeatures
An array of string representing the features of this guild. |
Implements
HasAllMembers
Indicates whether the client has all the members downloaded to the local guild cache.
Declaration
public bool? HasAllMembers { get; }
Property Value
Nullable<Boolean>
|
Remarks
warning
If MemberCount is null
, this property will always return null
,
which means that the client is unable to determine whether all the members are downloaded or not.
Icon
IsConnected
Indicates whether the client is connected to this guild.
Declaration
public bool IsConnected { get; }
Property Value
Boolean
|
IsOpenEnabled
MaxBitrate
MaxUploadLimit
MemberCount
Gets the number of members.
Declaration
public int? MemberCount { get; }
Property Value
Nullable<Int32>
|
Remarks
This property retrieves the number of members returned by Kook.
tip
Due to how this property is returned by Kook instead of relying on the WebSocket cache, the number here is the most accurate in terms of counting the number of users within this guild.
Use this instead of enumerating the count of the Users collection, as you may see discrepancy between that and this property.
warning
Only when AlwaysDownloadUsers is set to true
will this property be populated upon startup. Otherwise, this property will be null
,
and will be populated when DownloadUsersAsync(RequestOptions) is called.
Name
NotifyType
Gets the default notification type for this guild.
Declaration
public NotifyType NotifyType { get; }
Property Value
NotifyType
A NotifyType representing the default notification type for this guild. |
Implements
OpenId
Owner
Gets the user that owns this guild.
Declaration
public SocketGuildUser Owner { get; }
Property Value
SocketGuildUser
|
OwnerId
RecommendInfo
Gets the recommendation information for this guild.
Declaration
public RecommendInfo RecommendInfo { get; }
Property Value
RecommendInfo
A recommendation object that represents the recommendation information for this guild;
|
Region
Roles
Gets a collection of all roles in this guild.
Declaration
public IReadOnlyCollection<SocketRole> Roles { get; }
Property Value
IReadOnlyCollection<SocketRole>
A read-only collection of roles found within this guild. |
Remarks
warning
Due to the lack of event args which should contains the reordered roles data when roles are reordered, this property may not be completely accurate. To ensure the most accurate results, it is recommended to call UpdateAsync(RequestOptions) before this property is used.
Status
TextChannels
Gets a collection of all text channels in this guild.
Declaration
public IReadOnlyCollection<SocketTextChannel> TextChannels { get; }
Property Value
IReadOnlyCollection<SocketTextChannel>
A read-only collection of message channels found within this guild. |
Topic
Users
Gets a collection of users in this guild.
Declaration
public IReadOnlyCollection<SocketGuildUser> Users { get; }
Property Value
IReadOnlyCollection<SocketGuildUser>
A collection of guild users found within this guild. |
Remarks
This property retrieves all users found within this guild.
warning
This property may not always return all the members for large guilds (i.e. guilds containing 100+ users). If you are simply looking to get the number of users present in this guild, consider using MemberCount instead.
Otherwise, you may need to enable AlwaysDownloadUsers to fetch the full user list upon startup, or use DownloadUsersAsync(RequestOptions) to manually download the users.
See Also
ValidBoostSubscriptions
Gets a dictionary of all boost subscriptions which have not expired for this guild.
Declaration
public ImmutableDictionary<IUser, IReadOnlyCollection<BoostSubscriptionMetadata>> ValidBoostSubscriptions { get; }
Property Value
ImmutableDictionary<IUser, IReadOnlyCollection<BoostSubscriptionMetadata>>
A read-only dictionary containing all boost subscription metadata which have not expired for this guild grouped by users;
or |
Remarks
warning
Only when AlwaysDownloadBoostSubscriptions is set to true
will this property be populated upon startup. Due to the lack of event support for boost subscriptions,
this property will never be updated. The changes of BoostSubscriptionCount will trigger the update
of this property, but KOOK gateway will not publish this event resulting from the changes of total boost subscription
count. To fetch the latest boost subscription data, use DownloadBoostSubscriptionsAsync(RequestOptions) or
DownloadBoostSubscriptionsAsync(IEnumerable<IGuild>, RequestOptions) upon a KookSocketClient to
manually download the latest boost subscription data, or GetBoostSubscriptionsAsync(RequestOptions).
See Also
VoiceChannels
Gets a collection of all voice channels in this guild.
Declaration
public IReadOnlyCollection<SocketVoiceChannel> VoiceChannels { get; }
Property Value
IReadOnlyCollection<SocketVoiceChannel>
A read-only collection of voice channels found within this guild. |
WelcomeChannel
Gets the welcome text channel for this guild.
Declaration
public SocketTextChannel WelcomeChannel { get; }
Property Value
SocketTextChannel
A SocketTextChannel representing the default text channel for this guild. |
Remarks
This property retrieves default text channel for this guild.
WelcomeChannelId
Methods
AddBanAsync(IUser, Int32, String, RequestOptions)
Declaration
public Task AddBanAsync(IUser user, int pruneDays = 0, string reason = null, RequestOptions options = null)
Parameters
IUser
user
|
Int32
pruneDays
|
String
reason
|
RequestOptions
options
|
Returns
Task
|
AddBanAsync(UInt64, Int32, String, RequestOptions)
Declaration
public Task AddBanAsync(ulong userId, int pruneDays = 0, string reason = null, RequestOptions options = null)
Parameters
UInt64
userId
|
Int32
pruneDays
|
String
reason
|
RequestOptions
options
|
Returns
Task
|
CreateCategoryChannelAsync(String, Action<CreateCategoryChannelProperties>, RequestOptions)
Creates a new channel category in this guild.
Declaration
public Task<RestCategoryChannel> CreateCategoryChannelAsync(string name, Action<CreateCategoryChannelProperties> func = null, RequestOptions options = null)
Parameters
String
name
The new name for the category. |
Action<CreateCategoryChannelProperties>
func
The delegate containing the properties to be applied to the channel upon its creation. |
RequestOptions
options
The options to be used when sending the request. |
Returns
Task<RestCategoryChannel>
A task that represents the asynchronous creation operation. The task result contains the newly created category channel. |
CreateEmoteAsync(String, Image, RequestOptions)
Declaration
public Task<GuildEmote> CreateEmoteAsync(string name, Image image, RequestOptions options = null)
Parameters
String
name
|
Image
image
|
RequestOptions
options
|
Returns
Task<GuildEmote>
|
CreateInviteAsync(InviteMaxAge, InviteMaxUses, RequestOptions)
Declaration
public Task<IInvite> CreateInviteAsync(InviteMaxAge maxAge = default(InviteMaxAge), InviteMaxUses maxUses = default(InviteMaxUses), RequestOptions options = null)
Parameters
InviteMaxAge
maxAge
|
InviteMaxUses
maxUses
|
RequestOptions
options
|
Returns
Task<IInvite>
|
CreateInviteAsync(Nullable<Int32>, Nullable<Int32>, RequestOptions)
Declaration
public Task<IInvite> CreateInviteAsync(int? maxAge, int? maxUses = null, RequestOptions options = null)
Parameters
Nullable<Int32>
maxAge
|
Nullable<Int32>
maxUses
|
RequestOptions
options
|
Returns
Task<IInvite>
|
CreateRoleAsync(String, RequestOptions)
Creates a new role with the provided name.
Declaration
public Task<RestRole> CreateRoleAsync(string name, RequestOptions options = null)
Parameters
String
name
The new name for the role. |
RequestOptions
options
The options to be used when sending the request. |
Returns
Task<RestRole>
A task that represents the asynchronous creation operation. The task result contains the newly created role. |
CreateTextChannelAsync(String, Action<CreateTextChannelProperties>, RequestOptions)
Creates a new text channel in this guild.
Declaration
public Task<RestTextChannel> CreateTextChannelAsync(string name, Action<CreateTextChannelProperties> func = null, RequestOptions options = null)
Parameters
String
name
The new name for the text channel. |
Action<CreateTextChannelProperties>
func
The delegate containing the properties to be applied to the channel upon its creation. |
RequestOptions
options
The options to be used when sending the request. |
Returns
Task<RestTextChannel>
A task that represents the asynchronous creation operation. The task result contains the newly created text channel. |
CreateVoiceChannelAsync(String, Action<CreateVoiceChannelProperties>, RequestOptions)
Creates a new voice channel in this guild.
Declaration
public Task<RestVoiceChannel> CreateVoiceChannelAsync(string name, Action<CreateVoiceChannelProperties> func = null, RequestOptions options = null)
Parameters
String
name
The new name for the voice channel. |
Action<CreateVoiceChannelProperties>
func
The delegate containing the properties to be applied to the channel upon its creation. |
RequestOptions
options
The options to be used when sending the request. |
Returns
Task<RestVoiceChannel>
A task that represents the asynchronous creation operation. The task result contains the newly created voice channel. |
DeleteEmoteAsync(GuildEmote, RequestOptions)
Declaration
public Task DeleteEmoteAsync(GuildEmote emote, RequestOptions options = null)
Parameters
GuildEmote
emote
|
RequestOptions
options
|
Returns
Task
|
Dispose()
Declaration
public void Dispose()
DownloadBoostSubscriptionsAsync(RequestOptions)
Declaration
public Task DownloadBoostSubscriptionsAsync(RequestOptions options = null)
Parameters
RequestOptions
options
|
Returns
Task
|
DownloadUsersAsync(RequestOptions)
Declaration
public Task DownloadUsersAsync(RequestOptions options = null)
Parameters
RequestOptions
options
|
Returns
Task
|
DownloadVoiceStatesAsync(RequestOptions)
Declaration
public Task DownloadVoiceStatesAsync(RequestOptions options = null)
Parameters
RequestOptions
options
|
Returns
Task
|
GetActiveBoostSubscriptionsAsync(RequestOptions)
Declaration
public Task<ImmutableDictionary<IUser, IReadOnlyCollection<BoostSubscriptionMetadata>>> GetActiveBoostSubscriptionsAsync(RequestOptions options = null)
Parameters
RequestOptions
options
|
Returns
Task<ImmutableDictionary<IUser, IReadOnlyCollection<BoostSubscriptionMetadata>>>
|
GetBadgeAsync(BadgeStyle, RequestOptions)
Declaration
public Task<Stream> GetBadgeAsync(BadgeStyle style = default(BadgeStyle), RequestOptions options = null)
Parameters
BadgeStyle
style
|
RequestOptions
options
|
Returns
Task<Stream>
|
GetBanAsync(IUser, RequestOptions)
Gets a ban object for a banned user.
Declaration
public Task<RestBan> GetBanAsync(IUser user, RequestOptions options = null)
Parameters
IUser
user
The banned user. |
RequestOptions
options
The options to be used when sending the request. |
Returns
Task<RestBan>
A task that represents the asynchronous get operation. The task result contains a ban object, which
contains the user information and the reason for the ban; |
GetBanAsync(UInt64, RequestOptions)
Declaration
public Task<RestBan> GetBanAsync(ulong userId, RequestOptions options = null)
Parameters
UInt64
userId
|
RequestOptions
options
|
Returns
Task<RestBan>
|
GetBansAsync(RequestOptions)
Gets a collection of all users banned in this guild.
Declaration
public Task<IReadOnlyCollection<RestBan>> GetBansAsync(RequestOptions options = null)
Parameters
RequestOptions
options
The options to be used when sending the request. |
Returns
Task<IReadOnlyCollection<RestBan>>
A task that represents the asynchronous get operation. The task result contains a read-only collection of ban objects that this guild currently possesses, with each object containing the user banned and reason behind the ban. |
GetBoostSubscriptionsAsync(RequestOptions)
Declaration
public Task<ImmutableDictionary<IUser, IReadOnlyCollection<BoostSubscriptionMetadata>>> GetBoostSubscriptionsAsync(RequestOptions options = null)
Parameters
RequestOptions
options
|
Returns
Task<ImmutableDictionary<IUser, IReadOnlyCollection<BoostSubscriptionMetadata>>>
|
GetCategoryChannel(UInt64)
Gets a category channel in this guild.
Declaration
public SocketCategoryChannel GetCategoryChannel(ulong id)
Parameters
UInt64
id
The snowflake identifier for the category channel. |
Returns
SocketCategoryChannel
A category channel associated with the specified |
GetChannel(UInt64)
Gets a channel in this guild.
Declaration
public SocketGuildChannel GetChannel(ulong id)
Parameters
UInt64
id
The identifier for the channel. |
Returns
SocketGuildChannel
A generic channel associated with the specified |
GetEmote(String)
Gets a guild emoji in this guild.
Declaration
public GuildEmote GetEmote(string id)
Parameters
String
id
The identifier for the guild emoji. |
Returns
GuildEmote
A guild emoji associated with the specified |
GetEmoteAsync(String, RequestOptions)
Declaration
public Task<GuildEmote> GetEmoteAsync(string id, RequestOptions options = null)
Parameters
String
id
|
RequestOptions
options
|
Returns
Task<GuildEmote>
|
GetEmotesAsync(RequestOptions)
Declaration
public Task<IReadOnlyCollection<GuildEmote>> GetEmotesAsync(RequestOptions options = null)
Parameters
RequestOptions
options
|
Returns
Task<IReadOnlyCollection<GuildEmote>>
|
GetInvitesAsync(RequestOptions)
Declaration
public Task<IReadOnlyCollection<IInvite>> GetInvitesAsync(RequestOptions options = null)
Parameters
RequestOptions
options
|
Returns
Task<IReadOnlyCollection<IInvite>>
|
GetRole(UInt32)
Gets a role in this guild.
Declaration
public SocketRole GetRole(uint id)
Parameters
UInt32
id
The identifier for the role. |
Returns
SocketRole
A role that is associated with the specified |
GetTextChannel(UInt64)
Gets a text channel in this guild.
Declaration
public SocketTextChannel GetTextChannel(ulong id)
Parameters
UInt64
id
The identifier for the text channel. |
Returns
SocketTextChannel
A text channel associated with the specified |
GetUser(UInt64)
Gets a user from this guild.
Declaration
public SocketGuildUser GetUser(ulong id)
Parameters
UInt64
id
The identifier of the user. |
Returns
SocketGuildUser
A guild user associated with the specified |
Remarks
This method retrieves a user found within this guild.
note
This may return null
in the WebSocket implementation due to incomplete user collection in
large guilds.
GetUsersAsync(RequestOptions)
Gets a collection of all users in this guild.
Declaration
public IAsyncEnumerable<IReadOnlyCollection<IGuildUser>> GetUsersAsync(RequestOptions options = null)
Parameters
RequestOptions
options
The options to be used when sending the request. |
Returns
IAsyncEnumerable<IReadOnlyCollection<IGuildUser>>
A task that represents the asynchronous get operation. The task result contains a collection of guild users found within this guild. |
Remarks
This method retrieves all users found within this guild through REST.
Users returned by this method are not cached.
GetVoiceChannel(UInt64)
Gets a voice channel in this guild.
Declaration
public SocketVoiceChannel GetVoiceChannel(ulong id)
Parameters
UInt64
id
The identifier for the voice channel. |
Returns
SocketVoiceChannel
A voice channel associated with the specified |
LeaveAsync(RequestOptions)
Declaration
public Task LeaveAsync(RequestOptions options = null)
Parameters
RequestOptions
options
|
Returns
Task
|
ModifyEmoteNameAsync(GuildEmote, String, RequestOptions)
Declaration
public Task ModifyEmoteNameAsync(GuildEmote emote, string name, RequestOptions options = null)
Parameters
GuildEmote
emote
|
String
name
|
RequestOptions
options
|
Returns
Task
|
MoveUsersAsync(IEnumerable<IGuildUser>, IVoiceChannel, RequestOptions)
Declaration
public Task MoveUsersAsync(IEnumerable<IGuildUser> users, IVoiceChannel targetChannel, RequestOptions options = null)
Parameters
IEnumerable<IGuildUser>
users
|
IVoiceChannel
targetChannel
|
RequestOptions
options
|
Returns
Task
|
PurgeUserCache()
Purges this guild's user cache.
Declaration
public void PurgeUserCache()
PurgeUserCache(Func<SocketGuildUser, Boolean>)
Purges this guild's user cache.
Declaration
public void PurgeUserCache(Func<SocketGuildUser, bool> predicate)
Parameters
Func<SocketGuildUser, Boolean>
predicate
The predicate used to select which users to clear. |
RemoveBanAsync(IUser, RequestOptions)
Declaration
public Task RemoveBanAsync(IUser user, RequestOptions options = null)
Parameters
IUser
user
|
RequestOptions
options
|
Returns
Task
|
RemoveBanAsync(UInt64, RequestOptions)
Declaration
public Task RemoveBanAsync(ulong userId, RequestOptions options = null)
Parameters
UInt64
userId
|
RequestOptions
options
|
Returns
Task
|
SearchUsersAsync(Action<SearchGuildMemberProperties>, Int32, RequestOptions)
Gets a collection of users in this guild that the name or nickname contains the
provided string at func
.
Declaration
public IAsyncEnumerable<IReadOnlyCollection<RestGuildUser>> SearchUsersAsync(Action<SearchGuildMemberProperties> func, int limit = null, RequestOptions options = null)
Parameters
Action<SearchGuildMemberProperties>
func
A delegate containing the properties to search users with. |
Int32
limit
The maximum number of users to be gotten. |
RequestOptions
options
The options to be used when sending the request. |
Returns
IAsyncEnumerable<IReadOnlyCollection<RestGuildUser>>
A task that represents the asynchronous get operation. The task result contains a collection of guild
users that matches the properties with the provided |
Remarks
The limit
can not be higher than MaxUsersPerBatch.
ToString()
Gets the name of the guild.
Declaration
public override string ToString()
Returns
String
A string that resolves to Name. |
UpdateAsync(RequestOptions)
Declaration
public Task UpdateAsync(RequestOptions options = null)
Parameters
RequestOptions
options
|
Returns
Task
|
Explicit Interface Implementations
IGuild.EveryoneRole
Gets the built-in role containing all users in this guild.
Declaration
IRole IGuild.EveryoneRole { get; }
Returns
IRole
A role object that represents an |
Implements
IGuild.RecommendInfo
Gets the recommendation information for this guild.
Declaration
IRecommendInfo IGuild.RecommendInfo { get; }
Returns
IRecommendInfo
A recommendation object that represents the recommendation information for this guild;
|