hikari.invites
Application and entities that are used to describe invites on Discord.
View Source
# -*- coding: utf-8 -*- # cython: language_level=3 # Copyright (c) 2020 Nekokatt # Copyright (c) 2021-present davfsa # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. """Application and entities that are used to describe invites on Discord.""" from __future__ import annotations __all__: typing.Sequence[str] = ( "TargetType", "VanityURL", "InviteGuild", "InviteCode", "Invite", "InviteWithMetadata", ) import abc import typing import attr from hikari import guilds from hikari import urls from hikari.internal import attr_extensions from hikari.internal import enums from hikari.internal import routes if typing.TYPE_CHECKING: import datetime from hikari import applications from hikari import channels from hikari import files from hikari import snowflakes from hikari import traits from hikari import users @typing.final class TargetType(int, enums.Enum): """The target of the invite.""" STREAM = 1 """This invite is targeting a "Go Live" stream.""" EMBEDDED_APPLICATION = 2 """This invite is targeting an embedded application.""" class InviteCode(abc.ABC): """A representation of a guild/channel invite.""" __slots__: typing.Sequence[str] = () @property @abc.abstractmethod def code(self) -> str: """Code for this invite.""" def __str__(self) -> str: return f"https://discord.gg/{self.code}" @attr_extensions.with_copy @attr.define(hash=True, kw_only=True, weakref_slot=False) class VanityURL(InviteCode): """A special case invite object, that represents a guild's vanity url.""" app: traits.RESTAware = attr.field( repr=False, eq=False, hash=False, metadata={attr_extensions.SKIP_DEEP_COPY: True} ) """The client application that models may use for procedures.""" code: str = attr.field(hash=True, repr=True) """The code for this invite.""" uses: int = attr.field(eq=False, hash=False, repr=True) """The amount of times this invite has been used.""" @attr.define(hash=True, kw_only=True, weakref_slot=False) class InviteGuild(guilds.PartialGuild): """Represents the partial data of a guild that is attached to invites.""" features: typing.Sequence[typing.Union[guilds.GuildFeature, int]] = attr.field(eq=False, hash=False, repr=False) """A list of the features in this guild.""" splash_hash: typing.Optional[str] = attr.field(eq=False, hash=False, repr=False) """The hash of the splash for the guild, if there is one.""" banner_hash: typing.Optional[str] = attr.field(eq=False, hash=False, repr=False) """The hash for the guild's banner. This is only present if `hikari.guilds.GuildFeature.BANNER` is in the `features` for this guild. For all other purposes, it is `None`. """ description: typing.Optional[str] = attr.field(eq=False, hash=False, repr=False) """The guild's description. This is only present if certain `features` are set in this guild. Otherwise, this will always be `None`. For all other purposes, it is `None`. """ verification_level: typing.Union[guilds.GuildVerificationLevel, int] = attr.field(eq=False, hash=False, repr=False) """The verification level required for a user to participate in this guild.""" vanity_url_code: typing.Optional[str] = attr.field(eq=False, hash=False, repr=True) """The vanity URL code for the guild's vanity URL. This is only present if `hikari.guilds.GuildFeature.VANITY_URL` is in the `features` for this guild. If not, this will always be `None`. """ welcome_screen: typing.Optional[guilds.WelcomeScreen] = attr.field(eq=False, hash=False, repr=False) """The welcome screen of a community guild shown to new members, if set.""" nsfw_level: guilds.GuildNSFWLevel = attr.field(eq=False, hash=False, repr=False) """The NSFW level of the guild.""" @property def splash_url(self) -> typing.Optional[files.URL]: """Splash URL for the guild, if set.""" return self.make_splash_url() def make_splash_url(self, *, ext: str = "png", size: int = 4096) -> typing.Optional[files.URL]: """Generate the guild's splash image URL, if set. Parameters ---------- ext : str The extension to use for this URL, defaults to `png`. Supports `png`, `jpeg`, `jpg` and `webp`. size : int The size to set for the URL, defaults to `4096`. Can be any power of two between 16 and 4096. Returns ------- typing.Optional[hikari.files.URL] The URL to the splash, or `None` if not set. Raises ------ ValueError If `size` is not a power of two or not between 16 and 4096. """ if self.splash_hash is None: return None return routes.CDN_GUILD_SPLASH.compile_to_file( urls.CDN_URL, guild_id=self.id, hash=self.splash_hash, size=size, file_format=ext, ) @property def banner_url(self) -> typing.Optional[files.URL]: """Banner URL for the guild, if set.""" return self.make_banner_url() def make_banner_url(self, *, ext: typing.Optional[str] = None, size: int = 4096) -> typing.Optional[files.URL]: """Generate the guild's banner image URL, if set. Parameters ---------- ext : typing.Optional[str] The ext to use for this URL, defaults to `png` or `gif`. Supports `png`, `jpeg`, `jpg`, `webp` and `gif` (when animated). If `None`, then the correct default extension is determined based on whether the banner is animated or not. size : int The size to set for the URL, defaults to `4096`. Can be any power of two between 16 and 4096. Returns ------- typing.Optional[hikari.files.URL] The URL of the banner, or `None` if no banner is set. Raises ------ ValueError If `size` is not a power of two or not between 16 and 4096. """ if self.banner_hash is None: return None if ext is None: if self.banner_hash.startswith("a_"): ext = "gif" else: ext = "png" return routes.CDN_GUILD_BANNER.compile_to_file( urls.CDN_URL, guild_id=self.id, hash=self.banner_hash, size=size, file_format=ext, ) @attr_extensions.with_copy @attr.define(hash=True, kw_only=True, weakref_slot=False) class Invite(InviteCode): """Represents an invite that's used to add users to a guild or group dm.""" app: traits.RESTAware = attr.field( repr=False, eq=False, hash=False, metadata={attr_extensions.SKIP_DEEP_COPY: True} ) """The client application that models may use for procedures.""" code: str = attr.field(hash=True, repr=True) """The code for this invite.""" guild: typing.Optional[InviteGuild] = attr.field(eq=False, hash=False, repr=False) """The partial object of the guild this invite belongs to. Will be `None` for group DM invites and when attached to a gateway event; for invites received over the gateway you should refer to `Invite.guild_id`. """ guild_id: typing.Optional[snowflakes.Snowflake] = attr.field(eq=False, hash=False, repr=True) """The ID of the guild this invite belongs to. Will be `None` for group DM invites. """ channel: typing.Optional[channels.PartialChannel] = attr.field(eq=False, hash=False, repr=False) """The partial object of the channel this invite targets. Will be `None` for invite objects that are attached to gateway events, in which case you should refer to `Invite.channel_id`. """ channel_id: snowflakes.Snowflake = attr.field(eq=False, hash=False, repr=True) """The ID of the channel this invite targets.""" inviter: typing.Optional[users.User] = attr.field(eq=False, hash=False, repr=False) """The object of the user who created this invite.""" target_type: typing.Union[TargetType, int, None] = attr.ib(eq=False, hash=False, repr=False) """The type of the target of this invite, if applicable.""" target_user: typing.Optional[users.User] = attr.field(eq=False, hash=False, repr=False) """The object of the user who this invite targets, if set.""" target_application: typing.Optional[applications.InviteApplication] = attr.ib(eq=False, hash=False, repr=False) """The embedded application this invite targets, if applicable.""" approximate_active_member_count: typing.Optional[int] = attr.field(eq=False, hash=False, repr=False) """The approximate amount of presences in this invite's guild. This is only returned by the GET REST Invites endpoint. """ approximate_member_count: typing.Optional[int] = attr.field(eq=False, hash=False, repr=False) """The approximate amount of members in this invite's guild. This is only returned by the GET Invites REST endpoint. """ expires_at: typing.Optional[datetime.datetime] = attr.field(eq=False, hash=False, repr=False) """When this invite will expire. This field is only returned by the GET Invite REST endpoint and will be returned as `None` by said endpoint if the invite doesn't have a set expiry date. Other places will always return this as `None`. """ @attr.define(hash=True, kw_only=True, weakref_slot=False) class InviteWithMetadata(Invite): """Extends the base `Invite` object with metadata. The metadata is only returned when getting an invite with guild permissions, rather than it's code. """ uses: int = attr.field(eq=False, hash=False, repr=True) """The amount of times this invite has been used.""" max_uses: typing.Optional[int] = attr.field(eq=False, hash=False, repr=True) """The limit for how many times this invite can be used before it expires. If set to `None` then this is unlimited. """ # TODO: can we use a non-None value to represent infinity here somehow, or # make a timedelta that is infinite for comparisons? max_age: typing.Optional[datetime.timedelta] = attr.field(eq=False, hash=False, repr=False) """The timedelta of how long this invite will be valid for. If set to `None` then this is unlimited. """ is_temporary: bool = attr.field(eq=False, hash=False, repr=True) """Whether this invite grants temporary membership.""" created_at: datetime.datetime = attr.field(eq=False, hash=False, repr=False) """When this invite was created.""" expires_at: typing.Optional[datetime.datetime] """When this invite will expire. If this invite doesn't have a set expiry then this will be `None`. """ @property def uses_left(self) -> typing.Optional[int]: """Return the number of uses left for this invite. This will be `None` if the invite has unlimited uses. """ if self.max_uses: return self.max_uses - self.uses return None
View Source
@attr_extensions.with_copy @attr.define(hash=True, kw_only=True, weakref_slot=False) class Invite(InviteCode): """Represents an invite that's used to add users to a guild or group dm.""" app: traits.RESTAware = attr.field( repr=False, eq=False, hash=False, metadata={attr_extensions.SKIP_DEEP_COPY: True} ) """The client application that models may use for procedures.""" code: str = attr.field(hash=True, repr=True) """The code for this invite.""" guild: typing.Optional[InviteGuild] = attr.field(eq=False, hash=False, repr=False) """The partial object of the guild this invite belongs to. Will be `None` for group DM invites and when attached to a gateway event; for invites received over the gateway you should refer to `Invite.guild_id`. """ guild_id: typing.Optional[snowflakes.Snowflake] = attr.field(eq=False, hash=False, repr=True) """The ID of the guild this invite belongs to. Will be `None` for group DM invites. """ channel: typing.Optional[channels.PartialChannel] = attr.field(eq=False, hash=False, repr=False) """The partial object of the channel this invite targets. Will be `None` for invite objects that are attached to gateway events, in which case you should refer to `Invite.channel_id`. """ channel_id: snowflakes.Snowflake = attr.field(eq=False, hash=False, repr=True) """The ID of the channel this invite targets.""" inviter: typing.Optional[users.User] = attr.field(eq=False, hash=False, repr=False) """The object of the user who created this invite.""" target_type: typing.Union[TargetType, int, None] = attr.ib(eq=False, hash=False, repr=False) """The type of the target of this invite, if applicable.""" target_user: typing.Optional[users.User] = attr.field(eq=False, hash=False, repr=False) """The object of the user who this invite targets, if set.""" target_application: typing.Optional[applications.InviteApplication] = attr.ib(eq=False, hash=False, repr=False) """The embedded application this invite targets, if applicable.""" approximate_active_member_count: typing.Optional[int] = attr.field(eq=False, hash=False, repr=False) """The approximate amount of presences in this invite's guild. This is only returned by the GET REST Invites endpoint. """ approximate_member_count: typing.Optional[int] = attr.field(eq=False, hash=False, repr=False) """The approximate amount of members in this invite's guild. This is only returned by the GET Invites REST endpoint. """ expires_at: typing.Optional[datetime.datetime] = attr.field(eq=False, hash=False, repr=False) """When this invite will expire. This field is only returned by the GET Invite REST endpoint and will be returned as `None` by said endpoint if the invite doesn't have a set expiry date. Other places will always return this as `None`. """
Represents an invite that's used to add users to a guild or group dm.
Variables and properties
The client application that models may use for procedures.
The approximate amount of presences in this invite's guild.
This is only returned by the GET REST Invites endpoint.
The approximate amount of members in this invite's guild.
This is only returned by the GET Invites REST endpoint.
The partial object of the channel this invite targets.
Will be None
for invite objects that are attached to gateway events, in which case you should refer to Invite.channel_id
.
The ID of the channel this invite targets.
The code for this invite.
When this invite will expire.
This field is only returned by the GET Invite REST endpoint and will be returned as None
by said endpoint if the invite doesn't have a set expiry date. Other places will always return this as None
.
The partial object of the guild this invite belongs to.
Will be None
for group DM invites and when attached to a gateway event; for invites received over the gateway you should refer to Invite.guild_id
.
The ID of the guild this invite belongs to.
Will be None
for group DM invites.
The object of the user who created this invite.
The embedded application this invite targets, if applicable.
The type of the target of this invite, if applicable.
The object of the user who this invite targets, if set.
Methods
self,
*,
app: hikari.traits.RESTAware,
code: str,
guild: Optional[hikari.invites.InviteGuild],
guild_id: Optional[hikari.snowflakes.Snowflake],
channel: Optional[hikari.channels.PartialChannel],
channel_id: hikari.snowflakes.Snowflake,
inviter: Optional[hikari.users.User],
target_type: Union[hikari.invites.TargetType, int, NoneType],
target_user: Optional[hikari.users.User],
target_application: Optional[hikari.applications.InviteApplication],
approximate_active_member_count: Optional[int],
approximate_member_count: Optional[int],
expires_at: Optional[datetime.datetime]
):
View Source
def __init__(self, *, app, code, guild, guild_id, channel, channel_id, inviter, target_type, target_user, target_application, approximate_active_member_count, approximate_member_count, expires_at): self.app = app self.code = code self.guild = guild self.guild_id = guild_id self.channel = channel self.channel_id = channel_id self.inviter = inviter self.target_type = target_type self.target_user = target_user self.target_application = target_application self.approximate_active_member_count = approximate_active_member_count self.approximate_member_count = approximate_member_count self.expires_at = expires_at
Method generated by attrs for class Invite.
View Source
class InviteCode(abc.ABC): """A representation of a guild/channel invite.""" __slots__: typing.Sequence[str] = () @property @abc.abstractmethod def code(self) -> str: """Code for this invite.""" def __str__(self) -> str: return f"https://discord.gg/{self.code}"
A representation of a guild/channel invite.
Variables and properties
Code for this invite.
View Source
@attr.define(hash=True, kw_only=True, weakref_slot=False) class InviteGuild(guilds.PartialGuild): """Represents the partial data of a guild that is attached to invites.""" features: typing.Sequence[typing.Union[guilds.GuildFeature, int]] = attr.field(eq=False, hash=False, repr=False) """A list of the features in this guild.""" splash_hash: typing.Optional[str] = attr.field(eq=False, hash=False, repr=False) """The hash of the splash for the guild, if there is one.""" banner_hash: typing.Optional[str] = attr.field(eq=False, hash=False, repr=False) """The hash for the guild's banner. This is only present if `hikari.guilds.GuildFeature.BANNER` is in the `features` for this guild. For all other purposes, it is `None`. """ description: typing.Optional[str] = attr.field(eq=False, hash=False, repr=False) """The guild's description. This is only present if certain `features` are set in this guild. Otherwise, this will always be `None`. For all other purposes, it is `None`. """ verification_level: typing.Union[guilds.GuildVerificationLevel, int] = attr.field(eq=False, hash=False, repr=False) """The verification level required for a user to participate in this guild.""" vanity_url_code: typing.Optional[str] = attr.field(eq=False, hash=False, repr=True) """The vanity URL code for the guild's vanity URL. This is only present if `hikari.guilds.GuildFeature.VANITY_URL` is in the `features` for this guild. If not, this will always be `None`. """ welcome_screen: typing.Optional[guilds.WelcomeScreen] = attr.field(eq=False, hash=False, repr=False) """The welcome screen of a community guild shown to new members, if set.""" nsfw_level: guilds.GuildNSFWLevel = attr.field(eq=False, hash=False, repr=False) """The NSFW level of the guild.""" @property def splash_url(self) -> typing.Optional[files.URL]: """Splash URL for the guild, if set.""" return self.make_splash_url() def make_splash_url(self, *, ext: str = "png", size: int = 4096) -> typing.Optional[files.URL]: """Generate the guild's splash image URL, if set. Parameters ---------- ext : str The extension to use for this URL, defaults to `png`. Supports `png`, `jpeg`, `jpg` and `webp`. size : int The size to set for the URL, defaults to `4096`. Can be any power of two between 16 and 4096. Returns ------- typing.Optional[hikari.files.URL] The URL to the splash, or `None` if not set. Raises ------ ValueError If `size` is not a power of two or not between 16 and 4096. """ if self.splash_hash is None: return None return routes.CDN_GUILD_SPLASH.compile_to_file( urls.CDN_URL, guild_id=self.id, hash=self.splash_hash, size=size, file_format=ext, ) @property def banner_url(self) -> typing.Optional[files.URL]: """Banner URL for the guild, if set.""" return self.make_banner_url() def make_banner_url(self, *, ext: typing.Optional[str] = None, size: int = 4096) -> typing.Optional[files.URL]: """Generate the guild's banner image URL, if set. Parameters ---------- ext : typing.Optional[str] The ext to use for this URL, defaults to `png` or `gif`. Supports `png`, `jpeg`, `jpg`, `webp` and `gif` (when animated). If `None`, then the correct default extension is determined based on whether the banner is animated or not. size : int The size to set for the URL, defaults to `4096`. Can be any power of two between 16 and 4096. Returns ------- typing.Optional[hikari.files.URL] The URL of the banner, or `None` if no banner is set. Raises ------ ValueError If `size` is not a power of two or not between 16 and 4096. """ if self.banner_hash is None: return None if ext is None: if self.banner_hash.startswith("a_"): ext = "gif" else: ext = "png" return routes.CDN_GUILD_BANNER.compile_to_file( urls.CDN_URL, guild_id=self.id, hash=self.banner_hash, size=size, file_format=ext, )
Represents the partial data of a guild that is attached to invites.
Variables and properties
The client application that models may use for procedures.
When the object was created.
The guild's description.
This is only present if certain features
are set in this guild. Otherwise, this will always be None
. For all other purposes, it is None
.
A list of the features in this guild.
The hash for the guild icon, if there is one.
Icon URL for the guild, if set; otherwise None
.
The ID of this entity.
The name of the guild.
The NSFW level of the guild.
Return the ID of the shard this guild is served by.
This may return None
if the application does not have a gateway connection.
The hash of the splash for the guild, if there is one.
Splash URL for the guild, if set.
The vanity URL code for the guild's vanity URL.
This is only present if hikari.guilds.GuildFeature.VANITY_URL
is in the features
for this guild. If not, this will always be None
.
The verification level required for a user to participate in this guild.
The welcome screen of a community guild shown to new members, if set.
Methods
self,
*,
app: hikari.traits.RESTAware,
id: hikari.snowflakes.Snowflake,
icon_hash: Optional[str],
name: str,
features: Sequence[Union[hikari.guilds.GuildFeature, int]],
splash_hash: Optional[str],
banner_hash: Optional[str],
description: Optional[str],
verification_level: Union[hikari.guilds.GuildVerificationLevel, int],
vanity_url_code: Optional[str],
welcome_screen: Optional[hikari.guilds.WelcomeScreen],
nsfw_level: hikari.guilds.GuildNSFWLevel
):
View Source
def __init__(self, *, app, id, icon_hash, name, features, splash_hash, banner_hash, description, verification_level, vanity_url_code, welcome_screen, nsfw_level): self.app = app self.id = id self.icon_hash = icon_hash self.name = name self.features = features self.splash_hash = splash_hash self.banner_hash = banner_hash self.description = description self.verification_level = verification_level self.vanity_url_code = vanity_url_code self.welcome_screen = welcome_screen self.nsfw_level = nsfw_level
Method generated by attrs for class InviteGuild.
self,
user: Union[hikari.users.PartialUser, hikari.snowflakes.Snowflake, int],
*,
delete_message_days: Union[int, hikari.undefined.UndefinedType] = UNDEFINED,
reason: Union[str, hikari.undefined.UndefinedType] = UNDEFINED
) -> None:
View Source
async def ban( self, user: snowflakes.SnowflakeishOr[users.PartialUser], *, delete_message_days: undefined.UndefinedOr[int] = undefined.UNDEFINED, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> None: """Ban the given user from this guild. Parameters ---------- user: hikari.snowflakes.Snowflakeish[hikari.users.PartialUser] The user to ban from the guild Other Parameters ---------------- delete_message_days : hikari.undefined.UndefinedNoneOr[int] If provided, the number of days to delete messages for. This must be between 0 and 7. reason : hikari.undefined.UndefinedOr[str] If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters. Raises ------ hikari.errors.BadRequestError If any of the fields that are passed have an invalid value. hikari.errors.ForbiddenError If you are missing the `BAN_MEMBERS` permission. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild or user are not found. hikari.errors.RateLimitTooLongError Raised in the event that a rate limit occurs that is longer than `max_rate_limit` when making a request. hikari.errors.RateLimitedError Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur. hikari.errors.InternalServerError If an internal error occurs on Discord while handling the request. """ await self.app.rest.ban_user(self.id, user, delete_message_days=delete_message_days, reason=reason)
Ban the given user from this guild.
Parameters
- user (hikari.snowflakes.Snowflakeish[hikari.users.PartialUser]): The user to ban from the guild
Other Parameters
- delete_message_days (hikari.undefined.UndefinedNoneOr[int]): If provided, the number of days to delete messages for. This must be between 0 and 7.
- reason (hikari.undefined.UndefinedOr[str]): If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters.
Raises
- hikari.errors.BadRequestError: If any of the fields that are passed have an invalid value.
- hikari.errors.ForbiddenError: If you are missing the
BAN_MEMBERS
permission. - hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the guild or user are not found.
- hikari.errors.RateLimitTooLongError: Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. - hikari.errors.RateLimitedError: Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur.
- hikari.errors.InternalServerError: If an internal error occurs on Discord while handling the request.
self,
name: str,
*,
position: Union[int, hikari.undefined.UndefinedType] = UNDEFINED,
permission_overwrites: Union[Sequence[hikari.channels.PermissionOverwrite], hikari.undefined.UndefinedType] = UNDEFINED,
reason: Union[str, hikari.undefined.UndefinedType] = UNDEFINED
) -> hikari.channels.GuildCategory:
View Source
async def create_category( self, name: str, *, position: undefined.UndefinedOr[int] = undefined.UNDEFINED, permission_overwrites: undefined.UndefinedOr[ typing.Sequence[channels_.PermissionOverwrite] ] = undefined.UNDEFINED, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> channels_.GuildCategory: """Create a category in the guild. Parameters ---------- name : str The channels name. Must be between 2 and 1000 characters. Other Parameters ---------------- position : hikari.undefined.UndefinedOr[int] If provided, the position of the category. permission_overwrites : hikari.undefined.UndefinedOr[typing.Sequence[hikari.channels.PermissionOverwrite]] If provided, the permission overwrites for the category. reason : hikari.undefined.UndefinedOr[str] If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters. Returns ------- hikari.channels.GuildCategory The created category. Raises ------ hikari.errors.BadRequestError If any of the fields that are passed have an invalid value. hikari.errors.ForbiddenError If you are missing the `MANAGE_CHANNEL` permission. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild is not found. hikari.errors.RateLimitTooLongError Raised in the event that a rate limit occurs that is longer than `max_rate_limit` when making a request. hikari.errors.RateLimitedError Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur. hikari.errors.InternalServerError If an internal error occurs on Discord while handling the request. """ return await self.app.rest.create_guild_category( self.id, name, position=position, permission_overwrites=permission_overwrites, reason=reason )
Create a category in the guild.
Parameters
- name (str): The channels name. Must be between 2 and 1000 characters.
Other Parameters
- position (hikari.undefined.UndefinedOr[int]): If provided, the position of the category.
- permission_overwrites (hikari.undefined.UndefinedOr[typing.Sequence[hikari.channels.PermissionOverwrite]]): If provided, the permission overwrites for the category.
- reason (hikari.undefined.UndefinedOr[str]): If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters.
Returns
- hikari.channels.GuildCategory: The created category.
Raises
- hikari.errors.BadRequestError: If any of the fields that are passed have an invalid value.
- hikari.errors.ForbiddenError: If you are missing the
MANAGE_CHANNEL
permission. - hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the guild is not found.
- hikari.errors.RateLimitTooLongError: Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. - hikari.errors.RateLimitedError: Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur.
- hikari.errors.InternalServerError: If an internal error occurs on Discord while handling the request.
self,
name: str,
*,
position: Union[int, hikari.undefined.UndefinedType] = UNDEFINED,
topic: Union[str, hikari.undefined.UndefinedType] = UNDEFINED,
nsfw: Union[bool, hikari.undefined.UndefinedType] = UNDEFINED,
rate_limit_per_user: Union[int, float, datetime.timedelta, hikari.undefined.UndefinedType] = UNDEFINED,
permission_overwrites: Union[Sequence[hikari.channels.PermissionOverwrite], hikari.undefined.UndefinedType] = UNDEFINED,
category: Union[hikari.channels.GuildCategory, hikari.snowflakes.Snowflake, int, hikari.undefined.UndefinedType] = UNDEFINED,
reason: Union[str, hikari.undefined.UndefinedType] = UNDEFINED
) -> hikari.channels.GuildNewsChannel:
View Source
async def create_news_channel( self, name: str, *, position: undefined.UndefinedOr[int] = undefined.UNDEFINED, topic: undefined.UndefinedOr[str] = undefined.UNDEFINED, nsfw: undefined.UndefinedOr[bool] = undefined.UNDEFINED, rate_limit_per_user: undefined.UndefinedOr[time.Intervalish] = undefined.UNDEFINED, permission_overwrites: undefined.UndefinedOr[ typing.Sequence[channels_.PermissionOverwrite] ] = undefined.UNDEFINED, category: undefined.UndefinedOr[snowflakes.SnowflakeishOr[channels_.GuildCategory]] = undefined.UNDEFINED, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> channels_.GuildNewsChannel: """Create a news channel in the guild. Parameters ---------- name : str The channels name. Must be between 2 and 1000 characters. Other Parameters ---------------- position : hikari.undefined.UndefinedOr[int] If provided, the position of the channel (relative to the category, if any). topic : hikari.undefined.UndefinedOr[str] If provided, the channels topic. Maximum 1024 characters. nsfw : hikari.undefined.UndefinedOr[bool] If provided, whether to mark the channel as NSFW. rate_limit_per_user : hikari.undefined.UndefinedOr[hikari.internal.time.Intervalish] If provided, the amount of seconds a user has to wait before being able to send another message in the channel. Maximum 21600 seconds. permission_overwrites : hikari.undefined.UndefinedOr[typing.Sequence[hikari.channels.PermissionOverwrite]] If provided, the permission overwrites for the channel. category : hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishOr[hikari.channels.GuildCategory]] The category to create the channel under. This may be the object or the ID of an existing category. reason : hikari.undefined.UndefinedOr[str] If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters. Returns ------- hikari.channels.GuildNewsChannel The created channel. Raises ------ hikari.errors.BadRequestError If any of the fields that are passed have an invalid value. hikari.errors.ForbiddenError If you are missing the `MANAGE_CHANNEL` permission. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild is not found. hikari.errors.RateLimitTooLongError Raised in the event that a rate limit occurs that is longer than `max_rate_limit` when making a request. hikari.errors.RateLimitedError Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur. hikari.errors.InternalServerError If an internal error occurs on Discord while handling the request. """ return await self.app.rest.create_guild_news_channel( self.id, name, position=position, topic=topic, nsfw=nsfw, rate_limit_per_user=rate_limit_per_user, permission_overwrites=permission_overwrites, category=category, reason=reason, )
Create a news channel in the guild.
Parameters
- name (str): The channels name. Must be between 2 and 1000 characters.
Other Parameters
- position (hikari.undefined.UndefinedOr[int]): If provided, the position of the channel (relative to the category, if any).
- topic (hikari.undefined.UndefinedOr[str]): If provided, the channels topic. Maximum 1024 characters.
- nsfw (hikari.undefined.UndefinedOr[bool]): If provided, whether to mark the channel as NSFW.
- rate_limit_per_user (hikari.undefined.UndefinedOr[hikari.internal.time.Intervalish]): If provided, the amount of seconds a user has to wait before being able to send another message in the channel. Maximum 21600 seconds.
- permission_overwrites (hikari.undefined.UndefinedOr[typing.Sequence[hikari.channels.PermissionOverwrite]]): If provided, the permission overwrites for the channel.
- category (hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishOr[hikari.channels.GuildCategory]]): The category to create the channel under. This may be the object or the ID of an existing category.
- reason (hikari.undefined.UndefinedOr[str]): If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters.
Returns
- hikari.channels.GuildNewsChannel: The created channel.
Raises
- hikari.errors.BadRequestError: If any of the fields that are passed have an invalid value.
- hikari.errors.ForbiddenError: If you are missing the
MANAGE_CHANNEL
permission. - hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the guild is not found.
- hikari.errors.RateLimitTooLongError: Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. - hikari.errors.RateLimitedError: Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur.
- hikari.errors.InternalServerError: If an internal error occurs on Discord while handling the request.
self,
name: str,
*,
position: Union[int, hikari.undefined.UndefinedType] = UNDEFINED,
user_limit: Union[int, hikari.undefined.UndefinedType] = UNDEFINED,
bitrate: Union[int, hikari.undefined.UndefinedType] = UNDEFINED,
permission_overwrites: Union[Sequence[hikari.channels.PermissionOverwrite], hikari.undefined.UndefinedType] = UNDEFINED,
region: Union[hikari.voices.VoiceRegion, str, hikari.undefined.UndefinedType] = UNDEFINED,
category: Union[hikari.channels.GuildCategory, hikari.snowflakes.Snowflake, int, hikari.undefined.UndefinedType] = UNDEFINED,
reason: Union[str, hikari.undefined.UndefinedType] = UNDEFINED
) -> hikari.channels.GuildStageChannel:
View Source
async def create_stage_channel( self, name: str, *, position: undefined.UndefinedOr[int] = undefined.UNDEFINED, user_limit: undefined.UndefinedOr[int] = undefined.UNDEFINED, bitrate: undefined.UndefinedOr[int] = undefined.UNDEFINED, permission_overwrites: undefined.UndefinedOr[ typing.Sequence[channels_.PermissionOverwrite] ] = undefined.UNDEFINED, region: undefined.UndefinedOr[typing.Union[voices_.VoiceRegion, str]] = undefined.UNDEFINED, category: undefined.UndefinedOr[snowflakes.SnowflakeishOr[channels_.GuildCategory]] = undefined.UNDEFINED, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> channels_.GuildStageChannel: """Create a stage channel in the guild. Parameters ---------- name : str The channel's name. Must be between 2 and 1000 characters. Other Parameters ---------------- position : hikari.undefined.UndefinedOr[int] If provided, the position of the channel (relative to the category, if any). user_limit : hikari.undefined.UndefinedOr[int] If provided, the maximum users in the channel at once. Must be between 0 and 99 with 0 meaning no limit. bitrate : hikari.undefined.UndefinedOr[int] If provided, the bitrate for the channel. Must be between 8000 and 96000 or 8000 and 128000 for VIP servers. permission_overwrites : hikari.undefined.UndefinedOr[typing.Sequence[hikari.channels.PermissionOverwrite]] If provided, the permission overwrites for the channel. region : hikari.undefined.UndefinedOr[typing.Union[hikari.voices.VoiceRegion, str]] If provided, the voice region to for this channel. Passing `None` here will set it to "auto" mode where the used region will be decided based on the first person who connects to it when it's empty. category : hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishOr[hikari.channels.GuildCategory]] The category to create the channel under. This may be the object or the ID of an existing category. reason : hikari.undefined.UndefinedOr[str] If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters. Returns ------- hikari.channels.GuildStageChannel The created channel. Raises ------ hikari.errors.BadRequestError If any of the fields that are passed have an invalid value. hikari.errors.ForbiddenError If you are missing the `MANAGE_CHANNEL` permission. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild is not found. hikari.errors.RateLimitTooLongError Raised in the event that a rate limit occurs that is longer than `max_rate_limit` when making a request. hikari.errors.RateLimitedError Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur. hikari.errors.InternalServerError If an internal error occurs on Discord while handling the request. """ return await self.app.rest.create_guild_stage_channel( self.id, name, position=position, user_limit=user_limit, bitrate=bitrate, permission_overwrites=permission_overwrites, region=region, category=category, reason=reason, )
Create a stage channel in the guild.
Parameters
- name (str): The channel's name. Must be between 2 and 1000 characters.
Other Parameters
- position (hikari.undefined.UndefinedOr[int]): If provided, the position of the channel (relative to the category, if any).
- user_limit (hikari.undefined.UndefinedOr[int]): If provided, the maximum users in the channel at once. Must be between 0 and 99 with 0 meaning no limit.
- bitrate (hikari.undefined.UndefinedOr[int]): If provided, the bitrate for the channel. Must be between 8000 and 96000 or 8000 and 128000 for VIP servers.
- permission_overwrites (hikari.undefined.UndefinedOr[typing.Sequence[hikari.channels.PermissionOverwrite]]): If provided, the permission overwrites for the channel.
- region (hikari.undefined.UndefinedOr[typing.Union[hikari.voices.VoiceRegion, str]]): If provided, the voice region to for this channel. Passing
None
here will set it to "auto" mode where the used region will be decided based on the first person who connects to it when it's empty. - category (hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishOr[hikari.channels.GuildCategory]]): The category to create the channel under. This may be the object or the ID of an existing category.
- reason (hikari.undefined.UndefinedOr[str]): If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters.
Returns
- hikari.channels.GuildStageChannel: The created channel.
Raises
- hikari.errors.BadRequestError: If any of the fields that are passed have an invalid value.
- hikari.errors.ForbiddenError: If you are missing the
MANAGE_CHANNEL
permission. - hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the guild is not found.
- hikari.errors.RateLimitTooLongError: Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. - hikari.errors.RateLimitedError: Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur.
- hikari.errors.InternalServerError: If an internal error occurs on Discord while handling the request.
self,
name: str,
tag: str,
image: Union[hikari.files.Resource[Any], os.PathLike[str], str, bytes, bytearray, memoryview, _io.BytesIO, _io.StringIO],
*,
description: Union[str, hikari.undefined.UndefinedType] = UNDEFINED,
reason: Union[str, hikari.undefined.UndefinedType] = UNDEFINED
) -> hikari.stickers.GuildSticker:
View Source
async def create_sticker( self, name: str, tag: str, image: files.Resourceish, *, description: undefined.UndefinedOr[str] = undefined.UNDEFINED, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> stickers.GuildSticker: """Create a sticker in a guild. .. note:: Lottie support is only available for verified and partnered servers. Parameters ---------- name : str The name for the sticker. tag : str The tag for the sticker. image : hikari.files.Resourceish The 320x320 image for the sticker. Maximum upload size is 500kb. This can be a still or an animated PNG or a Lottie. Other Parameters ---------------- description: hikari.undefined.UndefinedOr[str] If provided, the description of the sticker. reason : hikari.undefined.UndefinedOr[str] If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters. Returns ------- hikari.stickers.GuildSticker The created sticker. Raises ------ hikari.errors.BadRequestError If any of the fields that are passed have an invalid value or if there are no more spaces for the sticker in the guild. hikari.errors.ForbiddenError If you are missing `MANAGE_EMOJIS_AND_STICKERS` in the server. hikari.errors.NotFoundError If the guild is not found. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.RateLimitTooLongError Raised in the event that a rate limit occurs that is longer than `max_rate_limit` when making a request. hikari.errors.RateLimitedError Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur. hikari.errors.InternalServerError If an internal error occurs on Discord while handling the request. """ return await self.app.rest.create_sticker(self.id, name, tag, image, description=description, reason=reason)
Create a sticker in a guild.
Note: Lottie support is only available for verified and partnered servers.
Parameters
- name (str): The name for the sticker.
- tag (str): The tag for the sticker.
- image (hikari.files.Resourceish): The 320x320 image for the sticker. Maximum upload size is 500kb. This can be a still or an animated PNG or a Lottie.
Other Parameters
- description (hikari.undefined.UndefinedOr[str]): If provided, the description of the sticker.
- reason (hikari.undefined.UndefinedOr[str]): If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters.
Returns
- hikari.stickers.GuildSticker: The created sticker.
Raises
- hikari.errors.BadRequestError: If any of the fields that are passed have an invalid value or if there are no more spaces for the sticker in the guild.
- hikari.errors.ForbiddenError: If you are missing
MANAGE_EMOJIS_AND_STICKERS
in the server. - hikari.errors.NotFoundError: If the guild is not found.
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.RateLimitTooLongError: Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. - hikari.errors.RateLimitedError: Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur.
- hikari.errors.InternalServerError: If an internal error occurs on Discord while handling the request.
self,
name: str,
*,
position: Union[int, hikari.undefined.UndefinedType] = UNDEFINED,
topic: Union[str, hikari.undefined.UndefinedType] = UNDEFINED,
nsfw: Union[bool, hikari.undefined.UndefinedType] = UNDEFINED,
rate_limit_per_user: Union[int, float, datetime.timedelta, hikari.undefined.UndefinedType] = UNDEFINED,
permission_overwrites: Union[Sequence[hikari.channels.PermissionOverwrite], hikari.undefined.UndefinedType] = UNDEFINED,
category: Union[hikari.channels.GuildCategory, hikari.snowflakes.Snowflake, int, hikari.undefined.UndefinedType] = UNDEFINED,
reason: Union[str, hikari.undefined.UndefinedType] = UNDEFINED
) -> hikari.channels.GuildTextChannel:
View Source
async def create_text_channel( self, name: str, *, position: undefined.UndefinedOr[int] = undefined.UNDEFINED, topic: undefined.UndefinedOr[str] = undefined.UNDEFINED, nsfw: undefined.UndefinedOr[bool] = undefined.UNDEFINED, rate_limit_per_user: undefined.UndefinedOr[time.Intervalish] = undefined.UNDEFINED, permission_overwrites: undefined.UndefinedOr[ typing.Sequence[channels_.PermissionOverwrite] ] = undefined.UNDEFINED, category: undefined.UndefinedOr[snowflakes.SnowflakeishOr[channels_.GuildCategory]] = undefined.UNDEFINED, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> channels_.GuildTextChannel: """Create a text channel in the guild. Parameters ---------- name : str The channels name. Must be between 2 and 1000 characters. Other Parameters ---------------- position : hikari.undefined.UndefinedOr[int] If provided, the position of the channel (relative to the category, if any). topic : hikari.undefined.UndefinedOr[str] If provided, the channels topic. Maximum 1024 characters. nsfw : hikari.undefined.UndefinedOr[bool] If provided, whether to mark the channel as NSFW. rate_limit_per_user : hikari.undefined.UndefinedOr[hikari.internal.time.Intervalish] If provided, the amount of seconds a user has to wait before being able to send another message in the channel. Maximum 21600 seconds. permission_overwrites : hikari.undefined.UndefinedOr[typing.Sequence[hikari.channels.PermissionOverwrite]] If provided, the permission overwrites for the channel. category : hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishOr[hikari.channels.GuildCategory]] The category to create the channel under. This may be the object or the ID of an existing category. reason : hikari.undefined.UndefinedOr[str] If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters. Returns ------- hikari.channels.GuildTextChannel The created channel. Raises ------ hikari.errors.BadRequestError If any of the fields that are passed have an invalid value. hikari.errors.ForbiddenError If you are missing the `MANAGE_CHANNEL` permission. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild is not found. hikari.errors.RateLimitTooLongError Raised in the event that a rate limit occurs that is longer than `max_rate_limit` when making a request. hikari.errors.RateLimitedError Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur. hikari.errors.InternalServerError If an internal error occurs on Discord while handling the request. """ return await self.app.rest.create_guild_text_channel( self.id, name, position=position, topic=topic, nsfw=nsfw, rate_limit_per_user=rate_limit_per_user, permission_overwrites=permission_overwrites, category=category, reason=reason, )
Create a text channel in the guild.
Parameters
- name (str): The channels name. Must be between 2 and 1000 characters.
Other Parameters
- position (hikari.undefined.UndefinedOr[int]): If provided, the position of the channel (relative to the category, if any).
- topic (hikari.undefined.UndefinedOr[str]): If provided, the channels topic. Maximum 1024 characters.
- nsfw (hikari.undefined.UndefinedOr[bool]): If provided, whether to mark the channel as NSFW.
- rate_limit_per_user (hikari.undefined.UndefinedOr[hikari.internal.time.Intervalish]): If provided, the amount of seconds a user has to wait before being able to send another message in the channel. Maximum 21600 seconds.
- permission_overwrites (hikari.undefined.UndefinedOr[typing.Sequence[hikari.channels.PermissionOverwrite]]): If provided, the permission overwrites for the channel.
- category (hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishOr[hikari.channels.GuildCategory]]): The category to create the channel under. This may be the object or the ID of an existing category.
- reason (hikari.undefined.UndefinedOr[str]): If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters.
Returns
- hikari.channels.GuildTextChannel: The created channel.
Raises
- hikari.errors.BadRequestError: If any of the fields that are passed have an invalid value.
- hikari.errors.ForbiddenError: If you are missing the
MANAGE_CHANNEL
permission. - hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the guild is not found.
- hikari.errors.RateLimitTooLongError: Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. - hikari.errors.RateLimitedError: Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur.
- hikari.errors.InternalServerError: If an internal error occurs on Discord while handling the request.
self,
name: str,
*,
position: Union[int, hikari.undefined.UndefinedType] = UNDEFINED,
user_limit: Union[int, hikari.undefined.UndefinedType] = UNDEFINED,
bitrate: Union[int, hikari.undefined.UndefinedType] = UNDEFINED,
video_quality_mode: Union[hikari.channels.VideoQualityMode, int, hikari.undefined.UndefinedType] = UNDEFINED,
permission_overwrites: Union[Sequence[hikari.channels.PermissionOverwrite], hikari.undefined.UndefinedType] = UNDEFINED,
region: Union[hikari.voices.VoiceRegion, str, hikari.undefined.UndefinedType] = UNDEFINED,
category: Union[hikari.channels.GuildCategory, hikari.snowflakes.Snowflake, int, hikari.undefined.UndefinedType] = UNDEFINED,
reason: Union[str, hikari.undefined.UndefinedType] = UNDEFINED
) -> hikari.channels.GuildVoiceChannel:
View Source
async def create_voice_channel( self, name: str, *, position: undefined.UndefinedOr[int] = undefined.UNDEFINED, user_limit: undefined.UndefinedOr[int] = undefined.UNDEFINED, bitrate: undefined.UndefinedOr[int] = undefined.UNDEFINED, video_quality_mode: undefined.UndefinedOr[typing.Union[channels_.VideoQualityMode, int]] = undefined.UNDEFINED, permission_overwrites: undefined.UndefinedOr[ typing.Sequence[channels_.PermissionOverwrite] ] = undefined.UNDEFINED, region: undefined.UndefinedOr[typing.Union[voices_.VoiceRegion, str]] = undefined.UNDEFINED, category: undefined.UndefinedOr[snowflakes.SnowflakeishOr[channels_.GuildCategory]] = undefined.UNDEFINED, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> channels_.GuildVoiceChannel: """Create a voice channel in a guild. Parameters ---------- name : str The channels name. Must be between 2 and 1000 characters. Other Parameters ---------------- position : hikari.undefined.UndefinedOr[int] If provided, the position of the channel (relative to the category, if any). user_limit : hikari.undefined.UndefinedOr[int] If provided, the maximum users in the channel at once. Must be between 0 and 99 with 0 meaning no limit. bitrate : hikari.undefined.UndefinedOr[int] If provided, the bitrate for the channel. Must be between 8000 and 96000 or 8000 and 128000 for VIP servers. video_quality_mode: hikari.undefined.UndefinedOr[typing.Union[hikari.channels.VideoQualityMode, int]] If provided, the new video quality mode for the channel. permission_overwrites : hikari.undefined.UndefinedOr[typing.Sequence[hikari.channels.PermissionOverwrite]] If provided, the permission overwrites for the channel. region : hikari.undefined.UndefinedOr[typing.Union[hikari.voices.VoiceRegion, str]] If provided, the voice region to for this channel. Passing `None` here will set it to "auto" mode where the used region will be decided based on the first person who connects to it when it's empty. category : hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishOr[hikari.channels.GuildCategory]] The category to create the channel under. This may be the object or the ID of an existing category. reason : hikari.undefined.UndefinedOr[str] If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters. Returns ------- hikari.channels.GuildVoiceChannel The created channel. Raises ------ hikari.errors.BadRequestError If any of the fields that are passed have an invalid value. hikari.errors.ForbiddenError If you are missing the `MANAGE_CHANNEL` permission. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the gui ld is not found. hikari.errors.RateLimitTooLongError Raised in the event that a rate limit occurs that is longer than `max_rate_limit` when making a request. hikari.errors.RateLimitedError Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur. hikari.errors.InternalServerError If an internal error occurs on Discord while handling the request. """ return await self.app.rest.create_guild_voice_channel( self.id, name, position=position, user_limit=user_limit, bitrate=bitrate, video_quality_mode=video_quality_mode, permission_overwrites=permission_overwrites, region=region, category=category, reason=reason, )
Create a voice channel in a guild.
Parameters
- name (str): The channels name. Must be between 2 and 1000 characters.
Other Parameters
- position (hikari.undefined.UndefinedOr[int]): If provided, the position of the channel (relative to the category, if any).
- user_limit (hikari.undefined.UndefinedOr[int]): If provided, the maximum users in the channel at once. Must be between 0 and 99 with 0 meaning no limit.
- bitrate (hikari.undefined.UndefinedOr[int]): If provided, the bitrate for the channel. Must be between 8000 and 96000 or 8000 and 128000 for VIP servers.
- video_quality_mode (hikari.undefined.UndefinedOr[typing.Union[hikari.channels.VideoQualityMode, int]]): If provided, the new video quality mode for the channel.
- permission_overwrites (hikari.undefined.UndefinedOr[typing.Sequence[hikari.channels.PermissionOverwrite]]): If provided, the permission overwrites for the channel.
- region (hikari.undefined.UndefinedOr[typing.Union[hikari.voices.VoiceRegion, str]]): If provided, the voice region to for this channel. Passing
None
here will set it to "auto" mode where the used region will be decided based on the first person who connects to it when it's empty. - category (hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishOr[hikari.channels.GuildCategory]]): The category to create the channel under. This may be the object or the ID of an existing category.
- reason (hikari.undefined.UndefinedOr[str]): If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters.
Returns
- hikari.channels.GuildVoiceChannel: The created channel.
Raises
- hikari.errors.BadRequestError: If any of the fields that are passed have an invalid value.
- hikari.errors.ForbiddenError: If you are missing the
MANAGE_CHANNEL
permission. - hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the gui ld is not found.
- hikari.errors.RateLimitTooLongError: Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. - hikari.errors.RateLimitedError: Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur.
- hikari.errors.InternalServerError: If an internal error occurs on Discord while handling the request.
self,
channel: Union[hikari.channels.GuildChannel, hikari.snowflakes.Snowflake, int]
) -> hikari.channels.GuildChannel:
View Source
async def delete_channel( self, channel: snowflakes.SnowflakeishOr[channels_.GuildChannel] ) -> channels_.GuildChannel: """Delete a channel in the guild. .. note:: This method can also be used for deleting guild categories as well. .. note:: For Public servers, the set 'Rules' or 'Guidelines' channels and the 'Public Server Updates' channel cannot be deleted. Parameters ---------- channel : hikari.snowflakes.SnowflakeishOr[hikari.channels.GuildChannel] The channel or category to delete. This may be the object or the ID of an existing channel. Returns ------- hikari.channels.GuildChannel Object of the channel or category that was deleted. Raises ------ hikari.errors.UnauthorizedError, or close a DM. If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `MANAGE_CHANNEL` permission in the channel. hikari.errors.NotFoundError If the channel is not found. hikari.errors.RateLimitTooLongError Raised in the event that a rate limit occurs that is longer than `max_rate_limit` when making a request. hikari.errors.RateLimitedError Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur. hikari.errors.InternalServerError If an internal error occurs on Discord while handling the request. """ deleted_channel = await self.app.rest.delete_channel(channel) assert isinstance(deleted_channel, channels_.GuildChannel) return deleted_channel
Delete a channel in the guild.
Note: This method can also be used for deleting guild categories as well.
Note: For Public servers, the set 'Rules' or 'Guidelines' channels and the 'Public Server Updates' channel cannot be deleted.
Parameters
- channel (hikari.snowflakes.SnowflakeishOr[hikari.channels.GuildChannel]): The channel or category to delete. This may be the object or the ID of an existing channel.
Returns
- hikari.channels.GuildChannel: Object of the channel or category that was deleted.
Raises
- hikari.errors.UnauthorizedError, or close a DM.: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.ForbiddenError: If you are missing the
MANAGE_CHANNEL
permission in the channel. - hikari.errors.NotFoundError: If the channel is not found.
- hikari.errors.RateLimitTooLongError: Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. - hikari.errors.RateLimitedError: Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur.
- hikari.errors.InternalServerError: If an internal error occurs on Discord while handling the request.
self,
sticker: Union[hikari.stickers.PartialSticker, hikari.snowflakes.Snowflake, int],
*,
reason: Union[str, hikari.undefined.UndefinedType] = UNDEFINED
) -> None:
View Source
async def delete_sticker( self, sticker: snowflakes.SnowflakeishOr[stickers.PartialSticker], *, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> None: """Delete a sticker in a guild. Parameters ---------- sticker : hikari.snowflakes.SnowflakeishOr[hikari.stickers.PartialSticker] The sticker to delete. This can be a sticker object or the ID of an existing sticker. Other Parameters ---------------- reason : hikari.undefined.UndefinedOr[str] If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters. Raises ------ hikari.errors.ForbiddenError If you are missing `MANAGE_EMOJIS_AND_STICKERS` in the server. hikari.errors.NotFoundError If the guild or the sticker are not found. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.RateLimitTooLongError Raised in the event that a rate limit occurs that is longer than `max_rate_limit` when making a request. hikari.errors.RateLimitedError Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur. hikari.errors.InternalServerError If an internal error occurs on Discord while handling the request. """ return await self.app.rest.delete_sticker(self.id, sticker, reason=reason)
Delete a sticker in a guild.
Parameters
- sticker (hikari.snowflakes.SnowflakeishOr[hikari.stickers.PartialSticker]): The sticker to delete. This can be a sticker object or the ID of an existing sticker.
Other Parameters
- reason (hikari.undefined.UndefinedOr[str]): If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters.
Raises
- hikari.errors.ForbiddenError: If you are missing
MANAGE_EMOJIS_AND_STICKERS
in the server. - hikari.errors.NotFoundError: If the guild or the sticker are not found.
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.RateLimitTooLongError: Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. - hikari.errors.RateLimitedError: Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur.
- hikari.errors.InternalServerError: If an internal error occurs on Discord while handling the request.
self,
*,
name: Union[str, hikari.undefined.UndefinedType] = UNDEFINED,
verification_level: Union[hikari.guilds.GuildVerificationLevel, hikari.undefined.UndefinedType] = UNDEFINED,
default_message_notifications: Union[hikari.guilds.GuildMessageNotificationsLevel, hikari.undefined.UndefinedType] = UNDEFINED,
explicit_content_filter_level: Union[hikari.guilds.GuildExplicitContentFilterLevel, hikari.undefined.UndefinedType] = UNDEFINED,
afk_channel: Union[hikari.channels.GuildVoiceChannel, hikari.snowflakes.Snowflake, int, hikari.undefined.UndefinedType] = UNDEFINED,
afk_timeout: Union[int, float, datetime.timedelta, hikari.undefined.UndefinedType] = UNDEFINED,
icon: Union[hikari.files.Resource[Any], os.PathLike[str], str, bytes, bytearray, memoryview, _io.BytesIO, _io.StringIO, hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
owner: Union[hikari.users.PartialUser, hikari.snowflakes.Snowflake, int, hikari.undefined.UndefinedType] = UNDEFINED,
splash: Union[hikari.files.Resource[Any], os.PathLike[str], str, bytes, bytearray, memoryview, _io.BytesIO, _io.StringIO, hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
banner: Union[hikari.files.Resource[Any], os.PathLike[str], str, bytes, bytearray, memoryview, _io.BytesIO, _io.StringIO, hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
system_channel: Union[hikari.channels.GuildTextChannel, hikari.snowflakes.Snowflake, int, hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
rules_channel: Union[hikari.channels.GuildTextChannel, hikari.snowflakes.Snowflake, int, hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
public_updates_channel: Union[hikari.channels.GuildTextChannel, hikari.snowflakes.Snowflake, int, hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
preferred_locale: Union[str, hikari.locales.Locale, hikari.undefined.UndefinedType] = UNDEFINED,
reason: Union[str, hikari.undefined.UndefinedType] = UNDEFINED
) -> hikari.guilds.RESTGuild:
View Source
async def edit( self, *, name: undefined.UndefinedOr[str] = undefined.UNDEFINED, verification_level: undefined.UndefinedOr[GuildVerificationLevel] = undefined.UNDEFINED, default_message_notifications: undefined.UndefinedOr[GuildMessageNotificationsLevel] = undefined.UNDEFINED, explicit_content_filter_level: undefined.UndefinedOr[GuildExplicitContentFilterLevel] = undefined.UNDEFINED, afk_channel: undefined.UndefinedOr[ snowflakes.SnowflakeishOr[channels_.GuildVoiceChannel] ] = undefined.UNDEFINED, afk_timeout: undefined.UndefinedOr[time.Intervalish] = undefined.UNDEFINED, icon: undefined.UndefinedNoneOr[files.Resourceish] = undefined.UNDEFINED, owner: undefined.UndefinedOr[snowflakes.SnowflakeishOr[users.PartialUser]] = undefined.UNDEFINED, splash: undefined.UndefinedNoneOr[files.Resourceish] = undefined.UNDEFINED, banner: undefined.UndefinedNoneOr[files.Resourceish] = undefined.UNDEFINED, system_channel: undefined.UndefinedNoneOr[ snowflakes.SnowflakeishOr[channels_.GuildTextChannel] ] = undefined.UNDEFINED, rules_channel: undefined.UndefinedNoneOr[ snowflakes.SnowflakeishOr[channels_.GuildTextChannel] ] = undefined.UNDEFINED, public_updates_channel: undefined.UndefinedNoneOr[ snowflakes.SnowflakeishOr[channels_.GuildTextChannel] ] = undefined.UNDEFINED, preferred_locale: undefined.UndefinedOr[typing.Union[str, locales.Locale]] = undefined.UNDEFINED, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> RESTGuild: """Edits the guild. Parameters ---------- name : hikari.undefined.UndefinedOr[str] If provided, the new name for the guild. verification_level : hikari.undefined.UndefinedOr[hikari.guilds.GuildVerificationLevel] If provided, the new verification level. default_message_notifications : hikari.undefined.UndefinedOr[hikari.guilds.GuildMessageNotificationsLevel] If provided, the new default message notifications level. explicit_content_filter_level : hikari.undefined.UndefinedOr[hikari.guilds.GuildExplicitContentFilterLevel] If provided, the new explicit content filter level. afk_channel : hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishOr[hikari.channels.GuildVoiceChannel]] If provided, the new afk channel. Requires `afk_timeout` to be set to work. afk_timeout : hikari.undefined.UndefinedOr[hikari.internal.time.Intervalish] If provided, the new afk timeout. icon : hikari.undefined.UndefinedOr[hikari.files.Resourceish] If provided, the new guild icon. Must be a 1024x1024 image or can be an animated gif when the guild has the `ANIMATED_ICON` feature. owner : hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser]]] If provided, the new guild owner. .. warning:: You need to be the owner of the server to use this. splash : hikari.undefined.UndefinedNoneOr[hikari.files.Resourceish] If provided, the new guild splash. Must be a 16:9 image and the guild must have the `INVITE_SPLASH` feature. banner : hikari.undefined.UndefinedNoneOr[hikari.files.Resourceish] If provided, the new guild banner. Must be a 16:9 image and the guild must have the `BANNER` feature. system_channel : hikari.undefined.UndefinedNoneOr[hikari.snowflakes.SnowflakeishOr[hikari.channels.GuildTextChannel]] If provided, the new system channel. rules_channel : hikari.undefined.UndefinedNoneOr[hikari.snowflakes.SnowflakeishOr[hikari.channels.GuildTextChannel]] If provided, the new rules channel. public_updates_channel : hikari.undefined.UndefinedNoneOr[hikari.snowflakes.SnowflakeishOr[hikari.channels.GuildTextChannel]] If provided, the new public updates channel. preferred_locale : hikari.undefined.UndefinedNoneOr[str] If provided, the new preferred locale. reason : hikari.undefined.UndefinedOr[str] If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters. Returns ------- hikari.guilds.RESTGuild The edited guild. Raises ------ hikari.errors.BadRequestError If any of the fields that are passed have an invalid value. Or you are missing the hikari.errors.ForbiddenError If you are missing the `MANAGE_GUILD` permission or if you tried to pass ownership without being the server owner. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild is not found. hikari.errors.RateLimitTooLongError Raised in the event that a rate limit occurs that is longer than `max_rate_limit` when making a request. hikari.errors.RateLimitedError Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur. hikari.errors.InternalServerError If an internal error occurs on Discord while handling the request. """ # noqa: E501 - Line too long return await self.app.rest.edit_guild( self.id, name=name, verification_level=verification_level, default_message_notifications=default_message_notifications, explicit_content_filter_level=explicit_content_filter_level, afk_channel=afk_channel, afk_timeout=afk_timeout, icon=icon, owner=owner, splash=splash, banner=banner, system_channel=system_channel, rules_channel=rules_channel, public_updates_channel=public_updates_channel, preferred_locale=preferred_locale, reason=reason, )
Edits the guild.
Parameters
- name (hikari.undefined.UndefinedOr[str]): If provided, the new name for the guild.
- verification_level (hikari.undefined.UndefinedOr[hikari.guilds.GuildVerificationLevel]): If provided, the new verification level.
- default_message_notifications (hikari.undefined.UndefinedOr[hikari.guilds.GuildMessageNotificationsLevel]): If provided, the new default message notifications level.
- explicit_content_filter_level (hikari.undefined.UndefinedOr[hikari.guilds.GuildExplicitContentFilterLevel]): If provided, the new explicit content filter level.
- afk_channel (hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishOr[hikari.channels.GuildVoiceChannel]]): If provided, the new afk channel. Requires
afk_timeout
to be set to work. - afk_timeout (hikari.undefined.UndefinedOr[hikari.internal.time.Intervalish]): If provided, the new afk timeout.
- icon (hikari.undefined.UndefinedOr[hikari.files.Resourceish]): If provided, the new guild icon. Must be a 1024x1024 image or can be an animated gif when the guild has the
ANIMATED_ICON
feature. owner (hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser]]]): If provided, the new guild owner.
Warning: You need to be the owner of the server to use this.
- splash (hikari.undefined.UndefinedNoneOr[hikari.files.Resourceish]): If provided, the new guild splash. Must be a 16:9 image and the guild must have the
INVITE_SPLASH
feature. - banner (hikari.undefined.UndefinedNoneOr[hikari.files.Resourceish]): If provided, the new guild banner. Must be a 16:9 image and the guild must have the
BANNER
feature. - system_channel (hikari.undefined.UndefinedNoneOr[hikari.snowflakes.SnowflakeishOr[hikari.channels.GuildTextChannel]]): If provided, the new system channel.
- rules_channel (hikari.undefined.UndefinedNoneOr[hikari.snowflakes.SnowflakeishOr[hikari.channels.GuildTextChannel]]): If provided, the new rules channel.
- public_updates_channel (hikari.undefined.UndefinedNoneOr[hikari.snowflakes.SnowflakeishOr[hikari.channels.GuildTextChannel]]): If provided, the new public updates channel.
- preferred_locale (hikari.undefined.UndefinedNoneOr[str]): If provided, the new preferred locale.
- reason (hikari.undefined.UndefinedOr[str]): If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters.
Returns
- hikari.guilds.RESTGuild: The edited guild.
Raises
- hikari.errors.BadRequestError: If any of the fields that are passed have an invalid value. Or you are missing the
- hikari.errors.ForbiddenError: If you are missing the
MANAGE_GUILD
permission or if you tried to pass ownership without being the server owner. - hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the guild is not found.
- hikari.errors.RateLimitTooLongError: Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. - hikari.errors.RateLimitedError: Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur.
- hikari.errors.InternalServerError: If an internal error occurs on Discord while handling the request.
self,
sticker: Union[hikari.stickers.PartialSticker, hikari.snowflakes.Snowflake, int],
*,
name: Union[str, hikari.undefined.UndefinedType] = UNDEFINED,
description: Union[str, hikari.undefined.UndefinedType] = UNDEFINED,
tag: Union[str, hikari.undefined.UndefinedType] = UNDEFINED,
reason: Union[str, hikari.undefined.UndefinedType] = UNDEFINED
) -> hikari.stickers.GuildSticker:
View Source
async def edit_sticker( self, sticker: snowflakes.SnowflakeishOr[stickers.PartialSticker], *, name: undefined.UndefinedOr[str] = undefined.UNDEFINED, description: undefined.UndefinedOr[str] = undefined.UNDEFINED, tag: undefined.UndefinedOr[str] = undefined.UNDEFINED, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> stickers.GuildSticker: """Edit a sticker in a guild. Parameters ---------- sticker : hikari.snowflakes.SnowflakeishOr[hikari.stickers.PartialSticker] The sticker to edit. This can be a sticker object or the ID of an existing sticker. Other Parameters ---------------- name : hikari.undefined.UndefinedOr[str] If provided, the new name for the sticker. description : hikari.undefined.UndefinedOr[str] If provided, the new description for the sticker. tag : hikari.undefined.UndefinedOr[str] If provided, the new sticker tag. reason : hikari.undefined.UndefinedOr[str] If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters. Returns ------- hikari.stickers.GuildSticker The edited sticker. Raises ------ hikari.errors.BadRequestError If any of the fields that are passed have an invalid value. hikari.errors.ForbiddenError If you are missing `MANAGE_EMOJIS_AND_STICKERS` in the server. hikari.errors.NotFoundError If the guild or the sticker are not found. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.RateLimitTooLongError Raised in the event that a rate limit occurs that is longer than `max_rate_limit` when making a request. hikari.errors.RateLimitedError Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur. hikari.errors.InternalServerError If an internal error occurs on Discord while handling the request. """ return await self.app.rest.edit_sticker( self.id, sticker, name=name, description=description, tag=tag, reason=reason )
Edit a sticker in a guild.
Parameters
- sticker (hikari.snowflakes.SnowflakeishOr[hikari.stickers.PartialSticker]): The sticker to edit. This can be a sticker object or the ID of an existing sticker.
Other Parameters
- name (hikari.undefined.UndefinedOr[str]): If provided, the new name for the sticker.
- description (hikari.undefined.UndefinedOr[str]): If provided, the new description for the sticker.
- tag (hikari.undefined.UndefinedOr[str]): If provided, the new sticker tag.
- reason (hikari.undefined.UndefinedOr[str]): If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters.
Returns
- hikari.stickers.GuildSticker: The edited sticker.
Raises
- hikari.errors.BadRequestError: If any of the fields that are passed have an invalid value.
- hikari.errors.ForbiddenError: If you are missing
MANAGE_EMOJIS_AND_STICKERS
in the server. - hikari.errors.NotFoundError: If the guild or the sticker are not found.
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.RateLimitTooLongError: Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. - hikari.errors.RateLimitedError: Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur.
- hikari.errors.InternalServerError: If an internal error occurs on Discord while handling the request.
self,
emoji: Union[hikari.emojis.CustomEmoji, hikari.snowflakes.Snowflake, int]
) -> hikari.emojis.KnownCustomEmoji:
View Source
async def fetch_emoji(self, emoji: snowflakes.SnowflakeishOr[emojis_.CustomEmoji]) -> emojis_.KnownCustomEmoji: """Fetch an emoji from the guild. Parameters ---------- emoji : hikari.snowflakes.SnowflakeishOr[hikari.emojis.CustomEmoji] The emoji to fetch. This can be a `hikari.emojis.CustomEmoji` or the ID of an existing emoji. Returns ------- hikari.emojis.KnownCustomEmoji The requested emoji. Raises ------ hikari.errors.NotFoundError If the guild or the emoji are not found. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.RateLimitTooLongError Raised in the event that a rate limit occurs that is longer than `max_rate_limit` when making a request. hikari.errors.RateLimitedError Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur. hikari.errors.InternalServerError If an internal error occurs on Discord while handling the request. """ return await self.app.rest.fetch_emoji(self.id, emoji)
Fetch an emoji from the guild.
Parameters
- emoji (hikari.snowflakes.SnowflakeishOr[hikari.emojis.CustomEmoji]): The emoji to fetch. This can be a
hikari.emojis.CustomEmoji
or the ID of an existing emoji.
Returns
- hikari.emojis.KnownCustomEmoji: The requested emoji.
Raises
- hikari.errors.NotFoundError: If the guild or the emoji are not found.
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.RateLimitTooLongError: Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. - hikari.errors.RateLimitedError: Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur.
- hikari.errors.InternalServerError: If an internal error occurs on Discord while handling the request.
View Source
async def fetch_emojis(self) -> typing.Sequence[emojis_.KnownCustomEmoji]: """Fetch the emojis of the guild. Returns ------- typing.Sequence[hikari.emojis.KnownCustomEmoji] The requested emojis. Raises ------ hikari.errors.NotFoundError If the guild is not found. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.RateLimitTooLongError Raised in the event that a rate limit occurs that is longer than `max_rate_limit` when making a request. hikari.errors.RateLimitedError Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur. hikari.errors.InternalServerError If an internal error occurs on Discord while handling the request. """ return await self.app.rest.fetch_guild_emojis(self.id)
Fetch the emojis of the guild.
Returns
- typing.Sequence[hikari.emojis.KnownCustomEmoji]: The requested emojis.
Raises
- hikari.errors.NotFoundError: If the guild is not found.
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.RateLimitTooLongError: Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. - hikari.errors.RateLimitedError: Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur.
- hikari.errors.InternalServerError: If an internal error occurs on Discord while handling the request.
View Source
async def fetch_roles(self) -> typing.Sequence[Role]: """Fetch the roles of the guild. Returns ------- typing.Sequence[hikari.guilds.Role] The requested roles. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild is not found. hikari.errors.RateLimitTooLongError Raised in the event that a rate limit occurs that is longer than `max_rate_limit` when making a request. hikari.errors.RateLimitedError Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur. hikari.errors.InternalServerError If an internal error occurs on Discord while handling the request. """ return await self.app.rest.fetch_roles(self.id)
Fetch the roles of the guild.
Returns
- typing.Sequence[hikari.guilds.Role]: The requested roles.
Raises
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild is not found.
- hikari.errors.RateLimitTooLongError: Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. - hikari.errors.RateLimitedError: Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur.
- hikari.errors.InternalServerError: If an internal error occurs on Discord while handling the request.
View Source
async def fetch_self(self) -> RESTGuild: """Fetch the guild. Returns ------- hikari.guilds.RESTGuild The requested guild. Raises ------ hikari.errors.ForbiddenError If you are not part of the guild. hikari.errors.NotFoundError If the guild is not found. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.RateLimitTooLongError Raised in the event that a rate limit occurs that is longer than `max_rate_limit` when making a request. hikari.errors.RateLimitedError Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur. hikari.errors.InternalServerError If an internal error occurs on Discord while handling the request. """ return await self.app.rest.fetch_guild(self.id)
Fetch the guild.
Returns
- hikari.guilds.RESTGuild: The requested guild.
Raises
- hikari.errors.ForbiddenError: If you are not part of the guild.
- hikari.errors.NotFoundError: If the guild is not found.
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.RateLimitTooLongError: Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. - hikari.errors.RateLimitedError: Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur.
- hikari.errors.InternalServerError: If an internal error occurs on Discord while handling the request.
self,
sticker: Union[hikari.stickers.PartialSticker, hikari.snowflakes.Snowflake, int]
) -> hikari.stickers.GuildSticker:
View Source
async def fetch_sticker(self, sticker: snowflakes.SnowflakeishOr[stickers.PartialSticker]) -> stickers.GuildSticker: """Fetch a sticker from the guild. Parameters ---------- sticker : snowflakes.SnowflakeishOr[hikari.stickers.PartialSticker] The sticker to fetch. This can be a sticker object or the ID of an existing sticker. Returns ------- hikari.stickers.GuildSticker The requested sticker. Raises ------ hikari.errors.ForbiddenError If you are not part of the server. hikari.errors.NotFoundError If the guild or the sticker are not found. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.RateLimitTooLongError Raised in the event that a rate limit occurs that is longer than `max_rate_limit` when making a request. hikari.errors.RateLimitedError Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur. hikari.errors.InternalServerError If an internal error occurs on Discord while handling the request. """ return await self.app.rest.fetch_guild_sticker(self.id, sticker)
Fetch a sticker from the guild.
Parameters
- sticker (snowflakes.SnowflakeishOr[hikari.stickers.PartialSticker]): The sticker to fetch. This can be a sticker object or the ID of an existing sticker.
Returns
- hikari.stickers.GuildSticker: The requested sticker.
Raises
- hikari.errors.ForbiddenError: If you are not part of the server.
- hikari.errors.NotFoundError: If the guild or the sticker are not found.
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.RateLimitTooLongError: Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. - hikari.errors.RateLimitedError: Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur.
- hikari.errors.InternalServerError: If an internal error occurs on Discord while handling the request.
View Source
async def fetch_stickers(self) -> typing.Sequence[stickers.GuildSticker]: """Fetch the stickers of the guild. Returns ------- typing.Sequence[hikari.stickers.GuildSticker] The requested stickers. Raises ------ hikari.errors.ForbiddenError If you are not part of the server. hikari.errors.NotFoundError If the guild is not found. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.RateLimitTooLongError Raised in the event that a rate limit occurs that is longer than `max_rate_limit` when making a request. hikari.errors.RateLimitedError Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur. hikari.errors.InternalServerError If an internal error occurs on Discord while handling the request. """ return await self.app.rest.fetch_guild_stickers(self.id)
Fetch the stickers of the guild.
Returns
- typing.Sequence[hikari.stickers.GuildSticker]: The requested stickers.
Raises
- hikari.errors.ForbiddenError: If you are not part of the server.
- hikari.errors.NotFoundError: If the guild is not found.
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.RateLimitTooLongError: Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. - hikari.errors.RateLimitedError: Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur.
- hikari.errors.InternalServerError: If an internal error occurs on Discord while handling the request.
self,
user: Union[hikari.users.PartialUser, hikari.snowflakes.Snowflake, int],
*,
reason: Union[str, hikari.undefined.UndefinedType] = UNDEFINED
) -> None:
View Source
async def kick( self, user: snowflakes.SnowflakeishOr[users.PartialUser], *, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> None: """Kicks the given user from this guild. Parameters ---------- user: hikari.snowflakes.Snowflakeish[hikari.users.PartialUser] The user to kick from the guild Other Parameters ---------------- reason : hikari.undefined.UndefinedOr[str] If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters. Raises ------ hikari.errors.BadRequestError If any of the fields that are passed have an invalid value. hikari.errors.ForbiddenError If you are missing the `KICK_MEMBERS` permission. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild or user are not found. hikari.errors.RateLimitTooLongError Raised in the event that a rate limit occurs that is longer than `max_rate_limit` when making a request. hikari.errors.RateLimitedError Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur. hikari.errors.InternalServerError If an internal error occurs on Discord while handling the request. """ await self.app.rest.kick_user(self.id, user, reason=reason)
Kicks the given user from this guild.
Parameters
- user (hikari.snowflakes.Snowflakeish[hikari.users.PartialUser]): The user to kick from the guild
Other Parameters
- reason (hikari.undefined.UndefinedOr[str]): If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters.
Raises
- hikari.errors.BadRequestError: If any of the fields that are passed have an invalid value.
- hikari.errors.ForbiddenError: If you are missing the
KICK_MEMBERS
permission. - hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the guild or user are not found.
- hikari.errors.RateLimitTooLongError: Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. - hikari.errors.RateLimitedError: Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur.
- hikari.errors.InternalServerError: If an internal error occurs on Discord while handling the request.
self,
*,
ext: Optional[str] = None,
size: int = 4096
) -> Optional[hikari.files.URL]:
View Source
def make_icon_url(self, *, ext: typing.Optional[str] = None, size: int = 4096) -> typing.Optional[files.URL]: """Generate the guild's icon URL, if set. Parameters ---------- ext : typing.Optional[str] The extension to use for this URL, defaults to `png` or `gif`. Supports `png`, `jpeg`, `jpg`, `webp` and `gif` (when animated). If `None`, then the correct default extension is determined based on whether the icon is animated or not. size : int The size to set for the URL, defaults to `4096`. Can be any power of two between 16 and 4096. Returns ------- typing.Optional[hikari.files.URL] The URL to the resource, or `None` if no icon is set. Raises ------ ValueError If `size` is not a power of two or not between 16 and 4096. """ if self.icon_hash is None: return None if ext is None: if self.icon_hash.startswith("a_"): ext = "gif" else: ext = "png" return routes.CDN_GUILD_ICON.compile_to_file( urls.CDN_URL, guild_id=self.id, hash=self.icon_hash, size=size, file_format=ext, )
Generate the guild's icon URL, if set.
Parameters
ext (typing.Optional[str]): The extension to use for this URL, defaults to
png
orgif
. Supportspng
,jpeg
,jpg
,webp
andgif
(when animated).If
None
, then the correct default extension is determined based on whether the icon is animated or not.- size (int): The size to set for the URL, defaults to
4096
. Can be any power of two between 16 and 4096.
Returns
- typing.Optional[hikari.files.URL]: The URL to the resource, or
None
if no icon is set.
Raises
- ValueError: If
size
is not a power of two or not between 16 and 4096.
View Source
def make_splash_url(self, *, ext: str = "png", size: int = 4096) -> typing.Optional[files.URL]: """Generate the guild's splash image URL, if set. Parameters ---------- ext : str The extension to use for this URL, defaults to `png`. Supports `png`, `jpeg`, `jpg` and `webp`. size : int The size to set for the URL, defaults to `4096`. Can be any power of two between 16 and 4096. Returns ------- typing.Optional[hikari.files.URL] The URL to the splash, or `None` if not set. Raises ------ ValueError If `size` is not a power of two or not between 16 and 4096. """ if self.splash_hash is None: return None return routes.CDN_GUILD_SPLASH.compile_to_file( urls.CDN_URL, guild_id=self.id, hash=self.splash_hash, size=size, file_format=ext, )
Generate the guild's splash image URL, if set.
Parameters
- ext (str): The extension to use for this URL, defaults to
png
. Supportspng
,jpeg
,jpg
andwebp
. - size (int): The size to set for the URL, defaults to
4096
. Can be any power of two between 16 and 4096.
Returns
- typing.Optional[hikari.files.URL]: The URL to the splash, or
None
if not set.
Raises
- ValueError: If
size
is not a power of two or not between 16 and 4096.
self,
user: Union[hikari.users.PartialUser, hikari.snowflakes.Snowflake, int],
*,
reason: Union[str, hikari.undefined.UndefinedType] = UNDEFINED
) -> None:
View Source
async def unban( self, user: snowflakes.SnowflakeishOr[users.PartialUser], *, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> None: """Unban the given user from this guild. Parameters ---------- user: hikari.snowflakes.Snowflakeish[hikari.users.PartialUser] The user to unban from the guild Other Parameters ---------------- reason : hikari.undefined.UndefinedOr[str] If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters. Raises ------ hikari.errors.BadRequestError If any of the fields that are passed have an invalid value. hikari.errors.ForbiddenError If you are missing the `BAN_MEMBERS` permission. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild or user are not found. hikari.errors.RateLimitTooLongError Raised in the event that a rate limit occurs that is longer than `max_rate_limit` when making a request. hikari.errors.RateLimitedError Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur. hikari.errors.InternalServerError If an internal error occurs on Discord while handling the request. """ await self.app.rest.unban_user(self.id, user, reason=reason)
Unban the given user from this guild.
Parameters
- user (hikari.snowflakes.Snowflakeish[hikari.users.PartialUser]): The user to unban from the guild
Other Parameters
- reason (hikari.undefined.UndefinedOr[str]): If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters.
Raises
- hikari.errors.BadRequestError: If any of the fields that are passed have an invalid value.
- hikari.errors.ForbiddenError: If you are missing the
BAN_MEMBERS
permission. - hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the guild or user are not found.
- hikari.errors.RateLimitTooLongError: Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. - hikari.errors.RateLimitedError: Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur.
- hikari.errors.InternalServerError: If an internal error occurs on Discord while handling the request.
View Source
@attr.define(hash=True, kw_only=True, weakref_slot=False) class InviteWithMetadata(Invite): """Extends the base `Invite` object with metadata. The metadata is only returned when getting an invite with guild permissions, rather than it's code. """ uses: int = attr.field(eq=False, hash=False, repr=True) """The amount of times this invite has been used.""" max_uses: typing.Optional[int] = attr.field(eq=False, hash=False, repr=True) """The limit for how many times this invite can be used before it expires. If set to `None` then this is unlimited. """ # TODO: can we use a non-None value to represent infinity here somehow, or # make a timedelta that is infinite for comparisons? max_age: typing.Optional[datetime.timedelta] = attr.field(eq=False, hash=False, repr=False) """The timedelta of how long this invite will be valid for. If set to `None` then this is unlimited. """ is_temporary: bool = attr.field(eq=False, hash=False, repr=True) """Whether this invite grants temporary membership.""" created_at: datetime.datetime = attr.field(eq=False, hash=False, repr=False) """When this invite was created.""" expires_at: typing.Optional[datetime.datetime] """When this invite will expire. If this invite doesn't have a set expiry then this will be `None`. """ @property def uses_left(self) -> typing.Optional[int]: """Return the number of uses left for this invite. This will be `None` if the invite has unlimited uses. """ if self.max_uses: return self.max_uses - self.uses return None
Extends the base Invite
object with metadata.
The metadata is only returned when getting an invite with guild permissions, rather than it's code.
Variables and properties
The client application that models may use for procedures.
The approximate amount of presences in this invite's guild.
This is only returned by the GET REST Invites endpoint.
The approximate amount of members in this invite's guild.
This is only returned by the GET Invites REST endpoint.
The partial object of the channel this invite targets.
Will be None
for invite objects that are attached to gateway events, in which case you should refer to Invite.channel_id
.
The ID of the channel this invite targets.
The code for this invite.
When this invite was created.
When this invite will expire.
If this invite doesn't have a set expiry then this will be None
.
The partial object of the guild this invite belongs to.
Will be None
for group DM invites and when attached to a gateway event; for invites received over the gateway you should refer to Invite.guild_id
.
The ID of the guild this invite belongs to.
Will be None
for group DM invites.
The object of the user who created this invite.
Whether this invite grants temporary membership.
The timedelta of how long this invite will be valid for.
If set to None
then this is unlimited.
The limit for how many times this invite can be used before it expires.
If set to None
then this is unlimited.
The embedded application this invite targets, if applicable.
The type of the target of this invite, if applicable.
The object of the user who this invite targets, if set.
The amount of times this invite has been used.
Return the number of uses left for this invite.
This will be None
if the invite has unlimited uses.
Methods
self,
*,
app: hikari.traits.RESTAware,
code: str,
guild: Optional[hikari.invites.InviteGuild],
guild_id: Optional[hikari.snowflakes.Snowflake],
channel: Optional[hikari.channels.PartialChannel],
channel_id: hikari.snowflakes.Snowflake,
inviter: Optional[hikari.users.User],
target_type: Union[hikari.invites.TargetType, int, NoneType],
target_user: Optional[hikari.users.User],
target_application: Optional[hikari.applications.InviteApplication],
approximate_active_member_count: Optional[int],
approximate_member_count: Optional[int],
uses: int,
max_uses: Optional[int],
max_age: Optional[datetime.timedelta],
is_temporary: bool,
created_at: datetime.datetime,
expires_at: Optional[datetime.datetime]
):
View Source
def __init__(self, *, app, code, guild, guild_id, channel, channel_id, inviter, target_type, target_user, target_application, approximate_active_member_count, approximate_member_count, uses, max_uses, max_age, is_temporary, created_at, expires_at): self.app = app self.code = code self.guild = guild self.guild_id = guild_id self.channel = channel self.channel_id = channel_id self.inviter = inviter self.target_type = target_type self.target_user = target_user self.target_application = target_application self.approximate_active_member_count = approximate_active_member_count self.approximate_member_count = approximate_member_count self.uses = uses self.max_uses = max_uses self.max_age = max_age self.is_temporary = is_temporary self.created_at = created_at self.expires_at = expires_at
Method generated by attrs for class InviteWithMetadata.
View Source
@typing.final class TargetType(int, enums.Enum): """The target of the invite.""" STREAM = 1 """This invite is targeting a "Go Live" stream.""" EMBEDDED_APPLICATION = 2 """This invite is targeting an embedded application."""
The target of the invite.
Variables and properties
This invite is targeting an embedded application.
This invite is targeting a "Go Live" stream.
the denominator of a rational number in lowest terms
the imaginary part of a complex number
Return the name of the enum member as a str
.
the numerator of a rational number in lowest terms
the real part of a complex number
Return the value of the enum member.
Methods
View Source
def __call__(cls, value: typing.Any) -> typing.Any: """Cast a value to the enum, returning the raw value that was passed if value not found.""" try: return cls._value_to_member_map_[value] except KeyError: # If we can't find the value, just return what got casted in return value
Cast a value to the enum, returning the raw value that was passed if value not found.
Return integer ratio.
Return a pair of integers, whose ratio is exactly equal to the original int and with a positive denominator.
>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
Number of bits necessary to represent self in binary.
>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
Returns self, the complex conjugate of any int.
Return the integer represented by the given array of bytes.
bytes Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol. byteorder The byte order used to represent the integer. If byteorder is 'big', the most significant byte is at the beginning of the byte array. If byteorder is 'little', the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder' as the byte order value. signed Indicates whether two's complement is used to represent the integer.
Return an array of bytes representing an integer.
length Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. byteorder The byte order used to represent the integer. If byteorder is 'big', the most significant byte is at the beginning of the byte array. If byteorder is 'little', the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder' as the byte order value. signed Determines whether two's complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.
View Source
@attr_extensions.with_copy @attr.define(hash=True, kw_only=True, weakref_slot=False) class VanityURL(InviteCode): """A special case invite object, that represents a guild's vanity url.""" app: traits.RESTAware = attr.field( repr=False, eq=False, hash=False, metadata={attr_extensions.SKIP_DEEP_COPY: True} ) """The client application that models may use for procedures.""" code: str = attr.field(hash=True, repr=True) """The code for this invite.""" uses: int = attr.field(eq=False, hash=False, repr=True) """The amount of times this invite has been used."""
A special case invite object, that represents a guild's vanity url.
Variables and properties
The client application that models may use for procedures.
The code for this invite.
The amount of times this invite has been used.
Methods
View Source
def __init__(self, *, app, code, uses): self.app = app self.code = code self.uses = uses
Method generated by attrs for class VanityURL.