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 aUser
, 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:
-
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
) – TheWebhook
to delete.
-
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 listInvite
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.
-
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
) – TheMember
to kick.
-
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: - afk_channel (
Optional
[Channel
]) – TheChannel
that represents the AFK voice channel. - verification_level (
Optional
[VerificationLevel
]) – TheVerificationLevel
to use for this guild. - content_filter_level (
Optional
[ContentFilterLevel
]) – TheContentFilterLevel
to use for this guild. - notification_level (
Optional
[NotificationLevel
]) – TheNotificationLevel
to use for this guild.
- afk_channel (
-
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.
-
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: 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.
-
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
) – TheUser
to forgive and unban.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 aUser
, 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:
-
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: Return type: None
-
await
-
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: - guild (
Guild
) – TheGuild
object that owns this wrapper. - channels (
MutableMapping
[int
,Channel
]) – The dictionary of channels that this wrapper contains.
-
_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: Return type: 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: - name (
str
) – The name of the channel. - type (
Optional
[ChannelType
]) – TheChannelType
of the channel. - permission_overwrites (
Optional
[List
[Overwrite
]]) – The list of permission overwrites to use for this channel.
For guild channels:
Parameters: parent ( Optional
[Channel
]) – The parentChannel
for this channel.For voice channels:
Parameters: For text channels:
Parameters: topic ( Optional
[str
]) – The topic of the channel, or None to set no topic.Return type: Channel
- name (
-
get
(key, default=None)[source]¶ Gets a channel by name or ID.
Parameters: Return type: 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¶
- guild (
-
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: - guild (
Guild
) – TheGuild
object that owns this wrapper. - emojis (
MutableMapping
[int
,Emoji
]) – The dictionary of emojis that this wrapper contains.
-
await
create
(*, name, image_data, roles=None)[source]¶ Creates a new emoji in this guild.
Parameters: Return type: 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¶
- guild (
-
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: - guild (
Guild
) – TheGuild
object that owns this wrapper. - roles (
MutableMapping
[int
,Role
]) – The dictionary of roles that this wrapper contains.
-
_get_by_name
(name, default=None)[source]¶ Gets a role by name.
Parameters: Return type: 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
.
-
get
(key, default=None)[source]¶ Gets a role by name or ID.
Parameters: Return type: 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¶
- guild (
-
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¶
-