curious.dataclasses.guild

Wrappers for Guild objects.

Classes

ContentFilterLevel Represents the content filter level for a Guild.
Guild(bot, **kwargs) Represents a guild object on Discord.
GuildBan(*args, **kwargs) Represents a ban in a guild.
GuildBanContainer(guild) A container for guild bans.
GuildChannelWrapper(guild, channels, …) A wrapper for channels on a guild.
GuildEmojiWrapper(guild, emojis, …) Wrapper for emoji objects for a guild.
GuildRoleWrapper(guild, roles, …) A wrapper for roles on a guild.
MFALevel Represents the MFA level of a Guild.
NotificationLevel Represents the default notification level for a Guild.
VerificationLevel Represents the verification levels for a Guild.
class curious.dataclasses.guild.ContentFilterLevel[source]

Bases: enum.IntEnum

Represents the content filter level for a Guild.

class curious.dataclasses.guild.Guild(bot, **kwargs) → None[source]

Bases: curious.dataclasses.bases.Dataclass

Represents a guild object on Discord.

Inspects the stack to ensure we’re being called correctly.

_handle_emojis(emojis)[source]

Handles the emojis for this guild.

Parameters:emojis (List[dict]) – A list of emoji objects from Discord.
_handle_member_chunk(members)[source]

Handles a chunk of members.

Parameters:members (list) – A list of member data dictionaries as returned from Discord.
afk_channel
Return type:Optional[Channel]
Returns:A Channel representing the AFK channel for this guild.
await ban(victim, *, delete_message_days=7)[source]

This function is deprecated since 0.7.0. See :meth:().GuildBanContainer.add`` instead. It will be removed at version 0.9.0.

Bans somebody from the guild.

This can either ban a Member, in which they must be in the guild. Or this can ban a User, which does not need to be in the guild.

Example for banning a member:

member = guild.members[66237334693085184]
await guild.ban(member)

Example for banning a user:

user = await client.get_user(66237334693085184)
await guild.ban(user)
Parameters:
Return type:

GuildBan

await change_icon(icon_content)[source]

Changes the icon for this guild.

Parameters:icon_content (bytes) – The bytes that represent the icon of the guild.
await change_role_positions(roles)[source]

Changes the positions of a mapping of roles.

Parameters:roles (Union[Dict[Role, int], List[Tuple[Role, int]]]) – A dict or iterable of two-item tuples of new roles that is in the format of (role, position).
await change_voice_state(member, *, deaf=None, mute=None)[source]

Changes the voice state of a member.

Parameters:
default_role
Return type:Optional[Role]
Returns:A Role that represents the default role of this guild.
await delete_webhook(webhook)[source]

Deletes a webhook in this guild.

Parameters:webhook (Webhook) – The Webhook to delete.
dnd_members
Return type:Generator[Member, None, None]
Returns:A generator of DnD Member objects.
await edit_widget(*, status=None, channel=-1)[source]

Edits the widget for this guild.

Parameters:
  • status (Optional[bool]) – The status of this widget: True or False.
  • channel (Channel) – The channel object to set the instant invite to.
embed_url

Gets the default embed url for this guild. If the widget is not enabled, this endpoint will 404.

Return type:str
Returns:The embed URL for this guild.
find_member(search_str)[source]

This function is deprecated since 0.7.0. See :meth:().Guild.search_for_member`` instead. It will be removed at version 0.9.0.

Attempts to find a member in this guild by name#discrim. This will also search nicknames.

The discriminator is optional, but if provided allows better matching.

Parameters:search_str (str) – The name#discrim pair to search for.
Return type:Member
Returns:A Member object that represents the member, or None if no member could be found.
from_guild_create(**data)[source]

Populates the fields from a GUILD_CREATE event.

Parameters:data (dict) – The GUILD_CREATE data to use.
Return type:Guild
get_embed_url(*, style='banner1')[source]

Gets an embed URL for this guild in a specified style.

Parameters:style (str) – The style to get.
Return type:str
Returns:The embed URL for this guild.
await get_invites()[source]

Gets the invites for this guild. :rtype: List[Invite] :return: A list Invite objects.

await get_vanity_invite()[source]

Gets the vanity Invite for this guild.

Return type:Union[None, Invite]
Returns:The Invite that corresponds with this guild, if it has one.
await get_webhooks()[source]

Gets the webhooks for this guild.

Return type:List[Webhook]
Returns:A list of Webhook objects for the guild.
await get_widget_info()[source]

Gets the widget info for the current guild.

Return type:Tuple[bool, Union[None, Channel]]
Returns:A two-item tuple: If this widget is enabled, and the channel the widget has an invite for.
icon_url
Return type:str
Returns:The icon URL for this guild, or None if one isn’t set.
idle_members
Return type:Generator[Member, None, None]
Returns:A generator of idle Member objects.
invites
Return type:AsyncIterator[Invite]
Returns:A class:.AsyncIteratorWrapper that yields Invite objects for this guild.
await kick(victim)[source]

Kicks somebody from the guild.

Parameters:victim (Member) – The Member to kick.
large
Return type:bool
Returns:If this guild is large or not (>= 250 members).
await leave()[source]

Leaves the guild.

Return type:None
me
Return type:Optional[Member]
Returns:A Member object that represents the current user in this guild.
members
Return type:Mapping[int, Member]
Returns:A mapping of Member that represent members on this guild.
for ... in members_with_status(status)[source]

A generator that returns the members that match the specified status.

Return type:Generator[Member, None, None]
await modify_guild(*, afk_channel=None, verification_level=None, content_filter_level=None, notification_level=None, **kwargs)[source]

Edits this guild.

For a list of available arguments, see https://discordapp.com/developers/docs/resources/guild#modify-guild.

Parameters:
offline_members
Return type:Generator[Member, None, None]
Returns:A generator of offline/invisible Member objects.
online_members
Return type:Generator[Member, None, None]
Returns:A generator of online Member objects.
owner
Return type:Optional[Member]
Returns:A Member object that represents the owner of this guild.
presence_count
Return type:int
Returns:The number of members with a non-Invisible presence.
search
Return type:SearchQuery
Returns:A SearchQuery that can be used to search this guild’s messages.
search_for_member(*, name=None, discriminator=None, full_name=None)[source]

Searches for a member.

Parameters:
  • name (Optional[str]) – The username or nickname of the member.
  • discriminator (Optional[str]) – The discriminator of the member.
  • full_name (Optional[str]) – The full name (i.e. username#discrim) of the member. Optional; will be split up into the correct parameters.

Warning

Using a username and discriminator pair is most accurate when finding a user; a nickname pair or not providing one of the arguments might not find the right member.

Returns:A Member that matched, or None if no matches were found.
await set_vanity_invite(url)[source]

Sets the vanity Invite for this guild.

Parameters:url (str) – The code to use for this guild.
Return type:Optional[Invite]
Returns:The Invite produced.
snowflake_timestamp
Return type:datetime
Returns:The timestamp of the snowflake.
splash_url
Return type:str
Returns:The splash URL for this guild, or None if one isn’t set.
start_chunking()[source]

Marks a guild to start guild chunking.

This will clear the chunking event, and calculate the number of member chunks required.

Return type:None
system_channel
Return type:Optional[Channel]
Returns:A Channel that represents the system channel for this guild.
await unban(user)[source]

This function is deprecated since 0.7.0. See :meth:().GuildBanContainer.remove`` instead. It will be removed at version 0.9.0.

Unbans a user from this guild. Example for unbanning the first banned user:

user = next(await guild.get_bans())
await guild.unban(user)

To unban an arbitrary user, use Client.get_user().

user = await client.get_user(66237334693085184)
await guild.unban(user)

Note

This does not take Member objects, as members cannot be in a guild and banned from the guild.

Parameters:user (User) – The User to forgive and unban.
Return type:None
await upload_icon(path)[source]

Uploads a new icon for the guild.

Parameters:path (PathLike) – A path-like object to use to upload.
await wait_until_chunked()[source]

Waits until the guild has finished chunking.

Useful for when you join a big guild.

Return type:None
class curious.dataclasses.guild.GuildBan(*args, **kwargs)[source]

Bases: object

Represents a ban in a guild.

class curious.dataclasses.guild.GuildBanContainer(guild: curious.dataclasses.guild.Guild)[source]

Bases: object

A container for guild bans.

await add(victim, *, delete_message_days, reason=None)[source]

Bans somebody from the guild.

This can either ban a Member, in which they must be in the guild. Or this can ban a User, which does not need to be in the guild.

Example for banning a member:

member = guild.members[66237334693085184]
await guild.ban(member)

Example for banning a user:

user = await client.get_user(66237334693085184)
await guild.ban(user)
Parameters:
Return type:

GuildBan

await ban(*args, **kwargs)[source]

Shortcut for GuildBanWrapper.add().

Return type:GuildBan
await flatten()[source]

Gets all the bans for this guild.

Return type:List[GuildBan]
await remove(user, *, reason=None)[source]

Unbans a user from this guild. Example for unbanning the first banned user:

user = next(await guild.get_bans())
await guild.unban(user)

To unban an arbitrary user, use Client.get_user().

user = await client.get_user(66237334693085184)
await guild.unban(user)

Note

This does not take Member objects, as members cannot be in a guild and banned from the guild.

Parameters:
  • user (User) – The User to forgive and unban.
  • reason (Optional[str]) – The reason given for unbanning.
Return type:

None

await unban(*args, **kwargs)[source]

Shortcut for GuildBanWrapper.remove().

Return type:None
class curious.dataclasses.guild.GuildChannelWrapper(guild: curious.dataclasses.guild.Guild, channels: typing.MutableMapping[int, curious.dataclasses.channel.Channel])[source]

Bases: curious.dataclasses.guild._WrapperBase

A wrapper for channels on a guild. This provides some convenience methods which make channel management more fluent.

Parameters:
_get_by_name(name, default=None)[source]

Gets a channel by name.

Warning

This will return the first channel in the channel list. If you want to get a channel in a specific category, use Channel.get_by_name()

Parameters:
  • name (str) – The name of the channel to get.
  • default (Optional[~T]) – The default value to get, if the channel cannot be found.
Return type:

Union[Channel, ~T]

Returns:

A Channel if it can be found.

await create(name, type_=None, permission_overwrites=None, *, parent=None, bitrate=64, user_limit=0, topic=None)[source]

Creates a new channel.

Parameters:

For guild channels:

Parameters:parent (Optional[Channel]) – The parent Channel for this channel.

For voice channels:

Parameters:
  • bitrate (int) – The bitrate of the channel, if it is a voice channel, in kbit/s.
  • user_limit (int) – The maximum number of users that can be in the channel.

For text channels:

Parameters:topic (Optional[str]) – The topic of the channel, or None to set no topic.
Return type:Channel
delete(channel)[source]

Deletes a channel.

edit(channel, **kwargs)[source]

Edits a channel.

get(key, default=None)[source]

Gets a channel by name or ID.

Parameters:
  • key (Union[str, int]) – The key to use. This can be the ID of the channel, or the name of the channel.
  • default (Optional[~T]) – The default value to use, if the channel cannot be found.
Return type:

Union[Channel, ~T]

Returns:

A Channel, if it was found.

items() → a set-like object providing a view on D's items
keys() → a set-like object providing a view on D's keys
values() → an object providing a view on D's values
view
Return type:Mapping[int, Channel]
Returns:A read-only view into the channels for this wrapper.
class curious.dataclasses.guild.GuildEmojiWrapper(guild: curious.dataclasses.guild.Guild, emojis: typing.MutableMapping[int, curious.dataclasses.emoji.Emoji])[source]

Bases: curious.dataclasses.guild._WrapperBase

Wrapper for emoji objects for a guild.

Parameters:
await create(*, name, image_data, roles=None)[source]

Creates a new emoji in this guild.

Parameters:
  • name (str) – The name of the emoji.
  • image_data (Union[str, bytes]) – The bytes image data or the str base64 data for the emoji.
  • roles (Optional[List[Role]]) – A list of roles this emoji is locked to.
Return type:

Emoji

Returns:

The Emoji created.

get(k[, d]) → D[k] if k in D, else d. d defaults to None.
items() → a set-like object providing a view on D's items
keys() → a set-like object providing a view on D's keys
values() → an object providing a view on D's values
view
Return type:Mapping[int, Emoji]
Returns:A read-only view into the channels for this wrapper.
class curious.dataclasses.guild.GuildRoleWrapper(guild: curious.dataclasses.guild.Guild, roles: typing.MutableMapping[int, curious.dataclasses.role.Role])[source]

Bases: curious.dataclasses.guild._WrapperBase

A wrapper for roles on a guild. Contains some convenience methods that make role management more fluent.

Parameters:
_get_by_name(name, default=None)[source]

Gets a role by name.

Parameters:
  • name (str) – The name of the channel to get.
  • default (Optional[~T]) – The default value to get, if the role cannot be found.
Return type:

Union[Role, ~T]

Returns:

A Role if it can be found.

await create(**kwargs)[source]

Creates a new role in this guild.

Return type:Role
Returns:A new Role.
delete(role)[source]

Deletes a role.

edit(role, **kwargs)[source]

Edits a role.

get(key, default=None)[source]

Gets a role by name or ID.

Parameters:
  • key (Union[str, int]) – The key to use. This can be the ID of the role, or the name of the role.
  • default (Optional[~T]) – The default value to use, if the role cannot be found.
Return type:

Union[Role, ~T]

Returns:

A Role, if it was found.

items() → a set-like object providing a view on D's items
keys() → a set-like object providing a view on D's keys
values() → an object providing a view on D's values
view
Return type:Mapping[int, Role]
Returns:A read-only view into the channels for this wrapper.
class curious.dataclasses.guild.MFALevel[source]

Bases: enum.IntEnum

Represents the MFA level of a Guild.

class curious.dataclasses.guild.NotificationLevel[source]

Bases: enum.IntEnum

Represents the default notification level for a Guild.

class curious.dataclasses.guild.VerificationLevel[source]

Bases: enum.IntEnum

Represents the verification levels for a Guild.

class curious.dataclasses.guild._WrapperBase[source]

Bases: collections.abc.Mapping, collections.abc.Iterable

Represents the base class for a wrapper object.

get(k[, d]) → D[k] if k in D, else d. d defaults to None.
items() → a set-like object providing a view on D's items
keys() → a set-like object providing a view on D's keys
values() → an object providing a view on D's values
view

Represents a read-only view for this wrapper.

Return type:Mapping[int, Dataclass]