hikari.guilds
Application and entities that are used to describe guilds 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 guilds on Discord.""" from __future__ import annotations __all__: typing.Sequence[str] = ( "Guild", "RESTGuild", "GatewayGuild", "GuildWidget", "Role", "GuildFeature", "GuildSystemChannelFlag", "GuildMessageNotificationsLevel", "GuildExplicitContentFilterLevel", "GuildMFALevel", "GuildVerificationLevel", "GuildPremiumTier", "GuildPreview", "GuildBan", "GuildNSFWLevel", "Member", "Integration", "IntegrationAccount", "IntegrationType", "IntegrationApplication", "IntegrationExpireBehaviour", "PartialApplication", "PartialGuild", "PartialIntegration", "PartialRole", "WelcomeScreen", "WelcomeChannel", ) import typing import attr from hikari import channels as channels_ from hikari import snowflakes from hikari import stickers from hikari import traits from hikari import undefined from hikari import urls from hikari import users from hikari.internal import attr_extensions from hikari.internal import deprecation from hikari.internal import enums from hikari.internal import routes from hikari.internal import time if typing.TYPE_CHECKING: import datetime from hikari import colors from hikari import colours from hikari import emojis as emojis_ from hikari import files from hikari import locales from hikari import permissions as permissions_ from hikari import presences as presences_ from hikari import voices as voices_ @typing.final class GuildExplicitContentFilterLevel(int, enums.Enum): """Represents the explicit content filter setting for a guild.""" DISABLED = 0 """No explicit content filter.""" MEMBERS_WITHOUT_ROLES = 1 """Filter posts from anyone without a role.""" ALL_MEMBERS = 2 """Filter all posts.""" @typing.final class GuildFeature(str, enums.Enum): """Features that a guild can provide.""" ANIMATED_ICON = "ANIMATED_ICON" """Guild has access to set an animated guild icon.""" BANNER = "BANNER" """Guild has access to set a guild banner image.""" COMMERCE = "COMMERCE" """Guild has access to use commerce features (i.e. create store channels).""" COMMUNITY = "COMMUNITY" """Guild has community features enabled.""" DISCOVERABLE = "DISCOVERABLE" """Guild is able to be discovered in the directory. This also implies the guild can be viewed without joining. """ FEATURABLE = "FEATURABLE" """Guild is able to be featured in the directory.""" INVITE_SPLASH = "INVITE_SPLASH" """Guild has access to set an invite splash background.""" MORE_EMOJI = "MORE_EMOJI" """More emojis can be hosted in this guild than normal.""" NEWS = "NEWS" """Guild has access to create news channels.""" PARTNERED = "PARTNERED" """Guild is partnered.""" RELAY_ENABLED = "RELAY_ENABLED" """Guild is using relays. Relays are new infrastructure designed to handle large guilds more efficiently server-side. """ VANITY_URL = "VANITY_URL" """Guild has access to set a vanity URL.""" VERIFIED = "VERIFIED" """Guild is verified.""" VIP_REGIONS = "VIP_REGIONS" """Guild has access to set 384kbps bitrate in voice. Previously gave access to VIP voice servers. """ WELCOME_SCREEN_ENABLED = "WELCOME_SCREEN_ENABLED" """Guild has enabled the welcome screen.""" MEMBER_VERIFICATION_GATE_ENABLED = "MEMBER_VERIFICATION_GATE_ENABLED" """Guild has enabled Membership Screening.""" PREVIEW_ENABLED = "PREVIEW_ENABLED" """Guild can be viewed before Membership Screening is complete.""" TICKETED_EVENTS_ENABLED = "TICKETED_EVENTS_ENABLED" """Guild has enabled ticketed events.""" MONETIZATION_ENABLED = "MONETIZATION_ENABLED" """Guild has enabled monetization.""" MORE_STICKERS = "MORE_STICKERS" """Guild has an increased custom stickers slots.""" @typing.final class GuildMessageNotificationsLevel(int, enums.Enum): """Represents the default notification level for new messages in a guild.""" ALL_MESSAGES = 0 """Notify users when any message is sent.""" ONLY_MENTIONS = 1 """Only notify users when they are @mentioned.""" @typing.final class GuildMFALevel(int, enums.Enum): """Represents the multi-factor authorization requirement for a guild.""" NONE = 0 """No MFA requirement.""" ELEVATED = 1 """MFA requirement.""" @typing.final class GuildPremiumTier(int, enums.Enum): """Tier for Discord Nitro boosting in a guild.""" NONE = 0 """No Nitro boost level.""" TIER_1 = 1 """Level 1 Nitro boost.""" TIER_2 = 2 """Level 2 Nitro boost.""" TIER_3 = 3 """Level 3 Nitro boost.""" @typing.final class GuildSystemChannelFlag(enums.Flag): """Defines which features are suppressed in the system channel.""" NONE = 0 """Nothing is suppressed.""" SUPPRESS_USER_JOIN = 1 << 0 """Suppress displaying a message about new users joining.""" SUPPRESS_PREMIUM_SUBSCRIPTION = 1 << 1 """Suppress displaying a message when the guild is Nitro boosted.""" SUPPRESS_GUILD_REMINDER = 1 << 2 """Suppress displaying messages with guild setup tips.""" SUPPRESS_USER_JOIN_REPLIES = 1 << 3 """Suppress displaying a reply button on join notifications.""" @typing.final class GuildVerificationLevel(int, enums.Enum): """Represents the level of verification of a guild.""" NONE = 0 """Unrestricted.""" LOW = 1 """Must have a verified email on their account.""" MEDIUM = 2 """Must have been registered on Discord for more than 5 minutes.""" HIGH = 3 """Must also be a member of the guild for longer than 10 minutes.""" VERY_HIGH = 4 """Must have a verified phone number.""" @typing.final class GuildNSFWLevel(int, enums.Enum): """Represents the NSFW level of a guild.""" DEFAULT = 0 """Guild has not been categorized yet.""" EXPLICIT = 1 """Guild contains explicit NSFW content.""" SAFE = 2 """Guild is safe of NSFW content.""" AGE_RESTRICTED = 3 """Guild may contain NSFW content.""" @attr_extensions.with_copy @attr.define(hash=False, kw_only=True, weakref_slot=False) class GuildWidget: """Represents a guild widget.""" 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.""" channel_id: typing.Optional[snowflakes.Snowflake] = attr.field(repr=True) """The ID of the channel the invite for this embed targets, if enabled.""" is_enabled: bool = attr.field(repr=True) """Whether this embed is enabled.""" async def fetch_channel(self) -> typing.Optional[channels_.GuildChannel]: """Fetch the widget channel. This will be `None` if not set. Returns ------- typing.Optional[hikari.channels.GuildChannel] The requested channel. You can check the type of the channel by using `isinstance`. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `READ_MESSAGES` 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. """ if not self.channel_id: return None widget_channel = await self.app.rest.fetch_channel(self.channel_id) assert isinstance(widget_channel, channels_.GuildChannel) return widget_channel @attr_extensions.with_copy @attr.define(eq=False, hash=False, kw_only=True, weakref_slot=False) class Member(users.User): """Used to represent a guild bound member.""" guild_id: snowflakes.Snowflake = attr.field(repr=True) """The ID of the guild this member belongs to.""" is_deaf: undefined.UndefinedOr[bool] = attr.field(repr=False) """`True` if this member is deafened in the current voice channel. This will be `hikari.undefined.UNDEFINED` if it's state is unknown. """ is_mute: undefined.UndefinedOr[bool] = attr.field(repr=False) """`True` if this member is muted in the current voice channel. This will be `hikari.undefined.UNDEFINED` if it's state is unknown. """ is_pending: undefined.UndefinedOr[bool] = attr.field(repr=False) """Whether the user has passed the guild's membership screening requirements. This will be `hikari.undefined.UNDEFINED` if it's state is unknown. """ joined_at: datetime.datetime = attr.field(repr=True) """The datetime of when this member joined the guild they belong to.""" nickname: typing.Optional[str] = attr.field(repr=True) """This member's nickname. This will be `None` if not set. """ premium_since: typing.Optional[datetime.datetime] = attr.field(repr=False) """The datetime of when this member started "boosting" this guild. Will be `None` if the member is not a premium user. """ raw_communication_disabled_until: typing.Optional[datetime.datetime] = attr.field(repr=False) """The datetime when this member's timeout will expire. Will be `None` if the member is not timed out. .. note:: The datetime might be in the past, so it is recommended to use `communication_disabled_until` method to check if the member is timed out at the time of the call. """ role_ids: typing.Sequence[snowflakes.Snowflake] = attr.field(repr=False) """A sequence of the IDs of the member's current roles.""" # This is technically optional, since UPDATE MEMBER and MESSAGE CREATE # events do not inject the user into the member payload, but specify it # separately. However, to get around this inconsistency, we force the # entity factory to always provide the user object in these cases, so we # can assume this is always set, and thus we are always able to get info # such as the ID of the user this member represents. user: users.User = attr.field(repr=True) """This member's corresponding user object.""" guild_avatar_hash: typing.Optional[str] = attr.field(eq=False, hash=False, repr=False) """Hash of the member's guild avatar guild if set, else `None`. .. note:: This takes precedence over `Member.avatar_hash`. """ @property def app(self) -> traits.RESTAware: """Return the app that is bound to the user object.""" return self.user.app @property def avatar_hash(self) -> typing.Optional[str]: return self.user.avatar_hash @property def avatar_url(self) -> typing.Optional[files.URL]: return self.user.avatar_url @property def guild_avatar_url(self) -> typing.Optional[files.URL]: """Guild Avatar URL for the user, if they have one set. May be `None` if no guild avatar is set. In this case, you should use `avatar_hash` or `default_avatar_url` instead. """ return self.make_guild_avatar_url() @property def default_avatar_url(self) -> files.URL: return self.user.default_avatar_url @property def display_avatar_url(self) -> files.URL: return self.make_guild_avatar_url() or super().display_avatar_url @property def banner_hash(self) -> typing.Optional[str]: return self.user.banner_hash @property def banner_url(self) -> typing.Optional[files.URL]: return self.user.banner_url @property def accent_color(self) -> typing.Optional[colors.Color]: return self.user.accent_color @property def discriminator(self) -> str: return self.user.discriminator @property def display_name(self) -> str: """Return the member's display name. If the member has a nickname, this will return that nickname. Otherwise, it will return the username instead. See Also -------- `Member.nickname` `Member.username` """ return self.nickname if isinstance(self.nickname, str) else self.username @property def flags(self) -> users.UserFlag: return self.user.flags @property def id(self) -> snowflakes.Snowflake: return self.user.id @property def is_bot(self) -> bool: return self.user.is_bot @property def is_system(self) -> bool: return self.user.is_system @property def mention(self) -> str: """Return a raw mention string for the given member. If the member has a known nickname, we always return a bang ("`!`") before the ID part of the mention string. This mimics the behaviour Discord clients tend to provide. Example ------- ```py >>> some_member_without_nickname.mention '<@123456789123456789>' >>> some_member_with_nickname.mention '<@!123456789123456789>' ``` """ return f"<@!{self.id}>" if self.nickname is not None else self.user.mention def communication_disabled_until(self) -> typing.Optional[datetime.datetime]: """Return when the timeout for this member ends. Unlike `raw_communication_disabled_until`, this will always be `None` if the member is not currently timed out. .. note:: The output of this function can depend based on when the function is called. """ if ( self.raw_communication_disabled_until is not None and self.raw_communication_disabled_until > time.utc_datetime() ): return self.raw_communication_disabled_until return None def get_guild(self) -> typing.Optional[Guild]: """Return the guild associated with this member. Returns ------- typing.Optional[hikari.guilds.Guild] The linked guild object or `None` if it's not cached. """ if not isinstance(self.user.app, traits.CacheAware): return None return self.user.app.cache.get_guild(self.guild_id) def get_presence(self) -> typing.Optional[presences_.MemberPresence]: """Get the cached presence for this member, if known. Presence info includes user status and activities. This requires the `GUILD_PRESENCES` intent to be enabled. Returns ------- typing.Optional[hikari.presences.MemberPresence] The member presence, or `None` if not known. """ if not isinstance(self.user.app, traits.CacheAware): return None return self.user.app.cache.get_presence(self.guild_id, self.user.id) def get_roles(self) -> typing.Sequence[Role]: """Return the roles the user has. This will be empty if the roles are missing from the cache. Returns ------- typing.Sequence[hikari.guilds.Role] The roles the users has. """ roles: typing.List[Role] = [] if not isinstance(self.user.app, traits.CacheAware): return roles for role_id in self.role_ids: if role := self.user.app.cache.get_role(role_id): roles.append(role) return roles def get_top_role(self) -> typing.Optional[Role]: """Return the highest role the member has. Returns ------- typing.Optional[hikari.guilds.Role] `None` if the cache is missing the roles information or the highest role the user has. """ roles = sorted(self.get_roles(), key=lambda r: r.position, reverse=True) try: return next(iter(roles)) except StopIteration: return None @property def username(self) -> str: return self.user.username def make_avatar_url(self, *, ext: typing.Optional[str] = None, size: int = 4096) -> typing.Optional[files.URL]: return self.user.make_avatar_url(ext=ext, size=size) def make_guild_avatar_url( self, *, ext: typing.Optional[str] = None, size: int = 4096 ) -> typing.Optional[files.URL]: """Generate the guild specific avatar url for this member, if set. If no guild avatar is set, this returns `None`. You can then use the `make_avatar_url` to get their global custom avatar or `default_avatar_url` if they have no custom avatar 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). Will be ignored for default avatars which can only be `png`. 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. Will be ignored for default avatars. Returns ------- typing.Optional[hikari.files.URL] The URL to the avatar, or `None` if not present. Raises ------ ValueError If `size` is not a power of two or not between 16 and 4096. """ if self.guild_avatar_hash is None: return None if ext is None: if self.guild_avatar_hash.startswith("a_"): ext = "gif" else: ext = "png" return routes.CDN_MEMBER_AVATAR.compile_to_file( urls.CDN_URL, guild_id=self.guild_id, user_id=self.id, hash=self.guild_avatar_hash, size=size, file_format=ext, ) async def fetch_self(self) -> Member: """Fetch an up-to-date view of this member from the API. Returns ------- hikari.guilds.Member An up-to-date view of this member. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the member 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.user.app.rest.fetch_member(self.guild_id, self.user.id) async def fetch_dm_channel(self) -> channels_.DMChannel: return await self.user.fetch_dm_channel() async def fetch_roles(self) -> typing.Sequence[Role]: """Fetch an up-to-date view of this member's roles from the API. Returns ------- typing.Sequence[hikari.guilds.Role] An up-to-date view of this member's roles. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the member 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. """ fetched_roles = await self.app.rest.fetch_roles(self.guild_id) return [role for role in fetched_roles if role.id in self.role_ids] async def ban( self, *, delete_message_days: undefined.UndefinedOr[int] = undefined.UNDEFINED, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> None: """Ban this member from this 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.user.app.rest.ban_user( self.guild_id, self.user.id, delete_message_days=delete_message_days, reason=reason ) async def unban( self, *, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> None: """Unban this member 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.user.app.rest.unban_user(self.guild_id, self.user.id, reason=reason) async def kick( self, *, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> None: """Kick this member from this 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.user.app.rest.kick_user(self.guild_id, self.user.id, reason=reason) async def add_role( self, role: snowflakes.SnowflakeishOr[PartialRole], *, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED ) -> None: """Add a role to the member. Parameters ---------- role : hikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialRole] The role to add. This may be the object or the ID of an existing role. 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 the `MANAGE_ROLES` permission. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild, user or role 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.user.app.rest.add_role_to_member(self.guild_id, self.user.id, role, reason=reason) async def remove_role( self, role: snowflakes.SnowflakeishOr[PartialRole], *, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED ) -> None: """Remove a role from the member. Parameters ---------- role : hikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialRole] The role to remove. This may be the object or the ID of an existing role. 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 the `MANAGE_ROLES` permission. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild, user or role 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.user.app.rest.remove_role_from_member(self.guild_id, self.user.id, role, reason=reason) async def edit( self, *, nickname: undefined.UndefinedNoneOr[str] = undefined.UNDEFINED, nick: undefined.UndefinedNoneOr[str] = undefined.UNDEFINED, roles: undefined.UndefinedOr[snowflakes.SnowflakeishSequence[PartialRole]] = undefined.UNDEFINED, mute: undefined.UndefinedOr[bool] = undefined.UNDEFINED, deaf: undefined.UndefinedOr[bool] = undefined.UNDEFINED, voice_channel: undefined.UndefinedNoneOr[ snowflakes.SnowflakeishOr[channels_.GuildVoiceChannel] ] = undefined.UNDEFINED, communication_disabled_until: undefined.UndefinedNoneOr[datetime.datetime] = undefined.UNDEFINED, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> Member: """Edit the member. Other Parameters ---------------- nickname : hikari.undefined.UndefinedNoneOr[str] If provided, the new nick for the member. If `None`, will remove the members nick. Requires the `MANAGE_NICKNAMES` permission. nick : hikari.undefined.UndefinedNoneOr[str] Deprecated alias for `nickname`. roles : hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishSequence[hikari.guilds.PartialRole]] If provided, the new roles for the member. Requires the `MANAGE_ROLES` permission. mute : hikari.undefined.UndefinedOr[bool] If provided, the new server mute state for the member. Requires the `MUTE_MEMBERS` permission. deaf : hikari.undefined.UndefinedOr[bool] If provided, the new server deaf state for the member. Requires the `DEAFEN_MEMBERS` permission. voice_channel : hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishOr[hikari.channels.GuildVoiceChannel]]] If provided, `None` or the object or the ID of an existing voice channel to move the member to. If `None`, will disconnect the member from voice. Requires the `MOVE_MEMBERS` permission and the `CONNECT` permission in the original voice channel and the target voice channel. .. note:: If the member is not in a voice channel, this will take no effect. communication_disabled_until : hikari.undefined.UndefinedNoneOr[datetime.datetime] If provided, the datetime when the timeout (disable communication) of the member expires, up to 28 days in the future, or `None` to remove the timeout from the member. Requires the `MODERATE_MEMBERS` permission. reason : hikari.undefined.UndefinedOr[str] If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters. Returns ------- hikari.guilds.Member Object of the member that was updated. Raises ------ hikari.errors.BadRequestError If any of the fields that are passed have an invalid value. hikari.errors.ForbiddenError If you are missing a permission to do an action. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild or the 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. """ if nick is not undefined.UNDEFINED: deprecation.warn_deprecated("nick", "Use 'nickname' argument instead") nickname = nick return await self.user.app.rest.edit_member( self.guild_id, self.user.id, nickname=nickname, roles=roles, mute=mute, deaf=deaf, voice_channel=voice_channel, communication_disabled_until=communication_disabled_until, reason=reason, ) def __str__(self) -> str: return str(self.user) def __hash__(self) -> int: return hash(self.user) def __eq__(self, other: object) -> bool: return self.user == other @attr_extensions.with_copy @attr.define(hash=True, kw_only=True, weakref_slot=False) class PartialRole(snowflakes.Unique): """Represents a partial guild bound role object.""" 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.""" id: snowflakes.Snowflake = attr.field(hash=True, repr=True) """The ID of this entity.""" name: str = attr.field(eq=False, hash=False, repr=True) """The role's name.""" @property def mention(self) -> str: """Return a raw mention string for the role.""" return f"<@&{self.id}>" def __str__(self) -> str: return self.name @attr.define(hash=True, kw_only=True, weakref_slot=False) class Role(PartialRole): """Represents a guild bound Role object.""" color: colors.Color = attr.field(eq=False, hash=False, repr=True) """The colour of this role. This will be applied to a member's name in chat if it's their top coloured role. """ guild_id: snowflakes.Snowflake = attr.field(eq=False, hash=False, repr=True) """The ID of the guild this role belongs to""" is_hoisted: bool = attr.field(eq=False, hash=False, repr=True) """Whether this role is hoisting the members it's attached to in the member list. members will be hoisted under their highest role where this is set to `True`. """ icon_hash: typing.Optional[str] = attr.field(eq=False, hash=False, repr=False) """Hash of the role's icon if set, else `None`.""" unicode_emoji: typing.Optional[emojis_.UnicodeEmoji] = attr.field(eq=False, hash=False, repr=False) """Role's icon as an unicode emoji if set, else `None`.""" is_managed: bool = attr.field(eq=False, hash=False, repr=False) """Whether this role is managed by an integration.""" is_mentionable: bool = attr.field(eq=False, hash=False, repr=False) """Whether this role can be mentioned by all regardless of permissions.""" permissions: permissions_.Permissions = attr.field(eq=False, hash=False, repr=False) """The guild wide permissions this role gives to the members it's attached to, This may be overridden by channel overwrites. """ position: int = attr.field(eq=False, hash=False, repr=True) """The position of this role in the role hierarchy. This will start at `0` for the lowest role (@everyone) and increase as you go up the hierarchy. """ bot_id: typing.Optional[snowflakes.Snowflake] = attr.field(eq=False, hash=False, repr=True) """The ID of the bot this role belongs to. If `None`, this is not a bot role. """ integration_id: typing.Optional[snowflakes.Snowflake] = attr.field(eq=False, hash=False, repr=True) """The ID of the integration this role belongs to. If `None`, this is not a integration role. """ is_premium_subscriber_role: bool = attr.field(eq=False, hash=False, repr=True) """Whether this role is the guild's nitro subscriber role.""" @property def colour(self) -> colours.Colour: """Alias for the `color` field.""" return self.color @property def icon_url(self) -> typing.Optional[files.URL]: """Role icon URL, if there is one. Returns ------- typing.Optional[hikari.files.URL] The URL, or `None` if no icon exists. """ return self.make_icon_url() def make_icon_url(self, *, ext: str = "png", size: int = 4096) -> typing.Optional[files.URL]: """Generate the icon URL for this role, if set. If no role icon is set, this returns `None`. 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 icon, or `None` if not present. Raises ------ ValueError If `size` is not a power of two or not between 16 and 4096. """ if self.icon_hash is None: return None return routes.CDN_ROLE_ICON.compile_to_file( urls.CDN_URL, role_id=self.id, hash=self.icon_hash, size=size, file_format=ext, ) @typing.final class IntegrationType(str, enums.Enum): """The integration type.""" TWITCH = "twitch" YOUTUBE = "youtube" DISCORD_BOT = "discord" @typing.final class IntegrationExpireBehaviour(int, enums.Enum): """Behavior for expiring integration subscribers.""" REMOVE_ROLE = 0 """Remove the role.""" KICK = 1 """Kick the subscriber.""" @attr_extensions.with_copy @attr.define(hash=True, kw_only=True, weakref_slot=False) class IntegrationAccount: """An account that's linked to an integration.""" id: str = attr.field(hash=True, repr=True) """The string ID of this (likely) third party account.""" name: str = attr.field(eq=False, hash=False, repr=True) """The name of this account.""" def __str__(self) -> str: return self.name # This is here rather than in applications.py to avoid circular imports @attr_extensions.with_copy @attr.define(hash=True, kw_only=True, weakref_slot=False) class PartialApplication(snowflakes.Unique): """A partial representation of a Discord application.""" id: snowflakes.Snowflake = attr.field(hash=True, repr=True) """The ID of this entity.""" name: str = attr.field(eq=False, hash=False, repr=True) """The name of this application.""" description: typing.Optional[str] = attr.field(eq=False, hash=False, repr=False) """The description of this application, if any.""" icon_hash: typing.Optional[str] = attr.field(eq=False, hash=False, repr=False) """The CDN hash of this application's icon, if set.""" def __str__(self) -> str: return self.name @property def icon_url(self) -> typing.Optional[files.URL]: """Team icon URL, if there is one.""" return self.make_icon_url() def make_icon_url(self, *, ext: str = "png", size: int = 4096) -> typing.Optional[files.URL]: """Generate the icon URL for this application. 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, or `None` if no icon exists. Raises ------ ValueError If the size is not an integer power of 2 between 16 and 4096 (inclusive). """ if self.icon_hash is None: return None return routes.CDN_APPLICATION_ICON.compile_to_file( urls.CDN_URL, application_id=self.id, hash=self.icon_hash, size=size, file_format=ext, ) @attr_extensions.with_copy @attr.define(hash=True, kw_only=True, weakref_slot=False) class IntegrationApplication(PartialApplication): """An application that's linked to an integration.""" bot: typing.Optional[users.User] = attr.field(eq=False, hash=False, repr=False) """The bot associated with this application.""" @attr_extensions.with_copy @attr.define(hash=True, kw_only=True, weakref_slot=False) class PartialIntegration(snowflakes.Unique): """A partial representation of an integration, found in audit logs.""" account: IntegrationAccount = attr.field(eq=False, hash=False, repr=False) """The account connected to this integration.""" id: snowflakes.Snowflake = attr.field(hash=True, repr=True) """The ID of this entity.""" name: str = attr.field(eq=False, hash=False, repr=True) """The name of this integration.""" type: typing.Union[IntegrationType, str] = attr.field(eq=False, hash=False, repr=True) """The type of this integration.""" def __str__(self) -> str: return self.name @attr.define(hash=True, kw_only=True, weakref_slot=False) class Integration(PartialIntegration): """Represents a guild integration object.""" guild_id: snowflakes.Snowflake = attr.field() """The ID of the guild this integration belongs to.""" expire_behavior: typing.Union[IntegrationExpireBehaviour, int, None] = attr.field(eq=False, hash=False, repr=False) """How members should be treated after their connected subscription expires. This will not be enacted until after `GuildIntegration.expire_grace_period` passes. .. note:: This will always be `None` for Discord integrations. """ expire_grace_period: typing.Optional[datetime.timedelta] = attr.field(eq=False, hash=False, repr=False) """How many days users with expired subscriptions are given until `GuildIntegration.expire_behavior` is enacted out on them. .. note:: This will always be `None` for Discord integrations. """ is_enabled: bool = attr.field(eq=False, hash=False, repr=True) """Whether this integration is enabled.""" is_syncing: typing.Optional[bool] = attr.field(eq=False, hash=False, repr=False) """Whether this integration is syncing subscribers/emojis.""" is_emojis_enabled: typing.Optional[bool] = attr.field(eq=False, hash=False, repr=False) """Whether users under this integration are allowed to use it's custom emojis.""" is_revoked: typing.Optional[bool] = attr.field(eq=False, hash=False, repr=False) """Whether the integration has been revoked.""" last_synced_at: typing.Optional[datetime.datetime] = attr.field(eq=False, hash=False, repr=False) """The datetime of when this integration's subscribers were last synced.""" role_id: typing.Optional[snowflakes.Snowflake] = attr.field(eq=False, hash=False, repr=False) """The ID of the managed role used for this integration's subscribers.""" user: typing.Optional[users.User] = attr.field(eq=False, hash=False, repr=False) """The user this integration belongs to.""" subscriber_count: typing.Optional[int] = attr.field(eq=False, hash=False, repr=False) """The number of subscribers this integration has.""" application: typing.Optional[IntegrationApplication] = attr.field(eq=False, hash=False, repr=False) """The bot/OAuth2 application associated with this integration. .. note:: This is only available for Discord integrations. """ @attr_extensions.with_copy @attr.define(hash=False, weakref_slot=False) class WelcomeChannel: """Used to represent channels on guild welcome screens.""" channel_id: snowflakes.Snowflake = attr.field(hash=False, repr=True) """ID of the channel shown in the welcome screen.""" description: str = attr.field(hash=False, repr=False) """The description shown for this channel.""" emoji_name: typing.Union[str, emojis_.UnicodeEmoji, None] = attr.field( default=None, kw_only=True, hash=False, repr=True ) """The emoji shown in the welcome screen channel if set to a unicode emoji. .. warning:: While it may also be present for custom emojis, this is neither guaranteed to be provided nor accurate. """ emoji_id: typing.Optional[snowflakes.Snowflake] = attr.field(default=None, kw_only=True, hash=False, repr=True) """ID of the emoji shown in the welcome screen channel if it's set to a custom emoji.""" @attr_extensions.with_copy @attr.define(hash=False, kw_only=True, weakref_slot=False) class WelcomeScreen: """Used to represent guild welcome screens on Discord.""" description: typing.Optional[str] = attr.field(hash=False, repr=True) """The guild's description shown in the welcome screen.""" channels: typing.Sequence[WelcomeChannel] = attr.field(hash=False, repr=True) """An array of up to 5 of the channels shown in the welcome screen.""" @attr_extensions.with_copy @attr.define(hash=False, kw_only=True, weakref_slot=False) class GuildBan: """Used to represent guild bans.""" reason: typing.Optional[str] = attr.field(repr=True) """The reason for this ban, will be `None` if no reason was given.""" user: users.User = attr.field(repr=True) """The object of the user this ban targets.""" @attr_extensions.with_copy @attr.define(hash=True, kw_only=True, weakref_slot=False) class PartialGuild(snowflakes.Unique): """Base object for any partial guild objects.""" 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.""" id: snowflakes.Snowflake = attr.field(hash=True, repr=True) """The ID of this entity.""" icon_hash: typing.Optional[str] = attr.field(eq=False, hash=False, repr=False) """The hash for the guild icon, if there is one.""" name: str = attr.field(eq=False, hash=False, repr=True) """The name of the guild.""" def __str__(self) -> str: return self.name @property def icon_url(self) -> typing.Optional[files.URL]: """Icon URL for the guild, if set; otherwise `None`.""" return self.make_icon_url() @property def shard_id(self) -> typing.Optional[int]: """Return the ID of the shard this guild is served by. This may return `None` if the application does not have a gateway connection. """ if not isinstance(self.app, traits.ShardAware): return None shard_count = self.app.shard_count assert isinstance(shard_count, int) return snowflakes.calculate_shard_id(shard_count, self.id) 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, ) 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) 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) 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) 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, ) 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) 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) 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) 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) 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) 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 ) 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) 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 ) 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, ) 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, ) 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, ) 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, ) 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 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) 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) @attr.define(hash=True, kw_only=True, weakref_slot=False) class GuildPreview(PartialGuild): """A preview of a guild with the `GuildFeature.DISCOVERABLE` feature.""" features: typing.Sequence[typing.Union[str, GuildFeature]] = 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.""" discovery_splash_hash: typing.Optional[str] = attr.field(eq=False, hash=False, repr=False) """The hash of the discovery splash for the guild, if there is one.""" emojis: typing.Mapping[snowflakes.Snowflake, emojis_.KnownCustomEmoji] = attr.field( eq=False, hash=False, repr=False ) """The mapping of IDs to the emojis this guild provides.""" approximate_active_member_count: int = attr.field(eq=False, hash=False, repr=True) """The approximate amount of presences in this guild.""" approximate_member_count: int = attr.field(eq=False, hash=False, repr=True) """The approximate amount of members in this guild.""" description: typing.Optional[str] = attr.field(eq=False, hash=False, repr=False) """The guild's description, if set.""" @property def discovery_splash_url(self) -> typing.Optional[files.URL]: """Discovery URL splash for the guild, if set.""" return self.make_discovery_splash_url() @property def splash_url(self) -> typing.Optional[files.URL]: """Splash URL for the guild, if set.""" return self.make_splash_url() def make_discovery_splash_url(self, *, ext: str = "png", size: int = 4096) -> typing.Optional[files.URL]: """Generate the guild's discovery 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 string URL. Raises ------ ValueError If `size` is not a power of two or not between 16 and 4096. """ if self.discovery_splash_hash is None: return None return routes.CDN_GUILD_DISCOVERY_SPLASH.compile_to_file( urls.CDN_URL, guild_id=self.id, hash=self.discovery_splash_hash, size=size, file_format=ext, ) 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, ) @attr.define(hash=True, kw_only=True, weakref_slot=False) class Guild(PartialGuild): """A representation of a guild on Discord.""" features: typing.Sequence[typing.Union[str, GuildFeature]] = attr.field(eq=False, hash=False, repr=False) """A list of the features in this guild.""" application_id: typing.Optional[snowflakes.Snowflake] = attr.field(eq=False, hash=False, repr=False) """The ID of the application that created this guild. This will always be `None` for guilds that weren't created by a bot. """ afk_channel_id: typing.Optional[snowflakes.Snowflake] = attr.field(eq=False, hash=False, repr=False) """The ID for the channel that AFK voice users get sent to. If `None`, then no AFK channel is set up for this guild. """ afk_timeout: datetime.timedelta = attr.field(eq=False, hash=False, repr=False) """Timeout for activity before a member is classed as AFK. How long a voice user has to be AFK for before they are classed as being AFK and are moved to the AFK channel (`Guild.afk_channel_id`). """ 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 the guild has `GuildFeature.BANNER` in `Guild.features` for this guild. For all other purposes, it is `None`. """ default_message_notifications: typing.Union[GuildMessageNotificationsLevel, int] = attr.field( eq=False, hash=False, repr=False ) """The default setting for message notifications in this guild.""" description: typing.Optional[str] = attr.field(eq=False, hash=False, repr=False) """The guild's description. This is only present if certain `GuildFeature`'s are set in `Guild.features` for this guild. Otherwise, this will always be `None`. """ discovery_splash_hash: typing.Optional[str] = attr.field(eq=False, hash=False, repr=False) """The hash of the discovery splash for the guild, if there is one.""" explicit_content_filter: typing.Union[GuildExplicitContentFilterLevel, int] = attr.field( eq=False, hash=False, repr=False ) """The setting for the explicit content filter in this guild.""" is_widget_enabled: typing.Optional[bool] = attr.field(eq=False, hash=False, repr=False) """Describes whether the guild widget is enabled or not. If this information is not present, this will be `None`. """ max_video_channel_users: typing.Optional[int] = attr.field(eq=False, hash=False, repr=False) """The maximum number of users allowed in a video channel together. This information may not be present, in which case, it will be `None`. """ mfa_level: typing.Union[GuildMFALevel, int] = attr.field(eq=False, hash=False, repr=False) """The required MFA level for users wishing to participate in this guild.""" owner_id: snowflakes.Snowflake = attr.field(eq=False, hash=False, repr=True) """The ID of the owner of this guild.""" preferred_locale: typing.Union[str, locales.Locale] = attr.field(eq=False, hash=False, repr=False) """The preferred locale to use for this guild. This can only be change if `GuildFeature.COMMUNITY` is in `Guild.features` for this guild and will otherwise default to `en-US`. """ premium_subscription_count: typing.Optional[int] = attr.field(eq=False, hash=False, repr=False) """The number of nitro boosts that the server currently has. This information may not be present, in which case, it will be `None`. """ premium_tier: typing.Union[GuildPremiumTier, int] = attr.field(eq=False, hash=False, repr=False) """The premium tier for this guild.""" public_updates_channel_id: typing.Optional[snowflakes.Snowflake] = attr.field(eq=False, hash=False, repr=False) """The channel ID of the channel where admins and moderators receive notices from Discord. This is only present if `GuildFeature.COMMUNITY` is in `Guild.features` for this guild. For all other purposes, it should be considered to be `None`. """ rules_channel_id: typing.Optional[snowflakes.Snowflake] = attr.field(eq=False, hash=False, repr=False) """The ID of the channel where guilds with the `GuildFeature.COMMUNITY` `features` display rules and guidelines. If the `GuildFeature.COMMUNITY` feature is not defined, then this is `None`. """ 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.""" system_channel_flags: GuildSystemChannelFlag = attr.field(eq=False, hash=False, repr=False) """Return flags for the guild system channel. These are used to describe which notifications are suppressed. """ system_channel_id: typing.Optional[snowflakes.Snowflake] = attr.field(eq=False, hash=False, repr=False) """The ID of the system channel or `None` if it is not enabled. Welcome messages and Nitro boost messages may be sent to this channel. """ vanity_url_code: typing.Optional[str] = attr.field(eq=False, hash=False, repr=False) """The vanity URL code for the guild's vanity URL. This is only present if `GuildFeature.VANITY_URL` is in `Guild.features` for this guild. If not, this will always be `None`. """ verification_level: typing.Union[GuildVerificationLevel, int] = attr.field(eq=False, hash=False, repr=False) """The verification level needed for a user to participate in this guild.""" widget_channel_id: typing.Optional[snowflakes.Snowflake] = attr.field(eq=False, hash=False, repr=False) """The channel ID that the widget's generated invite will send the user to. If this information is unavailable or this is not enabled for the guild then this will be `None`. """ nsfw_level: GuildNSFWLevel = attr.field(eq=False, hash=False, repr=False) """The NSFW level of the guild.""" @property def banner_url(self) -> typing.Optional[files.URL]: """Banner URL for the guild, if set.""" return self.make_banner_url() @property def discovery_splash_url(self) -> typing.Optional[files.URL]: """Discovery splash URL for the guild, if set.""" return self.make_discovery_splash_url() @property def splash_url(self) -> typing.Optional[files.URL]: """Splash URL for the guild, if set.""" return self.make_splash_url() def get_members(self) -> typing.Mapping[snowflakes.Snowflake, Member]: """Get the members cached for the guild. typing.Mapping[hikari.snowflakes.Snowflake, Member] A mapping of user IDs to objects of the members cached for the guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_members_view_for_guild(self.id) def get_presences(self) -> typing.Mapping[snowflakes.Snowflake, presences_.MemberPresence]: """Get the presences cached for the guild. typing.Mapping[hikari.snowflakes.Snowflake, hikari.presences.MemberPresence] A mapping of user IDs to objects of the presences cached for the guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_presences_view_for_guild(self.id) def get_channels(self) -> typing.Mapping[snowflakes.Snowflake, channels_.GuildChannel]: """Get the channels cached for the guild. Returns ------- typing.Mapping[hikari.snowflakes.Snowflake, hikari.channels.GuildChannel] A mapping of channel IDs to objects of the channels cached for the guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_guild_channels_view_for_guild(self.id) def get_voice_states(self) -> typing.Mapping[snowflakes.Snowflake, voices_.VoiceState]: """Get the voice states cached for the guild. Returns ------- typing.Mapping[hikari.snowflakes.Snowflake, hikari.voices.VoiceState] A mapping of user IDs to objects of the voice states cached for the guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_voice_states_view_for_guild(self.id) def get_emojis(self) -> typing.Mapping[snowflakes.Snowflake, emojis_.KnownCustomEmoji]: """Return the emojis in this guild. Returns ------- typing.Mapping[hikari.snowflakes.Snowflake, hikari.emojis.KnownCustomEmoji] A mapping of emoji IDs to the objects of emojis in this guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_emojis_view_for_guild(self.id) def get_roles(self) -> typing.Mapping[snowflakes.Snowflake, Role]: """Return the roles in this guild. Returns ------- typing.Mapping[hikari.snowflakes.Snowflake, Role] A mapping of role IDs to the objects of roles in this guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_roles_view_for_guild(self.id) 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, ) def make_discovery_splash_url(self, *, ext: str = "png", size: int = 4096) -> typing.Optional[files.URL]: """Generate the guild's discovery 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 string URL. Raises ------ ValueError If `size` is not a power of two or not between 16 and 4096. """ if self.discovery_splash_hash is None: return None return routes.CDN_GUILD_DISCOVERY_SPLASH.compile_to_file( urls.CDN_URL, guild_id=self.id, hash=self.discovery_splash_hash, size=size, file_format=ext, ) 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, ) def get_channel( self, channel: snowflakes.SnowflakeishOr[channels_.PartialChannel], ) -> typing.Optional[channels_.GuildChannel]: """Get a cached channel that belongs to the guild by it's ID or object. Parameters ---------- channel : hikari.snowflakes.SnowflakeishOr[hikari.channels.PartialChannel] The object or ID of the guild channel to get from the cache. Returns ------- typing.Optional[hikari.channels.GuildChannel] The object of the guild channel found in cache or `None. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_guild_channel(channel) def get_member(self, user: snowflakes.SnowflakeishOr[users.PartialUser]) -> typing.Optional[Member]: """Get a cached member that belongs to the guild by it's user ID or object. Parameters ---------- user : hikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser] The object or ID of the user to get the cached member for. Returns ------- typing.Optional[Member] The cached member object if found, else `None`. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_member(self.id, user) def get_my_member(self) -> typing.Optional[Member]: """Return the cached member for the bot user in this guild, if known. Returns ------- typing.Optional[Member] The cached member for this guild, or `None` if not known. """ if not isinstance(self.app, traits.ShardAware): return None me = self.app.get_me() if me is None: return None return self.get_member(me.id) def get_presence( self, user: snowflakes.SnowflakeishOr[users.PartialUser] ) -> typing.Optional[presences_.MemberPresence]: """Get a cached presence that belongs to the guild by it's user ID or object. Parameters ---------- user : hikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser] The object or ID of the user to get the cached presence for. Returns ------- typing.Optional[hikari.presences.MemberPresence] The cached presence object if found, else `None`. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_presence(self.id, user) def get_voice_state( self, user: snowflakes.SnowflakeishOr[users.PartialUser] ) -> typing.Optional[voices_.VoiceState]: """Get a cached voice state that belongs to the guild by it's user. Parameters ---------- user : hikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser] The object or ID of the user to get the cached voice state for. Returns ------- typing.Optional[hikari.voices.VoiceState] The cached voice state object if found, else `None`. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_voice_state(self.id, user) def get_emoji( self, emoji: snowflakes.SnowflakeishOr[emojis_.CustomEmoji] ) -> typing.Optional[emojis_.KnownCustomEmoji]: """Get a cached emoji that belongs to the guild by it's ID or object. Parameters ---------- emoji : hikari.snowflakes.SnowflakeishOr[hikari.emojis.CustomEmoji] The object or ID of the emoji to get from the cache. Returns ------- typing.Optional[hikari.emojis.KnownCustomEmoji] The object of the custom emoji if found in cache, else `None`. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_emoji(emoji) def get_role(self, role: snowflakes.SnowflakeishOr[PartialRole]) -> typing.Optional[Role]: """Get a cached role that belongs to the guild by it's ID or object. Parameters ---------- role : hikari.snowflakes.SnowflakeishOr[PartialRole] The object or ID of the role to get for this guild from the cache. Returns ------- typing.Optional[Role] The object of the role found in cache, else `None`. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_role(role) async def fetch_owner(self) -> Member: """Fetch the owner of the guild. Returns ------- hikari.guilds.Member The guild owner. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild or the 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. """ return await self.app.rest.fetch_member(self.id, self.owner_id) async def fetch_widget_channel(self) -> typing.Optional[channels_.GuildChannel]: """Fetch the widget channel. This will be `None` if not set. Returns ------- typing.Optional[hikari.channels.GuildChannel] The channel the widget is linked to or else `None`. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `READ_MESSAGES` 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. """ if not self.widget_channel_id: return None widget_channel = await self.app.rest.fetch_channel(self.widget_channel_id) assert isinstance(widget_channel, channels_.GuildChannel) return widget_channel async def fetch_afk_channel(self) -> typing.Optional[channels_.GuildVoiceChannel]: """Fetch the channel that AFK voice users get sent to. Returns ------- typing.Optional[hikari.channels.GuildVoiceChannel] The AFK channel or `None` if not enabled. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `READ_MESSAGES` 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. """ if not self.afk_channel_id: return None afk_channel = await self.app.rest.fetch_channel(self.afk_channel_id) assert isinstance(afk_channel, channels_.GuildVoiceChannel) return afk_channel async def fetch_system_channel(self) -> typing.Optional[channels_.GuildTextChannel]: """Fetch the system channel. Returns ------- typing.Optional[hikari.channels.GuildTextChannel] The system channel for this guild or `None` if not enabled. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `READ_MESSAGES` 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. """ if not self.system_channel_id: return None system_channel = await self.app.rest.fetch_channel(self.system_channel_id) assert isinstance(system_channel, channels_.GuildTextChannel) return system_channel async def fetch_rules_channel(self) -> typing.Optional[channels_.GuildTextChannel]: """Fetch the channel where guilds display rules and guidelines. If the `GuildFeature.COMMUNITY` feature is not defined, then this is `None`. Returns ------- typing.Optional[hikari.channels.GuildTextChannel] The channel where the rules of the guild are specified or else `None`. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `READ_MESSAGES` 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. """ if not self.rules_channel_id: return None rules_channel = await self.app.rest.fetch_channel(self.rules_channel_id) assert isinstance(rules_channel, channels_.GuildTextChannel) return rules_channel async def fetch_public_updates_channel(self) -> typing.Optional[channels_.GuildTextChannel]: """Fetch channel ID of the channel where admins and moderators receive notices from Discord. This is only present if `GuildFeature.COMMUNITY` is in `Guild.features` for this guild. For all other purposes, it should be considered to be `None`. Returns ------- typing.Optional[hikari.channels.GuildTextChannel] The channel where discord sends relevant updates to moderators and admins. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `READ_MESSAGES` 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. """ if not self.public_updates_channel_id: return None updates_channel = await self.app.rest.fetch_channel(self.public_updates_channel_id) assert isinstance(updates_channel, channels_.GuildTextChannel) return updates_channel @attr.define(hash=True, kw_only=True, weakref_slot=False) class RESTGuild(Guild): """Guild specialization that is sent via the REST API only.""" emojis: typing.Mapping[snowflakes.Snowflake, emojis_.KnownCustomEmoji] = attr.field( eq=False, hash=False, repr=False ) """A mapping of emoji IDs to the objects of the emojis this guild provides.""" roles: typing.Mapping[snowflakes.Snowflake, Role] = attr.field(eq=False, hash=False, repr=False) """The roles in this guild, represented as a mapping of role ID to role object.""" approximate_active_member_count: typing.Optional[int] = attr.field(eq=False, hash=False, repr=False) """The approximate number of members in the guild that are not offline. This will be `None` when creating a guild. """ approximate_member_count: typing.Optional[int] = attr.field(eq=False, hash=False, repr=False) """The approximate number of members in the guild. This will be `None` when creating a guild. """ max_presences: typing.Optional[int] = attr.field(eq=False, hash=False, repr=False) """The maximum number of presences for the guild. If `None`, then there is no limit. """ max_members: int = attr.field(eq=False, hash=False, repr=False) """The maximum number of members allowed in this guild.""" @attr.define(hash=True, kw_only=True, weakref_slot=False) class GatewayGuild(Guild): """Guild specialization that is sent via the gateway only.""" is_large: typing.Optional[bool] = attr.field(eq=False, hash=False, repr=False) """Whether the guild is considered to be large or not. This information is only available if the guild was sent via a `GUILD_CREATE` event. If the guild is received from any other place, this will always be `None`. The implications of a large guild are that presence information will not be sent about members who are offline or invisible. """ joined_at: typing.Optional[datetime.datetime] = attr.field(eq=False, hash=False, repr=False) """The date and time that the bot user joined this guild. This information is only available if the guild was sent via a `GUILD_CREATE` event. If the guild is received from any other place, this will always be `None`. """ member_count: typing.Optional[int] = attr.field(eq=False, hash=False, repr=False) """The number of members in this guild. This information is only available if the guild was sent via a `GUILD_CREATE` event. If the guild is received from any other place, this will always be `None`. """
View Source
@attr.define(hash=True, kw_only=True, weakref_slot=False) class GatewayGuild(Guild): """Guild specialization that is sent via the gateway only.""" is_large: typing.Optional[bool] = attr.field(eq=False, hash=False, repr=False) """Whether the guild is considered to be large or not. This information is only available if the guild was sent via a `GUILD_CREATE` event. If the guild is received from any other place, this will always be `None`. The implications of a large guild are that presence information will not be sent about members who are offline or invisible. """ joined_at: typing.Optional[datetime.datetime] = attr.field(eq=False, hash=False, repr=False) """The date and time that the bot user joined this guild. This information is only available if the guild was sent via a `GUILD_CREATE` event. If the guild is received from any other place, this will always be `None`. """ member_count: typing.Optional[int] = attr.field(eq=False, hash=False, repr=False) """The number of members in this guild. This information is only available if the guild was sent via a `GUILD_CREATE` event. If the guild is received from any other place, this will always be `None`. """
Guild specialization that is sent via the gateway only.
Variables and properties
The ID for the channel that AFK voice users get sent to.
If None
, then no AFK channel is set up for this guild.
Timeout for activity before a member is classed as AFK.
How long a voice user has to be AFK for before they are classed as being AFK and are moved to the AFK channel (Guild.afk_channel_id
).
The client application that models may use for procedures.
The ID of the application that created this guild.
This will always be None
for guilds that weren't created by a bot.
When the object was created.
The default setting for message notifications in this guild.
The guild's description.
This is only present if certain GuildFeature
's are set in Guild.features
for this guild. Otherwise, this will always be None
.
The hash of the discovery splash for the guild, if there is one.
Discovery splash URL for the guild, if set.
The setting for the explicit content filter in this guild.
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.
Whether the guild is considered to be large or not.
This information is only available if the guild was sent via a GUILD_CREATE
event. If the guild is received from any other place, this will always be None
.
The implications of a large guild are that presence information will not be sent about members who are offline or invisible.
Describes whether the guild widget is enabled or not.
If this information is not present, this will be None
.
The date and time that the bot user joined this guild.
This information is only available if the guild was sent via a GUILD_CREATE
event. If the guild is received from any other place, this will always be None
.
The maximum number of users allowed in a video channel together.
This information may not be present, in which case, it will be None
.
The number of members in this guild.
This information is only available if the guild was sent via a GUILD_CREATE
event. If the guild is received from any other place, this will always be None
.
The required MFA level for users wishing to participate in this guild.
The name of the guild.
The NSFW level of the guild.
The ID of the owner of this guild.
The preferred locale to use for this guild.
This can only be change if GuildFeature.COMMUNITY
is in Guild.features
for this guild and will otherwise default to en-US
.
The channel ID of the channel where admins and moderators receive notices from Discord.
This is only present if GuildFeature.COMMUNITY
is in Guild.features
for this guild. For all other purposes, it should be considered to be None
.
The ID of the channel where guilds with the GuildFeature.COMMUNITY
features
display rules and guidelines.
If the GuildFeature.COMMUNITY
feature is not defined, then this is None
.
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.
Return flags for the guild system channel.
These are used to describe which notifications are suppressed.
The ID of the system channel or None
if it is not enabled.
Welcome messages and Nitro boost messages may be sent to this channel.
The vanity URL code for the guild's vanity URL.
This is only present if GuildFeature.VANITY_URL
is in Guild.features
for this guild. If not, this will always be None
.
The verification level needed for a user to participate in this guild.
The channel ID that the widget's generated invite will send the user to.
If this information is unavailable or this is not enabled for the guild then this will be None
.
Methods
self,
*,
app: hikari.traits.RESTAware,
id: hikari.snowflakes.Snowflake,
icon_hash: Optional[str],
name: str,
features: Sequence[Union[str, hikari.guilds.GuildFeature]],
application_id: Optional[hikari.snowflakes.Snowflake],
afk_channel_id: Optional[hikari.snowflakes.Snowflake],
afk_timeout: datetime.timedelta,
banner_hash: Optional[str],
default_message_notifications: Union[hikari.guilds.GuildMessageNotificationsLevel, int],
description: Optional[str],
discovery_splash_hash: Optional[str],
explicit_content_filter: Union[hikari.guilds.GuildExplicitContentFilterLevel, int],
is_widget_enabled: Optional[bool],
max_video_channel_users: Optional[int],
mfa_level: Union[hikari.guilds.GuildMFALevel, int],
owner_id: hikari.snowflakes.Snowflake,
preferred_locale: Union[str, hikari.locales.Locale],
premium_subscription_count: Optional[int],
premium_tier: Union[hikari.guilds.GuildPremiumTier, int],
public_updates_channel_id: Optional[hikari.snowflakes.Snowflake],
rules_channel_id: Optional[hikari.snowflakes.Snowflake],
splash_hash: Optional[str],
system_channel_flags: hikari.guilds.GuildSystemChannelFlag,
system_channel_id: Optional[hikari.snowflakes.Snowflake],
vanity_url_code: Optional[str],
verification_level: Union[hikari.guilds.GuildVerificationLevel, int],
widget_channel_id: Optional[hikari.snowflakes.Snowflake],
nsfw_level: hikari.guilds.GuildNSFWLevel,
is_large: Optional[bool],
joined_at: Optional[datetime.datetime],
member_count: Optional[int]
):
View Source
def __init__(self, *, app, id, icon_hash, name, features, application_id, afk_channel_id, afk_timeout, banner_hash, default_message_notifications, description, discovery_splash_hash, explicit_content_filter, is_widget_enabled, max_video_channel_users, mfa_level, owner_id, preferred_locale, premium_subscription_count, premium_tier, public_updates_channel_id, rules_channel_id, splash_hash, system_channel_flags, system_channel_id, vanity_url_code, verification_level, widget_channel_id, nsfw_level, is_large, joined_at, member_count): self.app = app self.id = id self.icon_hash = icon_hash self.name = name self.features = features self.application_id = application_id self.afk_channel_id = afk_channel_id self.afk_timeout = afk_timeout self.banner_hash = banner_hash self.default_message_notifications = default_message_notifications self.description = description self.discovery_splash_hash = discovery_splash_hash self.explicit_content_filter = explicit_content_filter self.is_widget_enabled = is_widget_enabled self.max_video_channel_users = max_video_channel_users self.mfa_level = mfa_level self.owner_id = owner_id self.preferred_locale = preferred_locale self.premium_subscription_count = premium_subscription_count self.premium_tier = premium_tier self.public_updates_channel_id = public_updates_channel_id self.rules_channel_id = rules_channel_id self.splash_hash = splash_hash self.system_channel_flags = system_channel_flags self.system_channel_id = system_channel_id self.vanity_url_code = vanity_url_code self.verification_level = verification_level self.widget_channel_id = widget_channel_id self.nsfw_level = nsfw_level self.is_large = is_large self.joined_at = joined_at self.member_count = member_count
Method generated by attrs for class GatewayGuild.
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.
View Source
async def fetch_afk_channel(self) -> typing.Optional[channels_.GuildVoiceChannel]: """Fetch the channel that AFK voice users get sent to. Returns ------- typing.Optional[hikari.channels.GuildVoiceChannel] The AFK channel or `None` if not enabled. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `READ_MESSAGES` 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. """ if not self.afk_channel_id: return None afk_channel = await self.app.rest.fetch_channel(self.afk_channel_id) assert isinstance(afk_channel, channels_.GuildVoiceChannel) return afk_channel
Fetch the channel that AFK voice users get sent to.
Returns
- typing.Optional[hikari.channels.GuildVoiceChannel]: The AFK channel or
None
if not enabled.
Raises
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.ForbiddenError: If you are missing the
READ_MESSAGES
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,
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_owner(self) -> Member: """Fetch the owner of the guild. Returns ------- hikari.guilds.Member The guild owner. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild or the 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. """ return await self.app.rest.fetch_member(self.id, self.owner_id)
Fetch the owner of the guild.
Returns
- hikari.guilds.Member: The guild owner.
Raises
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the guild or the 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
async def fetch_public_updates_channel(self) -> typing.Optional[channels_.GuildTextChannel]: """Fetch channel ID of the channel where admins and moderators receive notices from Discord. This is only present if `GuildFeature.COMMUNITY` is in `Guild.features` for this guild. For all other purposes, it should be considered to be `None`. Returns ------- typing.Optional[hikari.channels.GuildTextChannel] The channel where discord sends relevant updates to moderators and admins. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `READ_MESSAGES` 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. """ if not self.public_updates_channel_id: return None updates_channel = await self.app.rest.fetch_channel(self.public_updates_channel_id) assert isinstance(updates_channel, channels_.GuildTextChannel) return updates_channel
Fetch channel ID of the channel where admins and moderators receive notices from Discord.
This is only present if GuildFeature.COMMUNITY
is in Guild.features
for this guild. For all other purposes, it should be considered to be None
.
Returns
- typing.Optional[hikari.channels.GuildTextChannel]: The channel where discord sends relevant updates to moderators and admins.
Raises
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.ForbiddenError: If you are missing the
READ_MESSAGES
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.
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_rules_channel(self) -> typing.Optional[channels_.GuildTextChannel]: """Fetch the channel where guilds display rules and guidelines. If the `GuildFeature.COMMUNITY` feature is not defined, then this is `None`. Returns ------- typing.Optional[hikari.channels.GuildTextChannel] The channel where the rules of the guild are specified or else `None`. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `READ_MESSAGES` 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. """ if not self.rules_channel_id: return None rules_channel = await self.app.rest.fetch_channel(self.rules_channel_id) assert isinstance(rules_channel, channels_.GuildTextChannel) return rules_channel
Fetch the channel where guilds display rules and guidelines.
If the GuildFeature.COMMUNITY
feature is not defined, then this is None
.
Returns
- typing.Optional[hikari.channels.GuildTextChannel]: The channel where the rules of the guild are specified or else
None
.
Raises
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.ForbiddenError: If you are missing the
READ_MESSAGES
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.
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.
View Source
async def fetch_system_channel(self) -> typing.Optional[channels_.GuildTextChannel]: """Fetch the system channel. Returns ------- typing.Optional[hikari.channels.GuildTextChannel] The system channel for this guild or `None` if not enabled. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `READ_MESSAGES` 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. """ if not self.system_channel_id: return None system_channel = await self.app.rest.fetch_channel(self.system_channel_id) assert isinstance(system_channel, channels_.GuildTextChannel) return system_channel
Fetch the system channel.
Returns
- typing.Optional[hikari.channels.GuildTextChannel]: The system channel for this guild or
None
if not enabled.
Raises
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.ForbiddenError: If you are missing the
READ_MESSAGES
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.
View Source
async def fetch_widget_channel(self) -> typing.Optional[channels_.GuildChannel]: """Fetch the widget channel. This will be `None` if not set. Returns ------- typing.Optional[hikari.channels.GuildChannel] The channel the widget is linked to or else `None`. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `READ_MESSAGES` 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. """ if not self.widget_channel_id: return None widget_channel = await self.app.rest.fetch_channel(self.widget_channel_id) assert isinstance(widget_channel, channels_.GuildChannel) return widget_channel
Fetch the widget channel.
This will be None
if not set.
Returns
- typing.Optional[hikari.channels.GuildChannel]: The channel the widget is linked to or else
None
.
Raises
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.ForbiddenError: If you are missing the
READ_MESSAGES
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,
channel: Union[hikari.channels.PartialChannel, hikari.snowflakes.Snowflake, int]
) -> Optional[hikari.channels.GuildChannel]:
View Source
def get_channel( self, channel: snowflakes.SnowflakeishOr[channels_.PartialChannel], ) -> typing.Optional[channels_.GuildChannel]: """Get a cached channel that belongs to the guild by it's ID or object. Parameters ---------- channel : hikari.snowflakes.SnowflakeishOr[hikari.channels.PartialChannel] The object or ID of the guild channel to get from the cache. Returns ------- typing.Optional[hikari.channels.GuildChannel] The object of the guild channel found in cache or `None. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_guild_channel(channel)
Get a cached channel that belongs to the guild by it's ID or object.
Parameters
- channel (hikari.snowflakes.SnowflakeishOr[hikari.channels.PartialChannel]): The object or ID of the guild channel to get from the cache.
Returns
- typing.Optional[hikari.channels.GuildChannel]: The object of the guild channel found in cache or `None.
View Source
def get_channels(self) -> typing.Mapping[snowflakes.Snowflake, channels_.GuildChannel]: """Get the channels cached for the guild. Returns ------- typing.Mapping[hikari.snowflakes.Snowflake, hikari.channels.GuildChannel] A mapping of channel IDs to objects of the channels cached for the guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_guild_channels_view_for_guild(self.id)
Get the channels cached for the guild.
Returns
- typing.Mapping[hikari.snowflakes.Snowflake, hikari.channels.GuildChannel]: A mapping of channel IDs to objects of the channels cached for the guild.
self,
emoji: Union[hikari.emojis.CustomEmoji, hikari.snowflakes.Snowflake, int]
) -> Optional[hikari.emojis.KnownCustomEmoji]:
View Source
def get_emoji( self, emoji: snowflakes.SnowflakeishOr[emojis_.CustomEmoji] ) -> typing.Optional[emojis_.KnownCustomEmoji]: """Get a cached emoji that belongs to the guild by it's ID or object. Parameters ---------- emoji : hikari.snowflakes.SnowflakeishOr[hikari.emojis.CustomEmoji] The object or ID of the emoji to get from the cache. Returns ------- typing.Optional[hikari.emojis.KnownCustomEmoji] The object of the custom emoji if found in cache, else `None`. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_emoji(emoji)
Get a cached emoji that belongs to the guild by it's ID or object.
Parameters
- emoji (hikari.snowflakes.SnowflakeishOr[hikari.emojis.CustomEmoji]): The object or ID of the emoji to get from the cache.
Returns
- typing.Optional[hikari.emojis.KnownCustomEmoji]: The object of the custom emoji if found in cache, else
None
.
View Source
def get_emojis(self) -> typing.Mapping[snowflakes.Snowflake, emojis_.KnownCustomEmoji]: """Return the emojis in this guild. Returns ------- typing.Mapping[hikari.snowflakes.Snowflake, hikari.emojis.KnownCustomEmoji] A mapping of emoji IDs to the objects of emojis in this guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_emojis_view_for_guild(self.id)
Return the emojis in this guild.
Returns
- typing.Mapping[hikari.snowflakes.Snowflake, hikari.emojis.KnownCustomEmoji]: A mapping of emoji IDs to the objects of emojis in this guild.
self,
user: Union[hikari.users.PartialUser, hikari.snowflakes.Snowflake, int]
) -> Optional[hikari.guilds.Member]:
View Source
def get_member(self, user: snowflakes.SnowflakeishOr[users.PartialUser]) -> typing.Optional[Member]: """Get a cached member that belongs to the guild by it's user ID or object. Parameters ---------- user : hikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser] The object or ID of the user to get the cached member for. Returns ------- typing.Optional[Member] The cached member object if found, else `None`. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_member(self.id, user)
Get a cached member that belongs to the guild by it's user ID or object.
Parameters
- user (hikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser]): The object or ID of the user to get the cached member for.
Returns
- typing.Optional[Member]: The cached member object if found, else
None
.
View Source
def get_members(self) -> typing.Mapping[snowflakes.Snowflake, Member]: """Get the members cached for the guild. typing.Mapping[hikari.snowflakes.Snowflake, Member] A mapping of user IDs to objects of the members cached for the guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_members_view_for_guild(self.id)
Get the members cached for the guild.
typing.Mapping[hikari.snowflakes.Snowflake, Member] A mapping of user IDs to objects of the members cached for the guild.
View Source
def get_my_member(self) -> typing.Optional[Member]: """Return the cached member for the bot user in this guild, if known. Returns ------- typing.Optional[Member] The cached member for this guild, or `None` if not known. """ if not isinstance(self.app, traits.ShardAware): return None me = self.app.get_me() if me is None: return None return self.get_member(me.id)
Return the cached member for the bot user in this guild, if known.
Returns
- typing.Optional[Member]: The cached member for this guild, or
None
if not known.
self,
user: Union[hikari.users.PartialUser, hikari.snowflakes.Snowflake, int]
) -> Optional[hikari.presences.MemberPresence]:
View Source
def get_presence( self, user: snowflakes.SnowflakeishOr[users.PartialUser] ) -> typing.Optional[presences_.MemberPresence]: """Get a cached presence that belongs to the guild by it's user ID or object. Parameters ---------- user : hikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser] The object or ID of the user to get the cached presence for. Returns ------- typing.Optional[hikari.presences.MemberPresence] The cached presence object if found, else `None`. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_presence(self.id, user)
Get a cached presence that belongs to the guild by it's user ID or object.
Parameters
- user (hikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser]): The object or ID of the user to get the cached presence for.
Returns
- typing.Optional[hikari.presences.MemberPresence]: The cached presence object if found, else
None
.
self
) -> Mapping[hikari.snowflakes.Snowflake, hikari.presences.MemberPresence]:
View Source
def get_presences(self) -> typing.Mapping[snowflakes.Snowflake, presences_.MemberPresence]: """Get the presences cached for the guild. typing.Mapping[hikari.snowflakes.Snowflake, hikari.presences.MemberPresence] A mapping of user IDs to objects of the presences cached for the guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_presences_view_for_guild(self.id)
Get the presences cached for the guild.
typing.Mapping[hikari.snowflakes.Snowflake, hikari.presences.MemberPresence] A mapping of user IDs to objects of the presences cached for the guild.
self,
role: Union[hikari.guilds.PartialRole, hikari.snowflakes.Snowflake, int]
) -> Optional[hikari.guilds.Role]:
View Source
def get_role(self, role: snowflakes.SnowflakeishOr[PartialRole]) -> typing.Optional[Role]: """Get a cached role that belongs to the guild by it's ID or object. Parameters ---------- role : hikari.snowflakes.SnowflakeishOr[PartialRole] The object or ID of the role to get for this guild from the cache. Returns ------- typing.Optional[Role] The object of the role found in cache, else `None`. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_role(role)
Get a cached role that belongs to the guild by it's ID or object.
Parameters
- role (hikari.snowflakes.SnowflakeishOr[PartialRole]): The object or ID of the role to get for this guild from the cache.
Returns
- typing.Optional[Role]: The object of the role found in cache, else
None
.
View Source
def get_roles(self) -> typing.Mapping[snowflakes.Snowflake, Role]: """Return the roles in this guild. Returns ------- typing.Mapping[hikari.snowflakes.Snowflake, Role] A mapping of role IDs to the objects of roles in this guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_roles_view_for_guild(self.id)
Return the roles in this guild.
Returns
- typing.Mapping[hikari.snowflakes.Snowflake, Role]: A mapping of role IDs to the objects of roles in this guild.
self,
user: Union[hikari.users.PartialUser, hikari.snowflakes.Snowflake, int]
) -> Optional[hikari.voices.VoiceState]:
View Source
def get_voice_state( self, user: snowflakes.SnowflakeishOr[users.PartialUser] ) -> typing.Optional[voices_.VoiceState]: """Get a cached voice state that belongs to the guild by it's user. Parameters ---------- user : hikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser] The object or ID of the user to get the cached voice state for. Returns ------- typing.Optional[hikari.voices.VoiceState] The cached voice state object if found, else `None`. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_voice_state(self.id, user)
Get a cached voice state that belongs to the guild by it's user.
Parameters
- user (hikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser]): The object or ID of the user to get the cached voice state for.
Returns
- typing.Optional[hikari.voices.VoiceState]: The cached voice state object if found, else
None
.
View Source
def get_voice_states(self) -> typing.Mapping[snowflakes.Snowflake, voices_.VoiceState]: """Get the voice states cached for the guild. Returns ------- typing.Mapping[hikari.snowflakes.Snowflake, hikari.voices.VoiceState] A mapping of user IDs to objects of the voice states cached for the guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_voice_states_view_for_guild(self.id)
Get the voice states cached for the guild.
Returns
- typing.Mapping[hikari.snowflakes.Snowflake, hikari.voices.VoiceState]: A mapping of user IDs to objects of the voice states cached for the guild.
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: str = 'png',
size: int = 4096
) -> Optional[hikari.files.URL]:
View Source
def make_discovery_splash_url(self, *, ext: str = "png", size: int = 4096) -> typing.Optional[files.URL]: """Generate the guild's discovery 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 string URL. Raises ------ ValueError If `size` is not a power of two or not between 16 and 4096. """ if self.discovery_splash_hash is None: return None return routes.CDN_GUILD_DISCOVERY_SPLASH.compile_to_file( urls.CDN_URL, guild_id=self.id, hash=self.discovery_splash_hash, size=size, file_format=ext, )
Generate the guild's discovery 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 string URL.
Raises
- ValueError: If
size
is not a power of two or not between 16 and 4096.
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 Guild(PartialGuild): """A representation of a guild on Discord.""" features: typing.Sequence[typing.Union[str, GuildFeature]] = attr.field(eq=False, hash=False, repr=False) """A list of the features in this guild.""" application_id: typing.Optional[snowflakes.Snowflake] = attr.field(eq=False, hash=False, repr=False) """The ID of the application that created this guild. This will always be `None` for guilds that weren't created by a bot. """ afk_channel_id: typing.Optional[snowflakes.Snowflake] = attr.field(eq=False, hash=False, repr=False) """The ID for the channel that AFK voice users get sent to. If `None`, then no AFK channel is set up for this guild. """ afk_timeout: datetime.timedelta = attr.field(eq=False, hash=False, repr=False) """Timeout for activity before a member is classed as AFK. How long a voice user has to be AFK for before they are classed as being AFK and are moved to the AFK channel (`Guild.afk_channel_id`). """ 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 the guild has `GuildFeature.BANNER` in `Guild.features` for this guild. For all other purposes, it is `None`. """ default_message_notifications: typing.Union[GuildMessageNotificationsLevel, int] = attr.field( eq=False, hash=False, repr=False ) """The default setting for message notifications in this guild.""" description: typing.Optional[str] = attr.field(eq=False, hash=False, repr=False) """The guild's description. This is only present if certain `GuildFeature`'s are set in `Guild.features` for this guild. Otherwise, this will always be `None`. """ discovery_splash_hash: typing.Optional[str] = attr.field(eq=False, hash=False, repr=False) """The hash of the discovery splash for the guild, if there is one.""" explicit_content_filter: typing.Union[GuildExplicitContentFilterLevel, int] = attr.field( eq=False, hash=False, repr=False ) """The setting for the explicit content filter in this guild.""" is_widget_enabled: typing.Optional[bool] = attr.field(eq=False, hash=False, repr=False) """Describes whether the guild widget is enabled or not. If this information is not present, this will be `None`. """ max_video_channel_users: typing.Optional[int] = attr.field(eq=False, hash=False, repr=False) """The maximum number of users allowed in a video channel together. This information may not be present, in which case, it will be `None`. """ mfa_level: typing.Union[GuildMFALevel, int] = attr.field(eq=False, hash=False, repr=False) """The required MFA level for users wishing to participate in this guild.""" owner_id: snowflakes.Snowflake = attr.field(eq=False, hash=False, repr=True) """The ID of the owner of this guild.""" preferred_locale: typing.Union[str, locales.Locale] = attr.field(eq=False, hash=False, repr=False) """The preferred locale to use for this guild. This can only be change if `GuildFeature.COMMUNITY` is in `Guild.features` for this guild and will otherwise default to `en-US`. """ premium_subscription_count: typing.Optional[int] = attr.field(eq=False, hash=False, repr=False) """The number of nitro boosts that the server currently has. This information may not be present, in which case, it will be `None`. """ premium_tier: typing.Union[GuildPremiumTier, int] = attr.field(eq=False, hash=False, repr=False) """The premium tier for this guild.""" public_updates_channel_id: typing.Optional[snowflakes.Snowflake] = attr.field(eq=False, hash=False, repr=False) """The channel ID of the channel where admins and moderators receive notices from Discord. This is only present if `GuildFeature.COMMUNITY` is in `Guild.features` for this guild. For all other purposes, it should be considered to be `None`. """ rules_channel_id: typing.Optional[snowflakes.Snowflake] = attr.field(eq=False, hash=False, repr=False) """The ID of the channel where guilds with the `GuildFeature.COMMUNITY` `features` display rules and guidelines. If the `GuildFeature.COMMUNITY` feature is not defined, then this is `None`. """ 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.""" system_channel_flags: GuildSystemChannelFlag = attr.field(eq=False, hash=False, repr=False) """Return flags for the guild system channel. These are used to describe which notifications are suppressed. """ system_channel_id: typing.Optional[snowflakes.Snowflake] = attr.field(eq=False, hash=False, repr=False) """The ID of the system channel or `None` if it is not enabled. Welcome messages and Nitro boost messages may be sent to this channel. """ vanity_url_code: typing.Optional[str] = attr.field(eq=False, hash=False, repr=False) """The vanity URL code for the guild's vanity URL. This is only present if `GuildFeature.VANITY_URL` is in `Guild.features` for this guild. If not, this will always be `None`. """ verification_level: typing.Union[GuildVerificationLevel, int] = attr.field(eq=False, hash=False, repr=False) """The verification level needed for a user to participate in this guild.""" widget_channel_id: typing.Optional[snowflakes.Snowflake] = attr.field(eq=False, hash=False, repr=False) """The channel ID that the widget's generated invite will send the user to. If this information is unavailable or this is not enabled for the guild then this will be `None`. """ nsfw_level: GuildNSFWLevel = attr.field(eq=False, hash=False, repr=False) """The NSFW level of the guild.""" @property def banner_url(self) -> typing.Optional[files.URL]: """Banner URL for the guild, if set.""" return self.make_banner_url() @property def discovery_splash_url(self) -> typing.Optional[files.URL]: """Discovery splash URL for the guild, if set.""" return self.make_discovery_splash_url() @property def splash_url(self) -> typing.Optional[files.URL]: """Splash URL for the guild, if set.""" return self.make_splash_url() def get_members(self) -> typing.Mapping[snowflakes.Snowflake, Member]: """Get the members cached for the guild. typing.Mapping[hikari.snowflakes.Snowflake, Member] A mapping of user IDs to objects of the members cached for the guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_members_view_for_guild(self.id) def get_presences(self) -> typing.Mapping[snowflakes.Snowflake, presences_.MemberPresence]: """Get the presences cached for the guild. typing.Mapping[hikari.snowflakes.Snowflake, hikari.presences.MemberPresence] A mapping of user IDs to objects of the presences cached for the guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_presences_view_for_guild(self.id) def get_channels(self) -> typing.Mapping[snowflakes.Snowflake, channels_.GuildChannel]: """Get the channels cached for the guild. Returns ------- typing.Mapping[hikari.snowflakes.Snowflake, hikari.channels.GuildChannel] A mapping of channel IDs to objects of the channels cached for the guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_guild_channels_view_for_guild(self.id) def get_voice_states(self) -> typing.Mapping[snowflakes.Snowflake, voices_.VoiceState]: """Get the voice states cached for the guild. Returns ------- typing.Mapping[hikari.snowflakes.Snowflake, hikari.voices.VoiceState] A mapping of user IDs to objects of the voice states cached for the guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_voice_states_view_for_guild(self.id) def get_emojis(self) -> typing.Mapping[snowflakes.Snowflake, emojis_.KnownCustomEmoji]: """Return the emojis in this guild. Returns ------- typing.Mapping[hikari.snowflakes.Snowflake, hikari.emojis.KnownCustomEmoji] A mapping of emoji IDs to the objects of emojis in this guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_emojis_view_for_guild(self.id) def get_roles(self) -> typing.Mapping[snowflakes.Snowflake, Role]: """Return the roles in this guild. Returns ------- typing.Mapping[hikari.snowflakes.Snowflake, Role] A mapping of role IDs to the objects of roles in this guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_roles_view_for_guild(self.id) 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, ) def make_discovery_splash_url(self, *, ext: str = "png", size: int = 4096) -> typing.Optional[files.URL]: """Generate the guild's discovery 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 string URL. Raises ------ ValueError If `size` is not a power of two or not between 16 and 4096. """ if self.discovery_splash_hash is None: return None return routes.CDN_GUILD_DISCOVERY_SPLASH.compile_to_file( urls.CDN_URL, guild_id=self.id, hash=self.discovery_splash_hash, size=size, file_format=ext, ) 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, ) def get_channel( self, channel: snowflakes.SnowflakeishOr[channels_.PartialChannel], ) -> typing.Optional[channels_.GuildChannel]: """Get a cached channel that belongs to the guild by it's ID or object. Parameters ---------- channel : hikari.snowflakes.SnowflakeishOr[hikari.channels.PartialChannel] The object or ID of the guild channel to get from the cache. Returns ------- typing.Optional[hikari.channels.GuildChannel] The object of the guild channel found in cache or `None. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_guild_channel(channel) def get_member(self, user: snowflakes.SnowflakeishOr[users.PartialUser]) -> typing.Optional[Member]: """Get a cached member that belongs to the guild by it's user ID or object. Parameters ---------- user : hikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser] The object or ID of the user to get the cached member for. Returns ------- typing.Optional[Member] The cached member object if found, else `None`. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_member(self.id, user) def get_my_member(self) -> typing.Optional[Member]: """Return the cached member for the bot user in this guild, if known. Returns ------- typing.Optional[Member] The cached member for this guild, or `None` if not known. """ if not isinstance(self.app, traits.ShardAware): return None me = self.app.get_me() if me is None: return None return self.get_member(me.id) def get_presence( self, user: snowflakes.SnowflakeishOr[users.PartialUser] ) -> typing.Optional[presences_.MemberPresence]: """Get a cached presence that belongs to the guild by it's user ID or object. Parameters ---------- user : hikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser] The object or ID of the user to get the cached presence for. Returns ------- typing.Optional[hikari.presences.MemberPresence] The cached presence object if found, else `None`. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_presence(self.id, user) def get_voice_state( self, user: snowflakes.SnowflakeishOr[users.PartialUser] ) -> typing.Optional[voices_.VoiceState]: """Get a cached voice state that belongs to the guild by it's user. Parameters ---------- user : hikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser] The object or ID of the user to get the cached voice state for. Returns ------- typing.Optional[hikari.voices.VoiceState] The cached voice state object if found, else `None`. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_voice_state(self.id, user) def get_emoji( self, emoji: snowflakes.SnowflakeishOr[emojis_.CustomEmoji] ) -> typing.Optional[emojis_.KnownCustomEmoji]: """Get a cached emoji that belongs to the guild by it's ID or object. Parameters ---------- emoji : hikari.snowflakes.SnowflakeishOr[hikari.emojis.CustomEmoji] The object or ID of the emoji to get from the cache. Returns ------- typing.Optional[hikari.emojis.KnownCustomEmoji] The object of the custom emoji if found in cache, else `None`. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_emoji(emoji) def get_role(self, role: snowflakes.SnowflakeishOr[PartialRole]) -> typing.Optional[Role]: """Get a cached role that belongs to the guild by it's ID or object. Parameters ---------- role : hikari.snowflakes.SnowflakeishOr[PartialRole] The object or ID of the role to get for this guild from the cache. Returns ------- typing.Optional[Role] The object of the role found in cache, else `None`. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_role(role) async def fetch_owner(self) -> Member: """Fetch the owner of the guild. Returns ------- hikari.guilds.Member The guild owner. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild or the 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. """ return await self.app.rest.fetch_member(self.id, self.owner_id) async def fetch_widget_channel(self) -> typing.Optional[channels_.GuildChannel]: """Fetch the widget channel. This will be `None` if not set. Returns ------- typing.Optional[hikari.channels.GuildChannel] The channel the widget is linked to or else `None`. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `READ_MESSAGES` 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. """ if not self.widget_channel_id: return None widget_channel = await self.app.rest.fetch_channel(self.widget_channel_id) assert isinstance(widget_channel, channels_.GuildChannel) return widget_channel async def fetch_afk_channel(self) -> typing.Optional[channels_.GuildVoiceChannel]: """Fetch the channel that AFK voice users get sent to. Returns ------- typing.Optional[hikari.channels.GuildVoiceChannel] The AFK channel or `None` if not enabled. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `READ_MESSAGES` 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. """ if not self.afk_channel_id: return None afk_channel = await self.app.rest.fetch_channel(self.afk_channel_id) assert isinstance(afk_channel, channels_.GuildVoiceChannel) return afk_channel async def fetch_system_channel(self) -> typing.Optional[channels_.GuildTextChannel]: """Fetch the system channel. Returns ------- typing.Optional[hikari.channels.GuildTextChannel] The system channel for this guild or `None` if not enabled. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `READ_MESSAGES` 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. """ if not self.system_channel_id: return None system_channel = await self.app.rest.fetch_channel(self.system_channel_id) assert isinstance(system_channel, channels_.GuildTextChannel) return system_channel async def fetch_rules_channel(self) -> typing.Optional[channels_.GuildTextChannel]: """Fetch the channel where guilds display rules and guidelines. If the `GuildFeature.COMMUNITY` feature is not defined, then this is `None`. Returns ------- typing.Optional[hikari.channels.GuildTextChannel] The channel where the rules of the guild are specified or else `None`. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `READ_MESSAGES` 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. """ if not self.rules_channel_id: return None rules_channel = await self.app.rest.fetch_channel(self.rules_channel_id) assert isinstance(rules_channel, channels_.GuildTextChannel) return rules_channel async def fetch_public_updates_channel(self) -> typing.Optional[channels_.GuildTextChannel]: """Fetch channel ID of the channel where admins and moderators receive notices from Discord. This is only present if `GuildFeature.COMMUNITY` is in `Guild.features` for this guild. For all other purposes, it should be considered to be `None`. Returns ------- typing.Optional[hikari.channels.GuildTextChannel] The channel where discord sends relevant updates to moderators and admins. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `READ_MESSAGES` 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. """ if not self.public_updates_channel_id: return None updates_channel = await self.app.rest.fetch_channel(self.public_updates_channel_id) assert isinstance(updates_channel, channels_.GuildTextChannel) return updates_channel
A representation of a guild on Discord.
Variables and properties
The ID for the channel that AFK voice users get sent to.
If None
, then no AFK channel is set up for this guild.
Timeout for activity before a member is classed as AFK.
How long a voice user has to be AFK for before they are classed as being AFK and are moved to the AFK channel (Guild.afk_channel_id
).
The client application that models may use for procedures.
The ID of the application that created this guild.
This will always be None
for guilds that weren't created by a bot.
When the object was created.
The default setting for message notifications in this guild.
The guild's description.
This is only present if certain GuildFeature
's are set in Guild.features
for this guild. Otherwise, this will always be None
.
The hash of the discovery splash for the guild, if there is one.
Discovery splash URL for the guild, if set.
The setting for the explicit content filter in this guild.
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.
Describes whether the guild widget is enabled or not.
If this information is not present, this will be None
.
The maximum number of users allowed in a video channel together.
This information may not be present, in which case, it will be None
.
The required MFA level for users wishing to participate in this guild.
The name of the guild.
The NSFW level of the guild.
The ID of the owner of this guild.
The preferred locale to use for this guild.
This can only be change if GuildFeature.COMMUNITY
is in Guild.features
for this guild and will otherwise default to en-US
.
The channel ID of the channel where admins and moderators receive notices from Discord.
This is only present if GuildFeature.COMMUNITY
is in Guild.features
for this guild. For all other purposes, it should be considered to be None
.
The ID of the channel where guilds with the GuildFeature.COMMUNITY
features
display rules and guidelines.
If the GuildFeature.COMMUNITY
feature is not defined, then this is None
.
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.
Return flags for the guild system channel.
These are used to describe which notifications are suppressed.
The ID of the system channel or None
if it is not enabled.
Welcome messages and Nitro boost messages may be sent to this channel.
The vanity URL code for the guild's vanity URL.
This is only present if GuildFeature.VANITY_URL
is in Guild.features
for this guild. If not, this will always be None
.
The verification level needed for a user to participate in this guild.
The channel ID that the widget's generated invite will send the user to.
If this information is unavailable or this is not enabled for the guild then this will be None
.
Methods
self,
*,
app: hikari.traits.RESTAware,
id: hikari.snowflakes.Snowflake,
icon_hash: Optional[str],
name: str,
features: Sequence[Union[str, hikari.guilds.GuildFeature]],
application_id: Optional[hikari.snowflakes.Snowflake],
afk_channel_id: Optional[hikari.snowflakes.Snowflake],
afk_timeout: datetime.timedelta,
banner_hash: Optional[str],
default_message_notifications: Union[hikari.guilds.GuildMessageNotificationsLevel, int],
description: Optional[str],
discovery_splash_hash: Optional[str],
explicit_content_filter: Union[hikari.guilds.GuildExplicitContentFilterLevel, int],
is_widget_enabled: Optional[bool],
max_video_channel_users: Optional[int],
mfa_level: Union[hikari.guilds.GuildMFALevel, int],
owner_id: hikari.snowflakes.Snowflake,
preferred_locale: Union[str, hikari.locales.Locale],
premium_subscription_count: Optional[int],
premium_tier: Union[hikari.guilds.GuildPremiumTier, int],
public_updates_channel_id: Optional[hikari.snowflakes.Snowflake],
rules_channel_id: Optional[hikari.snowflakes.Snowflake],
splash_hash: Optional[str],
system_channel_flags: hikari.guilds.GuildSystemChannelFlag,
system_channel_id: Optional[hikari.snowflakes.Snowflake],
vanity_url_code: Optional[str],
verification_level: Union[hikari.guilds.GuildVerificationLevel, int],
widget_channel_id: Optional[hikari.snowflakes.Snowflake],
nsfw_level: hikari.guilds.GuildNSFWLevel
):
View Source
def __init__(self, *, app, id, icon_hash, name, features, application_id, afk_channel_id, afk_timeout, banner_hash, default_message_notifications, description, discovery_splash_hash, explicit_content_filter, is_widget_enabled, max_video_channel_users, mfa_level, owner_id, preferred_locale, premium_subscription_count, premium_tier, public_updates_channel_id, rules_channel_id, splash_hash, system_channel_flags, system_channel_id, vanity_url_code, verification_level, widget_channel_id, nsfw_level): self.app = app self.id = id self.icon_hash = icon_hash self.name = name self.features = features self.application_id = application_id self.afk_channel_id = afk_channel_id self.afk_timeout = afk_timeout self.banner_hash = banner_hash self.default_message_notifications = default_message_notifications self.description = description self.discovery_splash_hash = discovery_splash_hash self.explicit_content_filter = explicit_content_filter self.is_widget_enabled = is_widget_enabled self.max_video_channel_users = max_video_channel_users self.mfa_level = mfa_level self.owner_id = owner_id self.preferred_locale = preferred_locale self.premium_subscription_count = premium_subscription_count self.premium_tier = premium_tier self.public_updates_channel_id = public_updates_channel_id self.rules_channel_id = rules_channel_id self.splash_hash = splash_hash self.system_channel_flags = system_channel_flags self.system_channel_id = system_channel_id self.vanity_url_code = vanity_url_code self.verification_level = verification_level self.widget_channel_id = widget_channel_id self.nsfw_level = nsfw_level
Method generated by attrs for class Guild.
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.
View Source
async def fetch_afk_channel(self) -> typing.Optional[channels_.GuildVoiceChannel]: """Fetch the channel that AFK voice users get sent to. Returns ------- typing.Optional[hikari.channels.GuildVoiceChannel] The AFK channel or `None` if not enabled. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `READ_MESSAGES` 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. """ if not self.afk_channel_id: return None afk_channel = await self.app.rest.fetch_channel(self.afk_channel_id) assert isinstance(afk_channel, channels_.GuildVoiceChannel) return afk_channel
Fetch the channel that AFK voice users get sent to.
Returns
- typing.Optional[hikari.channels.GuildVoiceChannel]: The AFK channel or
None
if not enabled.
Raises
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.ForbiddenError: If you are missing the
READ_MESSAGES
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,
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_owner(self) -> Member: """Fetch the owner of the guild. Returns ------- hikari.guilds.Member The guild owner. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild or the 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. """ return await self.app.rest.fetch_member(self.id, self.owner_id)
Fetch the owner of the guild.
Returns
- hikari.guilds.Member: The guild owner.
Raises
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the guild or the 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
async def fetch_public_updates_channel(self) -> typing.Optional[channels_.GuildTextChannel]: """Fetch channel ID of the channel where admins and moderators receive notices from Discord. This is only present if `GuildFeature.COMMUNITY` is in `Guild.features` for this guild. For all other purposes, it should be considered to be `None`. Returns ------- typing.Optional[hikari.channels.GuildTextChannel] The channel where discord sends relevant updates to moderators and admins. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `READ_MESSAGES` 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. """ if not self.public_updates_channel_id: return None updates_channel = await self.app.rest.fetch_channel(self.public_updates_channel_id) assert isinstance(updates_channel, channels_.GuildTextChannel) return updates_channel
Fetch channel ID of the channel where admins and moderators receive notices from Discord.
This is only present if GuildFeature.COMMUNITY
is in Guild.features
for this guild. For all other purposes, it should be considered to be None
.
Returns
- typing.Optional[hikari.channels.GuildTextChannel]: The channel where discord sends relevant updates to moderators and admins.
Raises
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.ForbiddenError: If you are missing the
READ_MESSAGES
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.
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_rules_channel(self) -> typing.Optional[channels_.GuildTextChannel]: """Fetch the channel where guilds display rules and guidelines. If the `GuildFeature.COMMUNITY` feature is not defined, then this is `None`. Returns ------- typing.Optional[hikari.channels.GuildTextChannel] The channel where the rules of the guild are specified or else `None`. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `READ_MESSAGES` 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. """ if not self.rules_channel_id: return None rules_channel = await self.app.rest.fetch_channel(self.rules_channel_id) assert isinstance(rules_channel, channels_.GuildTextChannel) return rules_channel
Fetch the channel where guilds display rules and guidelines.
If the GuildFeature.COMMUNITY
feature is not defined, then this is None
.
Returns
- typing.Optional[hikari.channels.GuildTextChannel]: The channel where the rules of the guild are specified or else
None
.
Raises
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.ForbiddenError: If you are missing the
READ_MESSAGES
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.
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.
View Source
async def fetch_system_channel(self) -> typing.Optional[channels_.GuildTextChannel]: """Fetch the system channel. Returns ------- typing.Optional[hikari.channels.GuildTextChannel] The system channel for this guild or `None` if not enabled. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `READ_MESSAGES` 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. """ if not self.system_channel_id: return None system_channel = await self.app.rest.fetch_channel(self.system_channel_id) assert isinstance(system_channel, channels_.GuildTextChannel) return system_channel
Fetch the system channel.
Returns
- typing.Optional[hikari.channels.GuildTextChannel]: The system channel for this guild or
None
if not enabled.
Raises
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.ForbiddenError: If you are missing the
READ_MESSAGES
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.
View Source
async def fetch_widget_channel(self) -> typing.Optional[channels_.GuildChannel]: """Fetch the widget channel. This will be `None` if not set. Returns ------- typing.Optional[hikari.channels.GuildChannel] The channel the widget is linked to or else `None`. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `READ_MESSAGES` 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. """ if not self.widget_channel_id: return None widget_channel = await self.app.rest.fetch_channel(self.widget_channel_id) assert isinstance(widget_channel, channels_.GuildChannel) return widget_channel
Fetch the widget channel.
This will be None
if not set.
Returns
- typing.Optional[hikari.channels.GuildChannel]: The channel the widget is linked to or else
None
.
Raises
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.ForbiddenError: If you are missing the
READ_MESSAGES
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,
channel: Union[hikari.channels.PartialChannel, hikari.snowflakes.Snowflake, int]
) -> Optional[hikari.channels.GuildChannel]:
View Source
def get_channel( self, channel: snowflakes.SnowflakeishOr[channels_.PartialChannel], ) -> typing.Optional[channels_.GuildChannel]: """Get a cached channel that belongs to the guild by it's ID or object. Parameters ---------- channel : hikari.snowflakes.SnowflakeishOr[hikari.channels.PartialChannel] The object or ID of the guild channel to get from the cache. Returns ------- typing.Optional[hikari.channels.GuildChannel] The object of the guild channel found in cache or `None. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_guild_channel(channel)
Get a cached channel that belongs to the guild by it's ID or object.
Parameters
- channel (hikari.snowflakes.SnowflakeishOr[hikari.channels.PartialChannel]): The object or ID of the guild channel to get from the cache.
Returns
- typing.Optional[hikari.channels.GuildChannel]: The object of the guild channel found in cache or `None.
View Source
def get_channels(self) -> typing.Mapping[snowflakes.Snowflake, channels_.GuildChannel]: """Get the channels cached for the guild. Returns ------- typing.Mapping[hikari.snowflakes.Snowflake, hikari.channels.GuildChannel] A mapping of channel IDs to objects of the channels cached for the guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_guild_channels_view_for_guild(self.id)
Get the channels cached for the guild.
Returns
- typing.Mapping[hikari.snowflakes.Snowflake, hikari.channels.GuildChannel]: A mapping of channel IDs to objects of the channels cached for the guild.
self,
emoji: Union[hikari.emojis.CustomEmoji, hikari.snowflakes.Snowflake, int]
) -> Optional[hikari.emojis.KnownCustomEmoji]:
View Source
def get_emoji( self, emoji: snowflakes.SnowflakeishOr[emojis_.CustomEmoji] ) -> typing.Optional[emojis_.KnownCustomEmoji]: """Get a cached emoji that belongs to the guild by it's ID or object. Parameters ---------- emoji : hikari.snowflakes.SnowflakeishOr[hikari.emojis.CustomEmoji] The object or ID of the emoji to get from the cache. Returns ------- typing.Optional[hikari.emojis.KnownCustomEmoji] The object of the custom emoji if found in cache, else `None`. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_emoji(emoji)
Get a cached emoji that belongs to the guild by it's ID or object.
Parameters
- emoji (hikari.snowflakes.SnowflakeishOr[hikari.emojis.CustomEmoji]): The object or ID of the emoji to get from the cache.
Returns
- typing.Optional[hikari.emojis.KnownCustomEmoji]: The object of the custom emoji if found in cache, else
None
.
View Source
def get_emojis(self) -> typing.Mapping[snowflakes.Snowflake, emojis_.KnownCustomEmoji]: """Return the emojis in this guild. Returns ------- typing.Mapping[hikari.snowflakes.Snowflake, hikari.emojis.KnownCustomEmoji] A mapping of emoji IDs to the objects of emojis in this guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_emojis_view_for_guild(self.id)
Return the emojis in this guild.
Returns
- typing.Mapping[hikari.snowflakes.Snowflake, hikari.emojis.KnownCustomEmoji]: A mapping of emoji IDs to the objects of emojis in this guild.
self,
user: Union[hikari.users.PartialUser, hikari.snowflakes.Snowflake, int]
) -> Optional[hikari.guilds.Member]:
View Source
def get_member(self, user: snowflakes.SnowflakeishOr[users.PartialUser]) -> typing.Optional[Member]: """Get a cached member that belongs to the guild by it's user ID or object. Parameters ---------- user : hikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser] The object or ID of the user to get the cached member for. Returns ------- typing.Optional[Member] The cached member object if found, else `None`. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_member(self.id, user)
Get a cached member that belongs to the guild by it's user ID or object.
Parameters
- user (hikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser]): The object or ID of the user to get the cached member for.
Returns
- typing.Optional[Member]: The cached member object if found, else
None
.
View Source
def get_members(self) -> typing.Mapping[snowflakes.Snowflake, Member]: """Get the members cached for the guild. typing.Mapping[hikari.snowflakes.Snowflake, Member] A mapping of user IDs to objects of the members cached for the guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_members_view_for_guild(self.id)
Get the members cached for the guild.
typing.Mapping[hikari.snowflakes.Snowflake, Member] A mapping of user IDs to objects of the members cached for the guild.
View Source
def get_my_member(self) -> typing.Optional[Member]: """Return the cached member for the bot user in this guild, if known. Returns ------- typing.Optional[Member] The cached member for this guild, or `None` if not known. """ if not isinstance(self.app, traits.ShardAware): return None me = self.app.get_me() if me is None: return None return self.get_member(me.id)
Return the cached member for the bot user in this guild, if known.
Returns
- typing.Optional[Member]: The cached member for this guild, or
None
if not known.
self,
user: Union[hikari.users.PartialUser, hikari.snowflakes.Snowflake, int]
) -> Optional[hikari.presences.MemberPresence]:
View Source
def get_presence( self, user: snowflakes.SnowflakeishOr[users.PartialUser] ) -> typing.Optional[presences_.MemberPresence]: """Get a cached presence that belongs to the guild by it's user ID or object. Parameters ---------- user : hikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser] The object or ID of the user to get the cached presence for. Returns ------- typing.Optional[hikari.presences.MemberPresence] The cached presence object if found, else `None`. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_presence(self.id, user)
Get a cached presence that belongs to the guild by it's user ID or object.
Parameters
- user (hikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser]): The object or ID of the user to get the cached presence for.
Returns
- typing.Optional[hikari.presences.MemberPresence]: The cached presence object if found, else
None
.
self
) -> Mapping[hikari.snowflakes.Snowflake, hikari.presences.MemberPresence]:
View Source
def get_presences(self) -> typing.Mapping[snowflakes.Snowflake, presences_.MemberPresence]: """Get the presences cached for the guild. typing.Mapping[hikari.snowflakes.Snowflake, hikari.presences.MemberPresence] A mapping of user IDs to objects of the presences cached for the guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_presences_view_for_guild(self.id)
Get the presences cached for the guild.
typing.Mapping[hikari.snowflakes.Snowflake, hikari.presences.MemberPresence] A mapping of user IDs to objects of the presences cached for the guild.
self,
role: Union[hikari.guilds.PartialRole, hikari.snowflakes.Snowflake, int]
) -> Optional[hikari.guilds.Role]:
View Source
def get_role(self, role: snowflakes.SnowflakeishOr[PartialRole]) -> typing.Optional[Role]: """Get a cached role that belongs to the guild by it's ID or object. Parameters ---------- role : hikari.snowflakes.SnowflakeishOr[PartialRole] The object or ID of the role to get for this guild from the cache. Returns ------- typing.Optional[Role] The object of the role found in cache, else `None`. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_role(role)
Get a cached role that belongs to the guild by it's ID or object.
Parameters
- role (hikari.snowflakes.SnowflakeishOr[PartialRole]): The object or ID of the role to get for this guild from the cache.
Returns
- typing.Optional[Role]: The object of the role found in cache, else
None
.
View Source
def get_roles(self) -> typing.Mapping[snowflakes.Snowflake, Role]: """Return the roles in this guild. Returns ------- typing.Mapping[hikari.snowflakes.Snowflake, Role] A mapping of role IDs to the objects of roles in this guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_roles_view_for_guild(self.id)
Return the roles in this guild.
Returns
- typing.Mapping[hikari.snowflakes.Snowflake, Role]: A mapping of role IDs to the objects of roles in this guild.
self,
user: Union[hikari.users.PartialUser, hikari.snowflakes.Snowflake, int]
) -> Optional[hikari.voices.VoiceState]:
View Source
def get_voice_state( self, user: snowflakes.SnowflakeishOr[users.PartialUser] ) -> typing.Optional[voices_.VoiceState]: """Get a cached voice state that belongs to the guild by it's user. Parameters ---------- user : hikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser] The object or ID of the user to get the cached voice state for. Returns ------- typing.Optional[hikari.voices.VoiceState] The cached voice state object if found, else `None`. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_voice_state(self.id, user)
Get a cached voice state that belongs to the guild by it's user.
Parameters
- user (hikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser]): The object or ID of the user to get the cached voice state for.
Returns
- typing.Optional[hikari.voices.VoiceState]: The cached voice state object if found, else
None
.
View Source
def get_voice_states(self) -> typing.Mapping[snowflakes.Snowflake, voices_.VoiceState]: """Get the voice states cached for the guild. Returns ------- typing.Mapping[hikari.snowflakes.Snowflake, hikari.voices.VoiceState] A mapping of user IDs to objects of the voice states cached for the guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_voice_states_view_for_guild(self.id)
Get the voice states cached for the guild.
Returns
- typing.Mapping[hikari.snowflakes.Snowflake, hikari.voices.VoiceState]: A mapping of user IDs to objects of the voice states cached for the guild.
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: str = 'png',
size: int = 4096
) -> Optional[hikari.files.URL]:
View Source
def make_discovery_splash_url(self, *, ext: str = "png", size: int = 4096) -> typing.Optional[files.URL]: """Generate the guild's discovery 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 string URL. Raises ------ ValueError If `size` is not a power of two or not between 16 and 4096. """ if self.discovery_splash_hash is None: return None return routes.CDN_GUILD_DISCOVERY_SPLASH.compile_to_file( urls.CDN_URL, guild_id=self.id, hash=self.discovery_splash_hash, size=size, file_format=ext, )
Generate the guild's discovery 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 string URL.
Raises
- ValueError: If
size
is not a power of two or not between 16 and 4096.
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_extensions.with_copy @attr.define(hash=False, kw_only=True, weakref_slot=False) class GuildBan: """Used to represent guild bans.""" reason: typing.Optional[str] = attr.field(repr=True) """The reason for this ban, will be `None` if no reason was given.""" user: users.User = attr.field(repr=True) """The object of the user this ban targets."""
Used to represent guild bans.
Variables and properties
The reason for this ban, will be None
if no reason was given.
The object of the user this ban targets.
Methods
View Source
def __init__(self, *, reason, user): self.reason = reason self.user = user
Method generated by attrs for class GuildBan.
View Source
@typing.final class GuildExplicitContentFilterLevel(int, enums.Enum): """Represents the explicit content filter setting for a guild.""" DISABLED = 0 """No explicit content filter.""" MEMBERS_WITHOUT_ROLES = 1 """Filter posts from anyone without a role.""" ALL_MEMBERS = 2 """Filter all posts."""
Represents the explicit content filter setting for a guild.
Variables and properties
Filter all posts.
No explicit content filter.
Filter posts from anyone without a role.
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
@typing.final class GuildFeature(str, enums.Enum): """Features that a guild can provide.""" ANIMATED_ICON = "ANIMATED_ICON" """Guild has access to set an animated guild icon.""" BANNER = "BANNER" """Guild has access to set a guild banner image.""" COMMERCE = "COMMERCE" """Guild has access to use commerce features (i.e. create store channels).""" COMMUNITY = "COMMUNITY" """Guild has community features enabled.""" DISCOVERABLE = "DISCOVERABLE" """Guild is able to be discovered in the directory. This also implies the guild can be viewed without joining. """ FEATURABLE = "FEATURABLE" """Guild is able to be featured in the directory.""" INVITE_SPLASH = "INVITE_SPLASH" """Guild has access to set an invite splash background.""" MORE_EMOJI = "MORE_EMOJI" """More emojis can be hosted in this guild than normal.""" NEWS = "NEWS" """Guild has access to create news channels.""" PARTNERED = "PARTNERED" """Guild is partnered.""" RELAY_ENABLED = "RELAY_ENABLED" """Guild is using relays. Relays are new infrastructure designed to handle large guilds more efficiently server-side. """ VANITY_URL = "VANITY_URL" """Guild has access to set a vanity URL.""" VERIFIED = "VERIFIED" """Guild is verified.""" VIP_REGIONS = "VIP_REGIONS" """Guild has access to set 384kbps bitrate in voice. Previously gave access to VIP voice servers. """ WELCOME_SCREEN_ENABLED = "WELCOME_SCREEN_ENABLED" """Guild has enabled the welcome screen.""" MEMBER_VERIFICATION_GATE_ENABLED = "MEMBER_VERIFICATION_GATE_ENABLED" """Guild has enabled Membership Screening.""" PREVIEW_ENABLED = "PREVIEW_ENABLED" """Guild can be viewed before Membership Screening is complete.""" TICKETED_EVENTS_ENABLED = "TICKETED_EVENTS_ENABLED" """Guild has enabled ticketed events.""" MONETIZATION_ENABLED = "MONETIZATION_ENABLED" """Guild has enabled monetization.""" MORE_STICKERS = "MORE_STICKERS" """Guild has an increased custom stickers slots."""
Features that a guild can provide.
Variables and properties
Guild has access to set an animated guild icon.
Guild has access to set a guild banner image.
Guild has access to use commerce features (i.e. create store channels).
Guild has community features enabled.
Guild is able to be discovered in the directory.
This also implies the guild can be viewed without joining.
Guild is able to be featured in the directory.
Guild has access to set an invite splash background.
Guild has enabled Membership Screening.
Guild has enabled monetization.
More emojis can be hosted in this guild than normal.
Guild has an increased custom stickers slots.
Guild has access to create news channels.
Guild is partnered.
Guild can be viewed before Membership Screening is complete.
Guild is using relays.
Relays are new infrastructure designed to handle large guilds more efficiently server-side.
Guild has enabled ticketed events.
Guild has access to set a vanity URL.
Guild is verified.
Guild has access to set 384kbps bitrate in voice.
Previously gave access to VIP voice servers.
Guild has enabled the welcome screen.
Return the name of the enum member as a str
.
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 a capitalized version of the string.
More specifically, make the first character have upper case and the rest lower case.
Return a version of the string suitable for caseless comparisons.
Return a centered string of length width.
Padding is done using the specified fill character (default is a space).
S.count(sub[, start[, end]]) -> int
Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.
Encode the string using the codec registered for encoding.
encoding The encoding in which to encode the string. errors The error handling scheme to use for encoding errors. The default is 'strict' meaning that encoding errors raise a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and 'xmlcharrefreplace' as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.
S.endswith(suffix[, start[, end]]) -> bool
Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.
Return a copy where all tab characters are expanded using spaces.
If tabsize is not given, a tab size of 8 characters is assumed.
S.find(sub[, start[, end]]) -> int
Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.
Return -1 on failure.
S.format(args, *kwargs) -> str
Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces ('{' and '}').
S.format_map(mapping) -> str
Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces ('{' and '}').
S.index(sub[, start[, end]]) -> int
Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.
Raises ValueError when the substring is not found.
Return True if the string is an alpha-numeric string, False otherwise.
A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.
Return True if the string is an alphabetic string, False otherwise.
A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.
Return True if all characters in the string are ASCII, False otherwise.
ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.
Return True if the string is a decimal string, False otherwise.
A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.
Return True if the string is a digit string, False otherwise.
A string is a digit string if all characters in the string are digits and there is at least one character in the string.
Return True if the string is a valid Python identifier, False otherwise.
Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as "def" or "class".
Return True if the string is a lowercase string, False otherwise.
A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.
Return True if the string is a numeric string, False otherwise.
A string is numeric if all characters in the string are numeric and there is at least one character in the string.
Return True if the string is printable, False otherwise.
A string is printable if all of its characters are considered printable in repr() or if it is empty.
Return True if the string is a whitespace string, False otherwise.
A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.
Return True if the string is a title-cased string, False otherwise.
In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.
Return True if the string is an uppercase string, False otherwise.
A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.
Concatenate any number of strings.
The string whose method is called is inserted in between each given string. The result is returned as a new string.
Example: '.'.join(['ab', 'pq', 'rs']) -> 'ab.pq.rs'
Return a left-justified string of length width.
Padding is done using the specified fill character (default is a space).
Return a copy of the string converted to lowercase.
Return a copy of the string with leading whitespace removed.
If chars is given and not None, remove characters in chars instead.
Return a translation table usable for str.translate().
If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.
Partition the string into three parts using the given separator.
This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.
If the separator is not found, returns a 3-tuple containing the original string and two empty strings.
Return a str with the given prefix string removed if present.
If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.
Return a str with the given suffix string removed if present.
If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.
Return a copy with all occurrences of substring old replaced by new.
count Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.
If the optional argument count is given, only the first count occurrences are replaced.
S.rfind(sub[, start[, end]]) -> int
Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.
Return -1 on failure.
S.rindex(sub[, start[, end]]) -> int
Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.
Raises ValueError when the substring is not found.
Return a right-justified string of length width.
Padding is done using the specified fill character (default is a space).
Partition the string into three parts using the given separator.
This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.
If the separator is not found, returns a 3-tuple containing two empty strings and the original string.
Return a list of the words in the string, using sep as the delimiter string.
sep The delimiter according which to split the string. None (the default value) means split according to any whitespace, and discard empty strings from the result. maxsplit Maximum number of splits to do. -1 (the default value) means no limit.
Splits are done starting at the end of the string and working to the front.
Return a copy of the string with trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
Return a list of the words in the string, using sep as the delimiter string.
sep The delimiter according which to split the string. None (the default value) means split according to any whitespace, and discard empty strings from the result. maxsplit Maximum number of splits to do. -1 (the default value) means no limit.
Return a list of the lines in the string, breaking at line boundaries.
Line breaks are not included in the resulting list unless keepends is given and true.
S.startswith(prefix[, start[, end]]) -> bool
Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.
Return a copy of the string with leading and trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
Convert uppercase characters to lowercase and lowercase characters to uppercase.
Return a version of the string where each word is titlecased.
More specifically, words start with uppercased characters and all remaining cased characters have lower case.
Replace each character in the string using the given translation table.
table Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.
The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.
Return a copy of the string converted to uppercase.
Pad a numeric string with zeros on the left, to fill a field of the given width.
The string is never truncated.
View Source
@typing.final class GuildMFALevel(int, enums.Enum): """Represents the multi-factor authorization requirement for a guild.""" NONE = 0 """No MFA requirement.""" ELEVATED = 1 """MFA requirement."""
Represents the multi-factor authorization requirement for a guild.
Variables and properties
MFA requirement.
No MFA requirement.
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
@typing.final class GuildMessageNotificationsLevel(int, enums.Enum): """Represents the default notification level for new messages in a guild.""" ALL_MESSAGES = 0 """Notify users when any message is sent.""" ONLY_MENTIONS = 1 """Only notify users when they are @mentioned."""
Represents the default notification level for new messages in a guild.
Variables and properties
Notify users when any message is sent.
Only notify users when they are @mentioned.
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
@typing.final class GuildNSFWLevel(int, enums.Enum): """Represents the NSFW level of a guild.""" DEFAULT = 0 """Guild has not been categorized yet.""" EXPLICIT = 1 """Guild contains explicit NSFW content.""" SAFE = 2 """Guild is safe of NSFW content.""" AGE_RESTRICTED = 3 """Guild may contain NSFW content."""
Represents the NSFW level of a guild.
Variables and properties
Guild may contain NSFW content.
Guild has not been categorized yet.
Guild contains explicit NSFW content.
Guild is safe of NSFW content.
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
@typing.final class GuildPremiumTier(int, enums.Enum): """Tier for Discord Nitro boosting in a guild.""" NONE = 0 """No Nitro boost level.""" TIER_1 = 1 """Level 1 Nitro boost.""" TIER_2 = 2 """Level 2 Nitro boost.""" TIER_3 = 3 """Level 3 Nitro boost."""
Tier for Discord Nitro boosting in a guild.
Variables and properties
No Nitro boost level.
Level 1 Nitro boost.
Level 2 Nitro boost.
Level 3 Nitro boost.
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.define(hash=True, kw_only=True, weakref_slot=False) class GuildPreview(PartialGuild): """A preview of a guild with the `GuildFeature.DISCOVERABLE` feature.""" features: typing.Sequence[typing.Union[str, GuildFeature]] = 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.""" discovery_splash_hash: typing.Optional[str] = attr.field(eq=False, hash=False, repr=False) """The hash of the discovery splash for the guild, if there is one.""" emojis: typing.Mapping[snowflakes.Snowflake, emojis_.KnownCustomEmoji] = attr.field( eq=False, hash=False, repr=False ) """The mapping of IDs to the emojis this guild provides.""" approximate_active_member_count: int = attr.field(eq=False, hash=False, repr=True) """The approximate amount of presences in this guild.""" approximate_member_count: int = attr.field(eq=False, hash=False, repr=True) """The approximate amount of members in this guild.""" description: typing.Optional[str] = attr.field(eq=False, hash=False, repr=False) """The guild's description, if set.""" @property def discovery_splash_url(self) -> typing.Optional[files.URL]: """Discovery URL splash for the guild, if set.""" return self.make_discovery_splash_url() @property def splash_url(self) -> typing.Optional[files.URL]: """Splash URL for the guild, if set.""" return self.make_splash_url() def make_discovery_splash_url(self, *, ext: str = "png", size: int = 4096) -> typing.Optional[files.URL]: """Generate the guild's discovery 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 string URL. Raises ------ ValueError If `size` is not a power of two or not between 16 and 4096. """ if self.discovery_splash_hash is None: return None return routes.CDN_GUILD_DISCOVERY_SPLASH.compile_to_file( urls.CDN_URL, guild_id=self.id, hash=self.discovery_splash_hash, size=size, file_format=ext, ) 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, )
A preview of a guild with the GuildFeature.DISCOVERABLE
feature.
Variables and properties
The client application that models may use for procedures.
The approximate amount of presences in this guild.
The approximate amount of members in this guild.
When the object was created.
The guild's description, if set.
The hash of the discovery splash for the guild, if there is one.
Discovery URL splash for the guild, if set.
The mapping of IDs to the emojis this guild provides.
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.
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.
Methods
self,
*,
app: hikari.traits.RESTAware,
id: hikari.snowflakes.Snowflake,
icon_hash: Optional[str],
name: str,
features: Sequence[Union[str, hikari.guilds.GuildFeature]],
splash_hash: Optional[str],
discovery_splash_hash: Optional[str],
emojis: Mapping[hikari.snowflakes.Snowflake, hikari.emojis.KnownCustomEmoji],
approximate_active_member_count: int,
approximate_member_count: int,
description: Optional[str]
):
View Source
def __init__(self, *, app, id, icon_hash, name, features, splash_hash, discovery_splash_hash, emojis, approximate_active_member_count, approximate_member_count, description): self.app = app self.id = id self.icon_hash = icon_hash self.name = name self.features = features self.splash_hash = splash_hash self.discovery_splash_hash = discovery_splash_hash self.emojis = emojis self.approximate_active_member_count = approximate_active_member_count self.approximate_member_count = approximate_member_count self.description = description
Method generated by attrs for class GuildPreview.
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: str = 'png',
size: int = 4096
) -> Optional[hikari.files.URL]:
View Source
def make_discovery_splash_url(self, *, ext: str = "png", size: int = 4096) -> typing.Optional[files.URL]: """Generate the guild's discovery 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 string URL. Raises ------ ValueError If `size` is not a power of two or not between 16 and 4096. """ if self.discovery_splash_hash is None: return None return routes.CDN_GUILD_DISCOVERY_SPLASH.compile_to_file( urls.CDN_URL, guild_id=self.id, hash=self.discovery_splash_hash, size=size, file_format=ext, )
Generate the guild's discovery 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 string URL.
Raises
- ValueError: If
size
is not a power of two or not between 16 and 4096.
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
@typing.final class GuildSystemChannelFlag(enums.Flag): """Defines which features are suppressed in the system channel.""" NONE = 0 """Nothing is suppressed.""" SUPPRESS_USER_JOIN = 1 << 0 """Suppress displaying a message about new users joining.""" SUPPRESS_PREMIUM_SUBSCRIPTION = 1 << 1 """Suppress displaying a message when the guild is Nitro boosted.""" SUPPRESS_GUILD_REMINDER = 1 << 2 """Suppress displaying messages with guild setup tips.""" SUPPRESS_USER_JOIN_REPLIES = 1 << 3 """Suppress displaying a reply button on join notifications."""
Defines which features are suppressed in the system channel.
Variables and properties
Nothing is suppressed.
Suppress displaying messages with guild setup tips.
Suppress displaying a message when the guild is Nitro boosted.
Suppress displaying a message about new users joining.
Suppress displaying a reply button on join notifications.
the denominator of a rational number in lowest terms
the imaginary part of a complex number
Return the name of the flag combination as a str
.
the numerator of a rational number in lowest terms
the real part of a complex number
Return the int
value of the flag.
Methods
View Source
def __call__(cls, value: int = 0) -> typing.Any: """Cast a value to the flag enum, returning the raw value that was passed if values not found.""" # We want to handle value invariantly to avoid issues brought in by different behaviours from sub-classed ints # and floats. This also ensures that .__int__ only returns an invariant int. value = int(value) try: return cls._value_to_member_map_[value] except KeyError: # We only need this ability here usually, so overloading operators # is an overkill and would add more overhead. if value < 0: # Convert to a positive value instead. return cls.__everything__ - ~value temp_members = cls._temp_members_ # For huge enums, don't ever cache anything. We could consume masses of memory otherwise # (e.g. Permissions) try: # Try to get a cached value. return temp_members[value] except KeyError: # If we can't find the value, just return what got casted in by generating a pseudomember # and caching it. We can't use weakref because int is not weak referenceable, annoyingly. pseudomember = cls.__new__(cls, value) pseudomember._name_ = None pseudomember._value_ = value temp_members[value] = pseudomember if len(temp_members) > _MAX_CACHED_MEMBERS: temp_members.popitem() return pseudomember
Cast a value to the flag enum, returning the raw value that was passed if values not found.
View Source
def all(self: _T, *flags: _T) -> bool: """Check if all of the given flags are part of this value. Returns ------- bool `True` if any of the given flags are part of this value. Otherwise, return `False`. """ return all((flag & self) == flag for flag in flags)
Check if all of the given flags are part of this value.
Returns
- bool:
True
if any of the given flags are part of this value. Otherwise, returnFalse
.
View Source
def any(self: _T, *flags: _T) -> bool: """Check if any of the given flags are part of this value. Returns ------- bool `True` if any of the given flags are part of this value. Otherwise, return `False`. """ return any((flag & self) == flag for flag in flags)
Check if any of the given flags are part of this value.
Returns
- bool:
True
if any of the given flags are part of this value. Otherwise, returnFalse
.
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.
View Source
def difference(self: _T, other: typing.Union[_T, int]) -> _T: """Perform a set difference with the other set. This will return all flags in this set that are not in the other value. Equivalent to using the subtraction `-` operator. """ return self.__class__(self & ~int(other))
Perform a set difference with the other set.
This will return all flags in this set that are not in the other value.
Equivalent to using the subtraction -
operator.
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.
View Source
def intersection(self: _T, other: typing.Union[_T, int]) -> _T: """Return a combination of flags that are set for both given values. Equivalent to using the "AND" `&` operator. """ return self.__class__(self._value_ & int(other))
Return a combination of flags that are set for both given values.
Equivalent to using the "AND" &
operator.
View Source
def invert(self: _T) -> _T: """Return a set of all flags not in the current set.""" return self.__class__(self.__class__.__everything__._value_ & ~self._value_)
Return a set of all flags not in the current set.
View Source
def is_disjoint(self: _T, other: typing.Union[_T, int]) -> bool: """Return whether two sets have a intersection or not. If the two sets have an intersection, then this returns `False`. If no common flag values exist between them, then this returns `True`. """ return not (self & other)
Return whether two sets have a intersection or not.
If the two sets have an intersection, then this returns False
. If no common flag values exist between them, then this returns True
.
View Source
def is_subset(self: _T, other: typing.Union[_T, int]) -> bool: """Return whether another set contains this set or not. Equivalent to using the "in" operator. """ return (self & other) == other
Return whether another set contains this set or not.
Equivalent to using the "in" operator.
View Source
def is_superset(self: _T, other: typing.Union[_T, int]) -> bool: """Return whether this set contains another set or not.""" return (self & other) == self
Return whether this set contains another set or not.
View Source
def is_disjoint(self: _T, other: typing.Union[_T, int]) -> bool: """Return whether two sets have a intersection or not. If the two sets have an intersection, then this returns `False`. If no common flag values exist between them, then this returns `True`. """ return not (self & other)
Return whether two sets have a intersection or not.
If the two sets have an intersection, then this returns False
. If no common flag values exist between them, then this returns True
.
View Source
def is_subset(self: _T, other: typing.Union[_T, int]) -> bool: """Return whether another set contains this set or not. Equivalent to using the "in" operator. """ return (self & other) == other
Return whether another set contains this set or not.
Equivalent to using the "in" operator.
View Source
def is_superset(self: _T, other: typing.Union[_T, int]) -> bool: """Return whether this set contains another set or not.""" return (self & other) == self
Return whether this set contains another set or not.
View Source
def none(self: _T, *flags: _T) -> bool: """Check if none of the given flags are part of this value. .. note:: This is essentially the opposite of `Flag.any`. Returns ------- bool `True` if none of the given flags are part of this value. Otherwise, return `False`. """ return not self.any(*flags)
Check if none of the given flags are part of this value.
Note: This is essentially the opposite of Flag.any
.
Returns
- bool:
True
if none of the given flags are part of this value. Otherwise, returnFalse
.
View Source
def split(self: _T) -> typing.Sequence[_T]: """Return a list of all defined atomic values for this flag. Any unrecognised bits will be omitted for brevity. The result will be a name-sorted `typing.Sequence` of each member """ return sorted( (member for member in self.__class__._powers_of_2_to_member_map_.values() if member.value & self), # Assumption: powers of 2 already have a cached value. key=lambda m: m._name_, )
Return a list of all defined atomic values for this flag.
Any unrecognised bits will be omitted for brevity.
The result will be a name-sorted typing.Sequence
of each member
View Source
def symmetric_difference(self: _T, other: typing.Union[_T, int]) -> _T: """Return a set with the symmetric differences of two flag sets. Equivalent to using the "XOR" `^` operator. For `a ^ b`, this can be considered the same as `(a - b) | (b - a)`. """ return self.__class__(self._value_ ^ int(other))
Return a set with the symmetric differences of two flag sets.
Equivalent to using the "XOR" ^
operator.
For a ^ b
, this can be considered the same as (a - b) | (b - a)
.
View Source
def symmetric_difference(self: _T, other: typing.Union[_T, int]) -> _T: """Return a set with the symmetric differences of two flag sets. Equivalent to using the "XOR" `^` operator. For `a ^ b`, this can be considered the same as `(a - b) | (b - a)`. """ return self.__class__(self._value_ ^ int(other))
Return a set with the symmetric differences of two flag sets.
Equivalent to using the "XOR" ^
operator.
For a ^ b
, this can be considered the same as (a - b) | (b - a)
.
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
def union(self: _T, other: typing.Union[_T, int]) -> _T: """Return a combination of all flags in this set and the other set. Equivalent to using the "OR" `~` operator. """ return self.__class__(self._value_ | int(other))
Return a combination of all flags in this set and the other set.
Equivalent to using the "OR" ~
operator.
View Source
@typing.final class GuildVerificationLevel(int, enums.Enum): """Represents the level of verification of a guild.""" NONE = 0 """Unrestricted.""" LOW = 1 """Must have a verified email on their account.""" MEDIUM = 2 """Must have been registered on Discord for more than 5 minutes.""" HIGH = 3 """Must also be a member of the guild for longer than 10 minutes.""" VERY_HIGH = 4 """Must have a verified phone number."""
Represents the level of verification of a guild.
Variables and properties
Must also be a member of the guild for longer than 10 minutes.
Must have a verified email on their account.
Must have been registered on Discord for more than 5 minutes.
Unrestricted.
Must have a verified phone number.
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=False, kw_only=True, weakref_slot=False) class GuildWidget: """Represents a guild widget.""" 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.""" channel_id: typing.Optional[snowflakes.Snowflake] = attr.field(repr=True) """The ID of the channel the invite for this embed targets, if enabled.""" is_enabled: bool = attr.field(repr=True) """Whether this embed is enabled.""" async def fetch_channel(self) -> typing.Optional[channels_.GuildChannel]: """Fetch the widget channel. This will be `None` if not set. Returns ------- typing.Optional[hikari.channels.GuildChannel] The requested channel. You can check the type of the channel by using `isinstance`. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `READ_MESSAGES` 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. """ if not self.channel_id: return None widget_channel = await self.app.rest.fetch_channel(self.channel_id) assert isinstance(widget_channel, channels_.GuildChannel) return widget_channel
Represents a guild widget.
Variables and properties
The client application that models may use for procedures.
The ID of the channel the invite for this embed targets, if enabled.
Whether this embed is enabled.
Methods
self,
*,
app: hikari.traits.RESTAware,
channel_id: Optional[hikari.snowflakes.Snowflake],
is_enabled: bool
):
View Source
def __init__(self, *, app, channel_id, is_enabled): self.app = app self.channel_id = channel_id self.is_enabled = is_enabled
Method generated by attrs for class GuildWidget.
View Source
async def fetch_channel(self) -> typing.Optional[channels_.GuildChannel]: """Fetch the widget channel. This will be `None` if not set. Returns ------- typing.Optional[hikari.channels.GuildChannel] The requested channel. You can check the type of the channel by using `isinstance`. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `READ_MESSAGES` 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. """ if not self.channel_id: return None widget_channel = await self.app.rest.fetch_channel(self.channel_id) assert isinstance(widget_channel, channels_.GuildChannel) return widget_channel
Fetch the widget channel.
This will be None
if not set.
Returns
- typing.Optional[hikari.channels.GuildChannel]: The requested channel.
You can check the type of the channel by using isinstance
.
Raises
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.ForbiddenError: If you are missing the
READ_MESSAGES
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.
View Source
@attr.define(hash=True, kw_only=True, weakref_slot=False) class Integration(PartialIntegration): """Represents a guild integration object.""" guild_id: snowflakes.Snowflake = attr.field() """The ID of the guild this integration belongs to.""" expire_behavior: typing.Union[IntegrationExpireBehaviour, int, None] = attr.field(eq=False, hash=False, repr=False) """How members should be treated after their connected subscription expires. This will not be enacted until after `GuildIntegration.expire_grace_period` passes. .. note:: This will always be `None` for Discord integrations. """ expire_grace_period: typing.Optional[datetime.timedelta] = attr.field(eq=False, hash=False, repr=False) """How many days users with expired subscriptions are given until `GuildIntegration.expire_behavior` is enacted out on them. .. note:: This will always be `None` for Discord integrations. """ is_enabled: bool = attr.field(eq=False, hash=False, repr=True) """Whether this integration is enabled.""" is_syncing: typing.Optional[bool] = attr.field(eq=False, hash=False, repr=False) """Whether this integration is syncing subscribers/emojis.""" is_emojis_enabled: typing.Optional[bool] = attr.field(eq=False, hash=False, repr=False) """Whether users under this integration are allowed to use it's custom emojis.""" is_revoked: typing.Optional[bool] = attr.field(eq=False, hash=False, repr=False) """Whether the integration has been revoked.""" last_synced_at: typing.Optional[datetime.datetime] = attr.field(eq=False, hash=False, repr=False) """The datetime of when this integration's subscribers were last synced.""" role_id: typing.Optional[snowflakes.Snowflake] = attr.field(eq=False, hash=False, repr=False) """The ID of the managed role used for this integration's subscribers.""" user: typing.Optional[users.User] = attr.field(eq=False, hash=False, repr=False) """The user this integration belongs to.""" subscriber_count: typing.Optional[int] = attr.field(eq=False, hash=False, repr=False) """The number of subscribers this integration has.""" application: typing.Optional[IntegrationApplication] = attr.field(eq=False, hash=False, repr=False) """The bot/OAuth2 application associated with this integration. .. note:: This is only available for Discord integrations. """
Represents a guild integration object.
Variables and properties
The account connected to this integration.
The bot/OAuth2 application associated with this integration.
Note: This is only available for Discord integrations.
When the object was created.
How members should be treated after their connected subscription expires.
This will not be enacted until after GuildIntegration.expire_grace_period
passes.
Note: This will always be None
for Discord integrations.
How many days users with expired subscriptions are given until GuildIntegration.expire_behavior
is enacted out on them.
Note: This will always be None
for Discord integrations.
The ID of the guild this integration belongs to.
The ID of this entity.
Whether users under this integration are allowed to use it's custom emojis.
Whether this integration is enabled.
Whether the integration has been revoked.
Whether this integration is syncing subscribers/emojis.
The datetime of when this integration's subscribers were last synced.
The name of this integration.
The ID of the managed role used for this integration's subscribers.
The number of subscribers this integration has.
The type of this integration.
The user this integration belongs to.
Methods
self,
*,
account: hikari.guilds.IntegrationAccount,
id: hikari.snowflakes.Snowflake,
name: str,
type: Union[hikari.guilds.IntegrationType, str],
guild_id: hikari.snowflakes.Snowflake,
expire_behavior: Union[hikari.guilds.IntegrationExpireBehaviour, int, NoneType],
expire_grace_period: Optional[datetime.timedelta],
is_enabled: bool,
is_syncing: Optional[bool],
is_emojis_enabled: Optional[bool],
is_revoked: Optional[bool],
last_synced_at: Optional[datetime.datetime],
role_id: Optional[hikari.snowflakes.Snowflake],
user: Optional[hikari.users.User],
subscriber_count: Optional[int],
application: Optional[hikari.guilds.IntegrationApplication]
):
View Source
def __init__(self, *, account, id, name, type, guild_id, expire_behavior, expire_grace_period, is_enabled, is_syncing, is_emojis_enabled, is_revoked, last_synced_at, role_id, user, subscriber_count, application): self.account = account self.id = id self.name = name self.type = type self.guild_id = guild_id self.expire_behavior = expire_behavior self.expire_grace_period = expire_grace_period self.is_enabled = is_enabled self.is_syncing = is_syncing self.is_emojis_enabled = is_emojis_enabled self.is_revoked = is_revoked self.last_synced_at = last_synced_at self.role_id = role_id self.user = user self.subscriber_count = subscriber_count self.application = application
Method generated by attrs for class Integration.
View Source
@attr_extensions.with_copy @attr.define(hash=True, kw_only=True, weakref_slot=False) class IntegrationAccount: """An account that's linked to an integration.""" id: str = attr.field(hash=True, repr=True) """The string ID of this (likely) third party account.""" name: str = attr.field(eq=False, hash=False, repr=True) """The name of this account.""" def __str__(self) -> str: return self.name
An account that's linked to an integration.
Variables and properties
The string ID of this (likely) third party account.
The name of this account.
Methods
View Source
def __init__(self, *, id, name): self.id = id self.name = name
Method generated by attrs for class IntegrationAccount.
View Source
@attr_extensions.with_copy @attr.define(hash=True, kw_only=True, weakref_slot=False) class IntegrationApplication(PartialApplication): """An application that's linked to an integration.""" bot: typing.Optional[users.User] = attr.field(eq=False, hash=False, repr=False) """The bot associated with this application."""
An application that's linked to an integration.
Variables and properties
The bot associated with this application.
When the object was created.
The description of this application, if any.
The CDN hash of this application's icon, if set.
Team icon URL, if there is one.
The ID of this entity.
The name of this application.
Methods
self,
*,
id: hikari.snowflakes.Snowflake,
name: str,
description: Optional[str],
icon_hash: Optional[str],
bot: Optional[hikari.users.User]
):
View Source
def __init__(self, *, id, name, description, icon_hash, bot): self.id = id self.name = name self.description = description self.icon_hash = icon_hash self.bot = bot
Method generated by attrs for class IntegrationApplication.
View Source
def make_icon_url(self, *, ext: str = "png", size: int = 4096) -> typing.Optional[files.URL]: """Generate the icon URL for this application. 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, or `None` if no icon exists. Raises ------ ValueError If the size is not an integer power of 2 between 16 and 4096 (inclusive). """ if self.icon_hash is None: return None return routes.CDN_APPLICATION_ICON.compile_to_file( urls.CDN_URL, application_id=self.id, hash=self.icon_hash, size=size, file_format=ext, )
Generate the icon URL for this application.
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, or
None
if no icon exists.
Raises
- ValueError: If the size is not an integer power of 2 between 16 and 4096 (inclusive).
View Source
@typing.final class IntegrationExpireBehaviour(int, enums.Enum): """Behavior for expiring integration subscribers.""" REMOVE_ROLE = 0 """Remove the role.""" KICK = 1 """Kick the subscriber."""
Behavior for expiring integration subscribers.
Variables and properties
Kick the subscriber.
Remove the role.
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
@typing.final class IntegrationType(str, enums.Enum): """The integration type.""" TWITCH = "twitch" YOUTUBE = "youtube" DISCORD_BOT = "discord"
The integration type.
Variables and properties
Return the name of the enum member as a str
.
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 a capitalized version of the string.
More specifically, make the first character have upper case and the rest lower case.
Return a version of the string suitable for caseless comparisons.
Return a centered string of length width.
Padding is done using the specified fill character (default is a space).
S.count(sub[, start[, end]]) -> int
Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.
Encode the string using the codec registered for encoding.
encoding The encoding in which to encode the string. errors The error handling scheme to use for encoding errors. The default is 'strict' meaning that encoding errors raise a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and 'xmlcharrefreplace' as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.
S.endswith(suffix[, start[, end]]) -> bool
Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.
Return a copy where all tab characters are expanded using spaces.
If tabsize is not given, a tab size of 8 characters is assumed.
S.find(sub[, start[, end]]) -> int
Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.
Return -1 on failure.
S.format(args, *kwargs) -> str
Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces ('{' and '}').
S.format_map(mapping) -> str
Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces ('{' and '}').
S.index(sub[, start[, end]]) -> int
Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.
Raises ValueError when the substring is not found.
Return True if the string is an alpha-numeric string, False otherwise.
A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.
Return True if the string is an alphabetic string, False otherwise.
A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.
Return True if all characters in the string are ASCII, False otherwise.
ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.
Return True if the string is a decimal string, False otherwise.
A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.
Return True if the string is a digit string, False otherwise.
A string is a digit string if all characters in the string are digits and there is at least one character in the string.
Return True if the string is a valid Python identifier, False otherwise.
Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as "def" or "class".
Return True if the string is a lowercase string, False otherwise.
A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.
Return True if the string is a numeric string, False otherwise.
A string is numeric if all characters in the string are numeric and there is at least one character in the string.
Return True if the string is printable, False otherwise.
A string is printable if all of its characters are considered printable in repr() or if it is empty.
Return True if the string is a whitespace string, False otherwise.
A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.
Return True if the string is a title-cased string, False otherwise.
In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.
Return True if the string is an uppercase string, False otherwise.
A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.
Concatenate any number of strings.
The string whose method is called is inserted in between each given string. The result is returned as a new string.
Example: '.'.join(['ab', 'pq', 'rs']) -> 'ab.pq.rs'
Return a left-justified string of length width.
Padding is done using the specified fill character (default is a space).
Return a copy of the string converted to lowercase.
Return a copy of the string with leading whitespace removed.
If chars is given and not None, remove characters in chars instead.
Return a translation table usable for str.translate().
If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.
Partition the string into three parts using the given separator.
This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.
If the separator is not found, returns a 3-tuple containing the original string and two empty strings.
Return a str with the given prefix string removed if present.
If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.
Return a str with the given suffix string removed if present.
If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.
Return a copy with all occurrences of substring old replaced by new.
count Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.
If the optional argument count is given, only the first count occurrences are replaced.
S.rfind(sub[, start[, end]]) -> int
Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.
Return -1 on failure.
S.rindex(sub[, start[, end]]) -> int
Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.
Raises ValueError when the substring is not found.
Return a right-justified string of length width.
Padding is done using the specified fill character (default is a space).
Partition the string into three parts using the given separator.
This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.
If the separator is not found, returns a 3-tuple containing two empty strings and the original string.
Return a list of the words in the string, using sep as the delimiter string.
sep The delimiter according which to split the string. None (the default value) means split according to any whitespace, and discard empty strings from the result. maxsplit Maximum number of splits to do. -1 (the default value) means no limit.
Splits are done starting at the end of the string and working to the front.
Return a copy of the string with trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
Return a list of the words in the string, using sep as the delimiter string.
sep The delimiter according which to split the string. None (the default value) means split according to any whitespace, and discard empty strings from the result. maxsplit Maximum number of splits to do. -1 (the default value) means no limit.
Return a list of the lines in the string, breaking at line boundaries.
Line breaks are not included in the resulting list unless keepends is given and true.
S.startswith(prefix[, start[, end]]) -> bool
Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.
Return a copy of the string with leading and trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
Convert uppercase characters to lowercase and lowercase characters to uppercase.
Return a version of the string where each word is titlecased.
More specifically, words start with uppercased characters and all remaining cased characters have lower case.
Replace each character in the string using the given translation table.
table Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.
The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.
Return a copy of the string converted to uppercase.
Pad a numeric string with zeros on the left, to fill a field of the given width.
The string is never truncated.
View Source
@attr_extensions.with_copy @attr.define(eq=False, hash=False, kw_only=True, weakref_slot=False) class Member(users.User): """Used to represent a guild bound member.""" guild_id: snowflakes.Snowflake = attr.field(repr=True) """The ID of the guild this member belongs to.""" is_deaf: undefined.UndefinedOr[bool] = attr.field(repr=False) """`True` if this member is deafened in the current voice channel. This will be `hikari.undefined.UNDEFINED` if it's state is unknown. """ is_mute: undefined.UndefinedOr[bool] = attr.field(repr=False) """`True` if this member is muted in the current voice channel. This will be `hikari.undefined.UNDEFINED` if it's state is unknown. """ is_pending: undefined.UndefinedOr[bool] = attr.field(repr=False) """Whether the user has passed the guild's membership screening requirements. This will be `hikari.undefined.UNDEFINED` if it's state is unknown. """ joined_at: datetime.datetime = attr.field(repr=True) """The datetime of when this member joined the guild they belong to.""" nickname: typing.Optional[str] = attr.field(repr=True) """This member's nickname. This will be `None` if not set. """ premium_since: typing.Optional[datetime.datetime] = attr.field(repr=False) """The datetime of when this member started "boosting" this guild. Will be `None` if the member is not a premium user. """ raw_communication_disabled_until: typing.Optional[datetime.datetime] = attr.field(repr=False) """The datetime when this member's timeout will expire. Will be `None` if the member is not timed out. .. note:: The datetime might be in the past, so it is recommended to use `communication_disabled_until` method to check if the member is timed out at the time of the call. """ role_ids: typing.Sequence[snowflakes.Snowflake] = attr.field(repr=False) """A sequence of the IDs of the member's current roles.""" # This is technically optional, since UPDATE MEMBER and MESSAGE CREATE # events do not inject the user into the member payload, but specify it # separately. However, to get around this inconsistency, we force the # entity factory to always provide the user object in these cases, so we # can assume this is always set, and thus we are always able to get info # such as the ID of the user this member represents. user: users.User = attr.field(repr=True) """This member's corresponding user object.""" guild_avatar_hash: typing.Optional[str] = attr.field(eq=False, hash=False, repr=False) """Hash of the member's guild avatar guild if set, else `None`. .. note:: This takes precedence over `Member.avatar_hash`. """ @property def app(self) -> traits.RESTAware: """Return the app that is bound to the user object.""" return self.user.app @property def avatar_hash(self) -> typing.Optional[str]: return self.user.avatar_hash @property def avatar_url(self) -> typing.Optional[files.URL]: return self.user.avatar_url @property def guild_avatar_url(self) -> typing.Optional[files.URL]: """Guild Avatar URL for the user, if they have one set. May be `None` if no guild avatar is set. In this case, you should use `avatar_hash` or `default_avatar_url` instead. """ return self.make_guild_avatar_url() @property def default_avatar_url(self) -> files.URL: return self.user.default_avatar_url @property def display_avatar_url(self) -> files.URL: return self.make_guild_avatar_url() or super().display_avatar_url @property def banner_hash(self) -> typing.Optional[str]: return self.user.banner_hash @property def banner_url(self) -> typing.Optional[files.URL]: return self.user.banner_url @property def accent_color(self) -> typing.Optional[colors.Color]: return self.user.accent_color @property def discriminator(self) -> str: return self.user.discriminator @property def display_name(self) -> str: """Return the member's display name. If the member has a nickname, this will return that nickname. Otherwise, it will return the username instead. See Also -------- `Member.nickname` `Member.username` """ return self.nickname if isinstance(self.nickname, str) else self.username @property def flags(self) -> users.UserFlag: return self.user.flags @property def id(self) -> snowflakes.Snowflake: return self.user.id @property def is_bot(self) -> bool: return self.user.is_bot @property def is_system(self) -> bool: return self.user.is_system @property def mention(self) -> str: """Return a raw mention string for the given member. If the member has a known nickname, we always return a bang ("`!`") before the ID part of the mention string. This mimics the behaviour Discord clients tend to provide. Example ------- ```py >>> some_member_without_nickname.mention '<@123456789123456789>' >>> some_member_with_nickname.mention '<@!123456789123456789>' ``` """ return f"<@!{self.id}>" if self.nickname is not None else self.user.mention def communication_disabled_until(self) -> typing.Optional[datetime.datetime]: """Return when the timeout for this member ends. Unlike `raw_communication_disabled_until`, this will always be `None` if the member is not currently timed out. .. note:: The output of this function can depend based on when the function is called. """ if ( self.raw_communication_disabled_until is not None and self.raw_communication_disabled_until > time.utc_datetime() ): return self.raw_communication_disabled_until return None def get_guild(self) -> typing.Optional[Guild]: """Return the guild associated with this member. Returns ------- typing.Optional[hikari.guilds.Guild] The linked guild object or `None` if it's not cached. """ if not isinstance(self.user.app, traits.CacheAware): return None return self.user.app.cache.get_guild(self.guild_id) def get_presence(self) -> typing.Optional[presences_.MemberPresence]: """Get the cached presence for this member, if known. Presence info includes user status and activities. This requires the `GUILD_PRESENCES` intent to be enabled. Returns ------- typing.Optional[hikari.presences.MemberPresence] The member presence, or `None` if not known. """ if not isinstance(self.user.app, traits.CacheAware): return None return self.user.app.cache.get_presence(self.guild_id, self.user.id) def get_roles(self) -> typing.Sequence[Role]: """Return the roles the user has. This will be empty if the roles are missing from the cache. Returns ------- typing.Sequence[hikari.guilds.Role] The roles the users has. """ roles: typing.List[Role] = [] if not isinstance(self.user.app, traits.CacheAware): return roles for role_id in self.role_ids: if role := self.user.app.cache.get_role(role_id): roles.append(role) return roles def get_top_role(self) -> typing.Optional[Role]: """Return the highest role the member has. Returns ------- typing.Optional[hikari.guilds.Role] `None` if the cache is missing the roles information or the highest role the user has. """ roles = sorted(self.get_roles(), key=lambda r: r.position, reverse=True) try: return next(iter(roles)) except StopIteration: return None @property def username(self) -> str: return self.user.username def make_avatar_url(self, *, ext: typing.Optional[str] = None, size: int = 4096) -> typing.Optional[files.URL]: return self.user.make_avatar_url(ext=ext, size=size) def make_guild_avatar_url( self, *, ext: typing.Optional[str] = None, size: int = 4096 ) -> typing.Optional[files.URL]: """Generate the guild specific avatar url for this member, if set. If no guild avatar is set, this returns `None`. You can then use the `make_avatar_url` to get their global custom avatar or `default_avatar_url` if they have no custom avatar 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). Will be ignored for default avatars which can only be `png`. 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. Will be ignored for default avatars. Returns ------- typing.Optional[hikari.files.URL] The URL to the avatar, or `None` if not present. Raises ------ ValueError If `size` is not a power of two or not between 16 and 4096. """ if self.guild_avatar_hash is None: return None if ext is None: if self.guild_avatar_hash.startswith("a_"): ext = "gif" else: ext = "png" return routes.CDN_MEMBER_AVATAR.compile_to_file( urls.CDN_URL, guild_id=self.guild_id, user_id=self.id, hash=self.guild_avatar_hash, size=size, file_format=ext, ) async def fetch_self(self) -> Member: """Fetch an up-to-date view of this member from the API. Returns ------- hikari.guilds.Member An up-to-date view of this member. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the member 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.user.app.rest.fetch_member(self.guild_id, self.user.id) async def fetch_dm_channel(self) -> channels_.DMChannel: return await self.user.fetch_dm_channel() async def fetch_roles(self) -> typing.Sequence[Role]: """Fetch an up-to-date view of this member's roles from the API. Returns ------- typing.Sequence[hikari.guilds.Role] An up-to-date view of this member's roles. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the member 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. """ fetched_roles = await self.app.rest.fetch_roles(self.guild_id) return [role for role in fetched_roles if role.id in self.role_ids] async def ban( self, *, delete_message_days: undefined.UndefinedOr[int] = undefined.UNDEFINED, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> None: """Ban this member from this 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.user.app.rest.ban_user( self.guild_id, self.user.id, delete_message_days=delete_message_days, reason=reason ) async def unban( self, *, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> None: """Unban this member 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.user.app.rest.unban_user(self.guild_id, self.user.id, reason=reason) async def kick( self, *, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> None: """Kick this member from this 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.user.app.rest.kick_user(self.guild_id, self.user.id, reason=reason) async def add_role( self, role: snowflakes.SnowflakeishOr[PartialRole], *, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED ) -> None: """Add a role to the member. Parameters ---------- role : hikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialRole] The role to add. This may be the object or the ID of an existing role. 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 the `MANAGE_ROLES` permission. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild, user or role 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.user.app.rest.add_role_to_member(self.guild_id, self.user.id, role, reason=reason) async def remove_role( self, role: snowflakes.SnowflakeishOr[PartialRole], *, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED ) -> None: """Remove a role from the member. Parameters ---------- role : hikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialRole] The role to remove. This may be the object or the ID of an existing role. 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 the `MANAGE_ROLES` permission. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild, user or role 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.user.app.rest.remove_role_from_member(self.guild_id, self.user.id, role, reason=reason) async def edit( self, *, nickname: undefined.UndefinedNoneOr[str] = undefined.UNDEFINED, nick: undefined.UndefinedNoneOr[str] = undefined.UNDEFINED, roles: undefined.UndefinedOr[snowflakes.SnowflakeishSequence[PartialRole]] = undefined.UNDEFINED, mute: undefined.UndefinedOr[bool] = undefined.UNDEFINED, deaf: undefined.UndefinedOr[bool] = undefined.UNDEFINED, voice_channel: undefined.UndefinedNoneOr[ snowflakes.SnowflakeishOr[channels_.GuildVoiceChannel] ] = undefined.UNDEFINED, communication_disabled_until: undefined.UndefinedNoneOr[datetime.datetime] = undefined.UNDEFINED, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> Member: """Edit the member. Other Parameters ---------------- nickname : hikari.undefined.UndefinedNoneOr[str] If provided, the new nick for the member. If `None`, will remove the members nick. Requires the `MANAGE_NICKNAMES` permission. nick : hikari.undefined.UndefinedNoneOr[str] Deprecated alias for `nickname`. roles : hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishSequence[hikari.guilds.PartialRole]] If provided, the new roles for the member. Requires the `MANAGE_ROLES` permission. mute : hikari.undefined.UndefinedOr[bool] If provided, the new server mute state for the member. Requires the `MUTE_MEMBERS` permission. deaf : hikari.undefined.UndefinedOr[bool] If provided, the new server deaf state for the member. Requires the `DEAFEN_MEMBERS` permission. voice_channel : hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishOr[hikari.channels.GuildVoiceChannel]]] If provided, `None` or the object or the ID of an existing voice channel to move the member to. If `None`, will disconnect the member from voice. Requires the `MOVE_MEMBERS` permission and the `CONNECT` permission in the original voice channel and the target voice channel. .. note:: If the member is not in a voice channel, this will take no effect. communication_disabled_until : hikari.undefined.UndefinedNoneOr[datetime.datetime] If provided, the datetime when the timeout (disable communication) of the member expires, up to 28 days in the future, or `None` to remove the timeout from the member. Requires the `MODERATE_MEMBERS` permission. reason : hikari.undefined.UndefinedOr[str] If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters. Returns ------- hikari.guilds.Member Object of the member that was updated. Raises ------ hikari.errors.BadRequestError If any of the fields that are passed have an invalid value. hikari.errors.ForbiddenError If you are missing a permission to do an action. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild or the 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. """ if nick is not undefined.UNDEFINED: deprecation.warn_deprecated("nick", "Use 'nickname' argument instead") nickname = nick return await self.user.app.rest.edit_member( self.guild_id, self.user.id, nickname=nickname, roles=roles, mute=mute, deaf=deaf, voice_channel=voice_channel, communication_disabled_until=communication_disabled_until, reason=reason, ) def __str__(self) -> str: return str(self.user) def __hash__(self) -> int: return hash(self.user) def __eq__(self, other: object) -> bool: return self.user == other
Used to represent a guild bound member.
Variables and properties
The custom banner color for the user, if set else None
.
The official client will decide the default color if not set.
Alias for the accent_color
field.
Return the app that is bound to the user object.
Avatar hash for the user, if they have one, otherwise None
.
Avatar URL for the user, if they have one set.
May be None
if no custom avatar is set. In this case, you should use default_avatar_url
instead.
When the object was created.
Default avatar URL for this user.
Discriminator for the user.
Display avatar URL for this user.
Return the member's display name.
If the member has a nickname, this will return that nickname. Otherwise, it will return the username instead.
See Also
Flag bits that are set for the user.
Hash of the member's guild avatar guild if set, else None
.
Note: This takes precedence over Member.avatar_hash
.
Guild Avatar URL for the user, if they have one set.
May be None
if no guild avatar is set. In this case, you should use avatar_hash
or default_avatar_url
instead.
The ID of the guild this member belongs to.
Return the ID of this entity.
Returns
- Snowflake: The snowflake ID of this object.
Whether this user is a bot account.
True
if this member is deafened in the current voice channel.
This will be hikari.undefined.UNDEFINED
if it's state is unknown.
True
if this member is muted in the current voice channel.
This will be hikari.undefined.UNDEFINED
if it's state is unknown.
Whether the user has passed the guild's membership screening requirements.
This will be hikari.undefined.UNDEFINED
if it's state is unknown.
Whether this user is a system account.
The datetime of when this member joined the guild they belong to.
Return a raw mention string for the given member.
If the member has a known nickname, we always return a bang ("!
") before the ID part of the mention string. This mimics the behaviour Discord clients tend to provide.
Example
>>> some_member_without_nickname.mention
'<@123456789123456789>'
>>> some_member_with_nickname.mention
'<@!123456789123456789>'
This member's nickname.
This will be None
if not set.
The datetime when this member's timeout will expire.
Will be None
if the member is not timed out.
Note: The datetime might be in the past, so it is recommended to use communication_disabled_until
method to check if the member is timed out at the time of the call.
A sequence of the IDs of the member's current roles.
This member's corresponding user object.
Username for the user.
Methods
self,
*,
guild_id: hikari.snowflakes.Snowflake,
is_deaf: Union[bool, hikari.undefined.UndefinedType],
is_mute: Union[bool, hikari.undefined.UndefinedType],
is_pending: Union[bool, hikari.undefined.UndefinedType],
joined_at: datetime.datetime,
nickname: Optional[str],
premium_since: Optional[datetime.datetime],
raw_communication_disabled_until: Optional[datetime.datetime],
role_ids: Sequence[hikari.snowflakes.Snowflake],
user: hikari.users.User,
guild_avatar_hash: Optional[str]
):
View Source
def __init__(self, *, guild_id, is_deaf, is_mute, is_pending, joined_at, nickname, premium_since, raw_communication_disabled_until, role_ids, user, guild_avatar_hash): self.guild_id = guild_id self.is_deaf = is_deaf self.is_mute = is_mute self.is_pending = is_pending self.joined_at = joined_at self.nickname = nickname self.premium_since = premium_since self.raw_communication_disabled_until = raw_communication_disabled_until self.role_ids = role_ids self.user = user self.guild_avatar_hash = guild_avatar_hash
Method generated by attrs for class Member.
self,
role: Union[hikari.guilds.PartialRole, hikari.snowflakes.Snowflake, int],
*,
reason: Union[str, hikari.undefined.UndefinedType] = UNDEFINED
) -> None:
View Source
async def add_role( self, role: snowflakes.SnowflakeishOr[PartialRole], *, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED ) -> None: """Add a role to the member. Parameters ---------- role : hikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialRole] The role to add. This may be the object or the ID of an existing role. 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 the `MANAGE_ROLES` permission. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild, user or role 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.user.app.rest.add_role_to_member(self.guild_id, self.user.id, role, reason=reason)
Add a role to the member.
Parameters
- role (hikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialRole]): The role to add. This may be the object or the ID of an existing role.
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 the
MANAGE_ROLES
permission. - hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the guild, user or role 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,
*,
delete_message_days: Union[int, hikari.undefined.UndefinedType] = UNDEFINED,
reason: Union[str, hikari.undefined.UndefinedType] = UNDEFINED
) -> None:
View Source
async def ban( self, *, delete_message_days: undefined.UndefinedOr[int] = undefined.UNDEFINED, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> None: """Ban this member from this 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.user.app.rest.ban_user( self.guild_id, self.user.id, delete_message_days=delete_message_days, reason=reason )
Ban this member from this 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.
View Source
def communication_disabled_until(self) -> typing.Optional[datetime.datetime]: """Return when the timeout for this member ends. Unlike `raw_communication_disabled_until`, this will always be `None` if the member is not currently timed out. .. note:: The output of this function can depend based on when the function is called. """ if ( self.raw_communication_disabled_until is not None and self.raw_communication_disabled_until > time.utc_datetime() ): return self.raw_communication_disabled_until return None
Return when the timeout for this member ends.
Unlike raw_communication_disabled_until
, this will always be None
if the member is not currently timed out.
Note: The output of this function can depend based on when the function is called.
self,
*,
nickname: Union[str, hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
nick: Union[str, hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
roles: Union[Sequence[Union[hikari.guilds.PartialRole, hikari.snowflakes.Snowflake, int]], hikari.undefined.UndefinedType] = UNDEFINED,
mute: Union[bool, hikari.undefined.UndefinedType] = UNDEFINED,
deaf: Union[bool, hikari.undefined.UndefinedType] = UNDEFINED,
voice_channel: Union[hikari.channels.GuildVoiceChannel, hikari.snowflakes.Snowflake, int, hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
communication_disabled_until: Union[datetime.datetime, hikari.undefined.UndefinedType, NoneType] = UNDEFINED,
reason: Union[str, hikari.undefined.UndefinedType] = UNDEFINED
) -> hikari.guilds.Member:
View Source
async def edit( self, *, nickname: undefined.UndefinedNoneOr[str] = undefined.UNDEFINED, nick: undefined.UndefinedNoneOr[str] = undefined.UNDEFINED, roles: undefined.UndefinedOr[snowflakes.SnowflakeishSequence[PartialRole]] = undefined.UNDEFINED, mute: undefined.UndefinedOr[bool] = undefined.UNDEFINED, deaf: undefined.UndefinedOr[bool] = undefined.UNDEFINED, voice_channel: undefined.UndefinedNoneOr[ snowflakes.SnowflakeishOr[channels_.GuildVoiceChannel] ] = undefined.UNDEFINED, communication_disabled_until: undefined.UndefinedNoneOr[datetime.datetime] = undefined.UNDEFINED, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> Member: """Edit the member. Other Parameters ---------------- nickname : hikari.undefined.UndefinedNoneOr[str] If provided, the new nick for the member. If `None`, will remove the members nick. Requires the `MANAGE_NICKNAMES` permission. nick : hikari.undefined.UndefinedNoneOr[str] Deprecated alias for `nickname`. roles : hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishSequence[hikari.guilds.PartialRole]] If provided, the new roles for the member. Requires the `MANAGE_ROLES` permission. mute : hikari.undefined.UndefinedOr[bool] If provided, the new server mute state for the member. Requires the `MUTE_MEMBERS` permission. deaf : hikari.undefined.UndefinedOr[bool] If provided, the new server deaf state for the member. Requires the `DEAFEN_MEMBERS` permission. voice_channel : hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishOr[hikari.channels.GuildVoiceChannel]]] If provided, `None` or the object or the ID of an existing voice channel to move the member to. If `None`, will disconnect the member from voice. Requires the `MOVE_MEMBERS` permission and the `CONNECT` permission in the original voice channel and the target voice channel. .. note:: If the member is not in a voice channel, this will take no effect. communication_disabled_until : hikari.undefined.UndefinedNoneOr[datetime.datetime] If provided, the datetime when the timeout (disable communication) of the member expires, up to 28 days in the future, or `None` to remove the timeout from the member. Requires the `MODERATE_MEMBERS` permission. reason : hikari.undefined.UndefinedOr[str] If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters. Returns ------- hikari.guilds.Member Object of the member that was updated. Raises ------ hikari.errors.BadRequestError If any of the fields that are passed have an invalid value. hikari.errors.ForbiddenError If you are missing a permission to do an action. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild or the 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. """ if nick is not undefined.UNDEFINED: deprecation.warn_deprecated("nick", "Use 'nickname' argument instead") nickname = nick return await self.user.app.rest.edit_member( self.guild_id, self.user.id, nickname=nickname, roles=roles, mute=mute, deaf=deaf, voice_channel=voice_channel, communication_disabled_until=communication_disabled_until, reason=reason, )
Edit the member.
Other Parameters
nickname (hikari.undefined.UndefinedNoneOr[str]): If provided, the new nick for the member. If
None
, will remove the members nick.Requires the
MANAGE_NICKNAMES
permission.- nick (hikari.undefined.UndefinedNoneOr[str]): Deprecated alias for
nickname
. roles (hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishSequence[hikari.guilds.PartialRole]]): If provided, the new roles for the member.
Requires the
MANAGE_ROLES
permission.mute (hikari.undefined.UndefinedOr[bool]): If provided, the new server mute state for the member.
Requires the
MUTE_MEMBERS
permission.deaf (hikari.undefined.UndefinedOr[bool]): If provided, the new server deaf state for the member.
Requires the
DEAFEN_MEMBERS
permission.voice_channel (hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishOr[hikari.channels.GuildVoiceChannel]]]): If provided,
None
or the object or the ID of an existing voice channel to move the member to. IfNone
, will disconnect the member from voice.Requires the
MOVE_MEMBERS
permission and theCONNECT
permission in the original voice channel and the target voice channel.Note: If the member is not in a voice channel, this will take no effect.
communication_disabled_until (hikari.undefined.UndefinedNoneOr[datetime.datetime]): If provided, the datetime when the timeout (disable communication) of the member expires, up to 28 days in the future, or
None
to remove the timeout from the member.Requires the
MODERATE_MEMBERS
permission.- reason (hikari.undefined.UndefinedOr[str]): If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters.
Returns
- hikari.guilds.Member: Object of the member that was updated.
Raises
- hikari.errors.BadRequestError: If any of the fields that are passed have an invalid value.
- hikari.errors.ForbiddenError: If you are missing a permission to do an action.
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the guild or the 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
async def fetch_dm_channel(self) -> channels_.DMChannel: return await self.user.fetch_dm_channel()
Fetch the DM channel for this user.
Returns
- hikari.channels.DMChannel: The requested channel.
Raises
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the user 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_roles(self) -> typing.Sequence[Role]: """Fetch an up-to-date view of this member's roles from the API. Returns ------- typing.Sequence[hikari.guilds.Role] An up-to-date view of this member's roles. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the member 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. """ fetched_roles = await self.app.rest.fetch_roles(self.guild_id) return [role for role in fetched_roles if role.id in self.role_ids]
Fetch an up-to-date view of this member's roles from the API.
Returns
- typing.Sequence[hikari.guilds.Role]: An up-to-date view of this member's roles.
Raises
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the member 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) -> Member: """Fetch an up-to-date view of this member from the API. Returns ------- hikari.guilds.Member An up-to-date view of this member. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the member 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.user.app.rest.fetch_member(self.guild_id, self.user.id)
Fetch an up-to-date view of this member from the API.
Returns
- hikari.guilds.Member: An up-to-date view of this member.
Raises
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the member 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
def get_guild(self) -> typing.Optional[Guild]: """Return the guild associated with this member. Returns ------- typing.Optional[hikari.guilds.Guild] The linked guild object or `None` if it's not cached. """ if not isinstance(self.user.app, traits.CacheAware): return None return self.user.app.cache.get_guild(self.guild_id)
Return the guild associated with this member.
Returns
- typing.Optional[hikari.guilds.Guild]: The linked guild object or
None
if it's not cached.
View Source
def get_presence(self) -> typing.Optional[presences_.MemberPresence]: """Get the cached presence for this member, if known. Presence info includes user status and activities. This requires the `GUILD_PRESENCES` intent to be enabled. Returns ------- typing.Optional[hikari.presences.MemberPresence] The member presence, or `None` if not known. """ if not isinstance(self.user.app, traits.CacheAware): return None return self.user.app.cache.get_presence(self.guild_id, self.user.id)
Get the cached presence for this member, if known.
Presence info includes user status and activities.
This requires the GUILD_PRESENCES
intent to be enabled.
Returns
- typing.Optional[hikari.presences.MemberPresence]: The member presence, or
None
if not known.
View Source
def get_roles(self) -> typing.Sequence[Role]: """Return the roles the user has. This will be empty if the roles are missing from the cache. Returns ------- typing.Sequence[hikari.guilds.Role] The roles the users has. """ roles: typing.List[Role] = [] if not isinstance(self.user.app, traits.CacheAware): return roles for role_id in self.role_ids: if role := self.user.app.cache.get_role(role_id): roles.append(role) return roles
Return the roles the user has.
This will be empty if the roles are missing from the cache.
Returns
- typing.Sequence[hikari.guilds.Role]: The roles the users has.
View Source
def get_top_role(self) -> typing.Optional[Role]: """Return the highest role the member has. Returns ------- typing.Optional[hikari.guilds.Role] `None` if the cache is missing the roles information or the highest role the user has. """ roles = sorted(self.get_roles(), key=lambda r: r.position, reverse=True) try: return next(iter(roles)) except StopIteration: return None
Return the highest role the member has.
Returns
- typing.Optional[hikari.guilds.Role]:
None
if the cache is missing the roles information or the highest role the user has.
View Source
async def kick( self, *, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> None: """Kick this member from this 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.user.app.rest.kick_user(self.guild_id, self.user.id, reason=reason)
Kick this member from this 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_avatar_url(self, *, ext: typing.Optional[str] = None, size: int = 4096) -> typing.Optional[files.URL]: return self.user.make_avatar_url(ext=ext, size=size)
Generate the avatar URL for this user, if set.
If no custom avatar is set, this returns None
. You can then use the default_avatar_url
attribute instead to fetch the displayed URL.
Parameters
ext (typing.Optional[str]): The ext to use for this URL, defaults to
png
orgif
. Supportspng
,jpeg
,jpg
,webp
andgif
(when animated). Will be ignored for default avatars which can only bepng
.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. Will be ignored for default avatars.
Returns
- typing.Optional[hikari.files.URL]: The URL to the avatar, or
None
if not present.
Raises
- ValueError: If
size
is not a power of two or not between 16 and 4096.
self,
*,
ext: Optional[str] = None,
size: int = 4096
) -> Optional[hikari.files.URL]:
View Source
def make_guild_avatar_url( self, *, ext: typing.Optional[str] = None, size: int = 4096 ) -> typing.Optional[files.URL]: """Generate the guild specific avatar url for this member, if set. If no guild avatar is set, this returns `None`. You can then use the `make_avatar_url` to get their global custom avatar or `default_avatar_url` if they have no custom avatar 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). Will be ignored for default avatars which can only be `png`. 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. Will be ignored for default avatars. Returns ------- typing.Optional[hikari.files.URL] The URL to the avatar, or `None` if not present. Raises ------ ValueError If `size` is not a power of two or not between 16 and 4096. """ if self.guild_avatar_hash is None: return None if ext is None: if self.guild_avatar_hash.startswith("a_"): ext = "gif" else: ext = "png" return routes.CDN_MEMBER_AVATAR.compile_to_file( urls.CDN_URL, guild_id=self.guild_id, user_id=self.id, hash=self.guild_avatar_hash, size=size, file_format=ext, )
Generate the guild specific avatar url for this member, if set.
If no guild avatar is set, this returns None
. You can then use the make_avatar_url
to get their global custom avatar or default_avatar_url
if they have no custom avatar set.
Parameters
ext (typing.Optional[str]): The ext to use for this URL, defaults to
png
orgif
. Supportspng
,jpeg
,jpg
,webp
andgif
(when animated). Will be ignored for default avatars which can only bepng
.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. Will be ignored for default avatars.
Returns
- typing.Optional[hikari.files.URL]: The URL to the avatar, or
None
if not present.
Raises
- ValueError: If
size
is not a power of two or not between 16 and 4096.
self,
role: Union[hikari.guilds.PartialRole, hikari.snowflakes.Snowflake, int],
*,
reason: Union[str, hikari.undefined.UndefinedType] = UNDEFINED
) -> None:
View Source
async def remove_role( self, role: snowflakes.SnowflakeishOr[PartialRole], *, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED ) -> None: """Remove a role from the member. Parameters ---------- role : hikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialRole] The role to remove. This may be the object or the ID of an existing role. 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 the `MANAGE_ROLES` permission. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild, user or role 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.user.app.rest.remove_role_from_member(self.guild_id, self.user.id, role, reason=reason)
Remove a role from the member.
Parameters
- role (hikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialRole]): The role to remove. This may be the object or the ID of an existing role.
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 the
MANAGE_ROLES
permission. - hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the guild, user or role 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,
content: Union[Any, hikari.undefined.UndefinedType] = UNDEFINED,
*,
attachment: Union[hikari.files.Resource[Any], os.PathLike[str], str, bytes, bytearray, memoryview, _io.BytesIO, _io.StringIO, hikari.undefined.UndefinedType] = UNDEFINED,
attachments: Union[Sequence[Union[hikari.files.Resource[Any], os.PathLike[str], str, bytes, bytearray, memoryview, _io.BytesIO, _io.StringIO]], hikari.undefined.UndefinedType] = UNDEFINED,
component: Union[hikari.api.special_endpoints.ComponentBuilder, hikari.undefined.UndefinedType] = UNDEFINED,
components: Union[Sequence[hikari.api.special_endpoints.ComponentBuilder], hikari.undefined.UndefinedType] = UNDEFINED,
embed: Union[hikari.embeds.Embed, hikari.undefined.UndefinedType] = UNDEFINED,
embeds: Union[Sequence[hikari.embeds.Embed], hikari.undefined.UndefinedType] = UNDEFINED,
tts: Union[bool, hikari.undefined.UndefinedType] = UNDEFINED,
reply: Union[hikari.messages.PartialMessage, hikari.snowflakes.Snowflake, int, hikari.undefined.UndefinedType] = UNDEFINED,
mentions_everyone: Union[bool, hikari.undefined.UndefinedType] = UNDEFINED,
mentions_reply: Union[bool, hikari.undefined.UndefinedType] = UNDEFINED,
user_mentions: Union[Sequence[Union[hikari.users.PartialUser, hikari.snowflakes.Snowflake, int]], bool, hikari.undefined.UndefinedType] = UNDEFINED,
role_mentions: Union[Sequence[Union[hikari.guilds.PartialRole, hikari.snowflakes.Snowflake, int]], bool, hikari.undefined.UndefinedType] = UNDEFINED
) -> hikari.messages.Message:
View Source
async def send( self, content: undefined.UndefinedOr[typing.Any] = undefined.UNDEFINED, *, attachment: undefined.UndefinedOr[files.Resourceish] = undefined.UNDEFINED, attachments: undefined.UndefinedOr[typing.Sequence[files.Resourceish]] = undefined.UNDEFINED, component: undefined.UndefinedOr[special_endpoints.ComponentBuilder] = undefined.UNDEFINED, components: undefined.UndefinedOr[typing.Sequence[special_endpoints.ComponentBuilder]] = undefined.UNDEFINED, embed: undefined.UndefinedOr[embeds_.Embed] = undefined.UNDEFINED, embeds: undefined.UndefinedOr[typing.Sequence[embeds_.Embed]] = undefined.UNDEFINED, tts: undefined.UndefinedOr[bool] = undefined.UNDEFINED, reply: undefined.UndefinedOr[snowflakes.SnowflakeishOr[messages.PartialMessage]] = undefined.UNDEFINED, mentions_everyone: undefined.UndefinedOr[bool] = undefined.UNDEFINED, mentions_reply: undefined.UndefinedOr[bool] = undefined.UNDEFINED, user_mentions: undefined.UndefinedOr[ typing.Union[snowflakes.SnowflakeishSequence[PartialUser], bool] ] = undefined.UNDEFINED, role_mentions: undefined.UndefinedOr[ typing.Union[snowflakes.SnowflakeishSequence[guilds.PartialRole], bool] ] = undefined.UNDEFINED, ) -> messages.Message: """Send a message to this user in DM's. Parameters ---------- content : hikari.undefined.UndefinedOr[typing.Any] If provided, the message contents. If `hikari.undefined.UNDEFINED`, then nothing will be sent in the content. Any other value here will be cast to a `str`. If this is a `hikari.embeds.Embed` and no `embed` nor `embeds` kwarg is provided, then this will instead update the embed. This allows for simpler syntax when sending an embed alone. Likewise, if this is a `hikari.files.Resource`, then the content is instead treated as an attachment if no `attachment` and no `attachments` kwargs are provided. Other Parameters ---------------- attachment : hikari.undefined.UndefinedOr[hikari.files.Resourceish], If provided, the message attachment. This can be a resource, or string of a path on your computer or a URL. Attachments can be passed as many different things, to aid in convenience. - If a `pathlib.PurePath` or `str` to a valid URL, the resource at the given URL will be streamed to Discord when sending the message. Subclasses of `hikari.files.WebResource` such as `hikari.files.URL`, `hikari.messages.Attachment`, `hikari.emojis.Emoji`, `EmbedResource`, etc will also be uploaded this way. This will use bit-inception, so only a small percentage of the resource will remain in memory at any one time, thus aiding in scalability. - If a `hikari.files.Bytes` is passed, or a `str` that contains a valid data URI is passed, then this is uploaded with a randomized file name if not provided. - If a `hikari.files.File`, `pathlib.PurePath` or `str` that is an absolute or relative path to a file on your file system is passed, then this resource is uploaded as an attachment using non-blocking code internally and streamed using bit-inception where possible. This depends on the type of `concurrent.futures.Executor` that is being used for the application (default is a thread pool which supports this behaviour). attachments : hikari.undefined.UndefinedOr[typing.Sequence[hikari.files.Resourceish]], If provided, the message attachments. These can be resources, or strings consisting of paths on your computer or URLs. component : hikari.undefined.UndefinedOr[hikari.api.special_endpoints.ComponentBuilder] If provided, builder object of the component to include in this message. components : hikari.undefined.UndefinedOr[typing.Sequence[hikari.api.special_endpoints.ComponentBuilder]] If provided, a sequence of the component builder objects to include in this message. embed : hikari.undefined.UndefinedOr[hikari.embeds.Embed] If provided, the message embed. embeds : hikari.undefined.UndefinedOr[typing.Sequence[hikari.embeds.Embed]] If provided, the message embeds. tts : hikari.undefined.UndefinedOr[bool] If provided, whether the message will be read out by a screen reader using Discord's TTS (text-to-speech) system. reply : hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishOr[hikari.messages.PartialMessage]] If provided, the message to reply to. mentions_everyone : hikari.undefined.UndefinedOr[bool] If provided, whether the message should parse @everyone/@here mentions. mentions_reply : hikari.undefined.UndefinedOr[bool] If provided, whether to mention the author of the message that is being replied to. This will not do anything if not being used with `reply`. user_mentions : hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.users.PartialUser], bool]] If provided, and `True`, all user mentions will be detected. If provided, and `False`, all user mentions will be ignored if appearing in the message body. Alternatively this may be a collection of `hikari.snowflakes.Snowflake`, or `hikari.users.PartialUser` derivatives to enforce mentioning specific users. role_mentions : hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.guilds.PartialRole], bool]] If provided, and `True`, all role mentions will be detected. If provided, and `False`, all role mentions will be ignored if appearing in the message body. Alternatively this may be a collection of `hikari.snowflakes.Snowflake`, or `hikari.guilds.PartialRole` derivatives to enforce mentioning specific roles. Returns ------- hikari.messages.Message The created message. Raises ------ ValueError If more than 100 unique objects/entities are passed for `role_mentions` or `user_mentions`. TypeError If both `attachment` and `attachments` are specified. hikari.errors.BadRequestError This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; invalid image URLs in embeds; `reply` not found or not in the same channel; too many components. hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `SEND_MESSAGES` in the channel or the person you are trying to message has the DM's disabled. hikari.errors.NotFoundError If the user 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 channel_id = None if isinstance(self.app, traits.CacheAware): channel_id = self.app.cache.get_dm_channel_id(self.id) if channel_id is None: channel_id = (await self.fetch_dm_channel()).id return await self.app.rest.create_message( channel=channel_id, content=content, attachment=attachment, attachments=attachments, component=component, components=components, embed=embed, embeds=embeds, tts=tts, reply=reply, mentions_everyone=mentions_everyone, user_mentions=user_mentions, role_mentions=role_mentions, mentions_reply=mentions_reply, )
Send a message to this user in DM's.
Parameters
content (hikari.undefined.UndefinedOr[typing.Any]): If provided, the message contents. If
hikari.undefined.UNDEFINED
, then nothing will be sent in the content. Any other value here will be cast to astr
.If this is a
hikari.embeds.Embed
and noembed
norembeds
kwarg is provided, then this will instead update the embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a
hikari.files.Resource
, then the content is instead treated as an attachment if noattachment
and noattachments
kwargs are provided.
Other Parameters
attachment (hikari.undefined.UndefinedOr[hikari.files.Resourceish],): If provided, the message attachment. This can be a resource, or string of a path on your computer or a URL.
Attachments can be passed as many different things, to aid in convenience.
- If a
pathlib.PurePath
orstr
to a valid URL, the resource at the given URL will be streamed to Discord when sending the message. Subclasses ofhikari.files.WebResource
such ashikari.files.URL
,hikari.messages.Attachment
,hikari.emojis.Emoji
,EmbedResource
, etc will also be uploaded this way. This will use bit-inception, so only a small percentage of the resource will remain in memory at any one time, thus aiding in scalability. - If a
hikari.files.Bytes
is passed, or astr
that contains a valid data URI is passed, then this is uploaded with a randomized file name if not provided. - If a
hikari.files.File
,pathlib.PurePath
orstr
that is an absolute or relative path to a file on your file system is passed, then this resource is uploaded as an attachment using non-blocking code internally and streamed using bit-inception where possible. This depends on the type ofconcurrent.futures.Executor
that is being used for the application (default is a thread pool which supports this behaviour).
- If a
- attachments (hikari.undefined.UndefinedOr[typing.Sequence[hikari.files.Resourceish]],): If provided, the message attachments. These can be resources, or strings consisting of paths on your computer or URLs.
- component (hikari.undefined.UndefinedOr[hikari.api.special_endpoints.ComponentBuilder]): If provided, builder object of the component to include in this message.
- components (hikari.undefined.UndefinedOr[typing.Sequence[hikari.api.special_endpoints.ComponentBuilder]]): If provided, a sequence of the component builder objects to include in this message.
- embed (hikari.undefined.UndefinedOr[hikari.embeds.Embed]): If provided, the message embed.
- embeds (hikari.undefined.UndefinedOr[typing.Sequence[hikari.embeds.Embed]]): If provided, the message embeds.
- tts (hikari.undefined.UndefinedOr[bool]): If provided, whether the message will be read out by a screen reader using Discord's TTS (text-to-speech) system.
- reply (hikari.undefined.UndefinedOr[hikari.snowflakes.SnowflakeishOr[hikari.messages.PartialMessage]]): If provided, the message to reply to.
- mentions_everyone (hikari.undefined.UndefinedOr[bool]): If provided, whether the message should parse @everyone/@here mentions.
mentions_reply (hikari.undefined.UndefinedOr[bool]): If provided, whether to mention the author of the message that is being replied to.
This will not do anything if not being used with
reply
.- user_mentions (hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.users.PartialUser], bool]]): If provided, and
True
, all user mentions will be detected. If provided, andFalse
, all user mentions will be ignored if appearing in the message body. Alternatively this may be a collection ofhikari.snowflakes.Snowflake
, orhikari.users.PartialUser
derivatives to enforce mentioning specific users. - role_mentions (hikari.undefined.UndefinedOr[typing.Union[hikari.snowflakes.SnowflakeishSequence[hikari.guilds.PartialRole], bool]]): If provided, and
True
, all role mentions will be detected. If provided, andFalse
, all role mentions will be ignored if appearing in the message body. Alternatively this may be a collection ofhikari.snowflakes.Snowflake
, orhikari.guilds.PartialRole
derivatives to enforce mentioning specific roles.
Returns
- hikari.messages.Message: The created message.
Raises
- ValueError: If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
. - TypeError: If both
attachment
andattachments
are specified. - hikari.errors.BadRequestError: This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; invalid image URLs in embeds;
reply
not found or not in the same channel; too many components. - hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.ForbiddenError: If you are missing the
SEND_MESSAGES
in the channel or the person you are trying to message has the DM's disabled. - hikari.errors.NotFoundError: If the user 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,
*,
reason: Union[str, hikari.undefined.UndefinedType] = UNDEFINED
) -> None:
View Source
async def unban( self, *, reason: undefined.UndefinedOr[str] = undefined.UNDEFINED, ) -> None: """Unban this member 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.user.app.rest.unban_user(self.guild_id, self.user.id, reason=reason)
Unban this member 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_extensions.with_copy @attr.define(hash=True, kw_only=True, weakref_slot=False) class PartialApplication(snowflakes.Unique): """A partial representation of a Discord application.""" id: snowflakes.Snowflake = attr.field(hash=True, repr=True) """The ID of this entity.""" name: str = attr.field(eq=False, hash=False, repr=True) """The name of this application.""" description: typing.Optional[str] = attr.field(eq=False, hash=False, repr=False) """The description of this application, if any.""" icon_hash: typing.Optional[str] = attr.field(eq=False, hash=False, repr=False) """The CDN hash of this application's icon, if set.""" def __str__(self) -> str: return self.name @property def icon_url(self) -> typing.Optional[files.URL]: """Team icon URL, if there is one.""" return self.make_icon_url() def make_icon_url(self, *, ext: str = "png", size: int = 4096) -> typing.Optional[files.URL]: """Generate the icon URL for this application. 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, or `None` if no icon exists. Raises ------ ValueError If the size is not an integer power of 2 between 16 and 4096 (inclusive). """ if self.icon_hash is None: return None return routes.CDN_APPLICATION_ICON.compile_to_file( urls.CDN_URL, application_id=self.id, hash=self.icon_hash, size=size, file_format=ext, )
A partial representation of a Discord application.
Variables and properties
When the object was created.
The description of this application, if any.
The CDN hash of this application's icon, if set.
Team icon URL, if there is one.
The ID of this entity.
The name of this application.
Methods
self,
*,
id: hikari.snowflakes.Snowflake,
name: str,
description: Optional[str],
icon_hash: Optional[str]
):
View Source
def __init__(self, *, id, name, description, icon_hash): self.id = id self.name = name self.description = description self.icon_hash = icon_hash
Method generated by attrs for class PartialApplication.
View Source
def make_icon_url(self, *, ext: str = "png", size: int = 4096) -> typing.Optional[files.URL]: """Generate the icon URL for this application. 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, or `None` if no icon exists. Raises ------ ValueError If the size is not an integer power of 2 between 16 and 4096 (inclusive). """ if self.icon_hash is None: return None return routes.CDN_APPLICATION_ICON.compile_to_file( urls.CDN_URL, application_id=self.id, hash=self.icon_hash, size=size, file_format=ext, )
Generate the icon URL for this application.
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, or
None
if no icon exists.
Raises
- ValueError: If the size is not an integer power of 2 between 16 and 4096 (inclusive).
View Source
@attr_extensions.with_copy @attr.define(hash=True, kw_only=True, weakref_slot=False) class PartialGuild(snowflakes.Unique): """Base object for any partial guild objects.""" 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.""" id: snowflakes.Snowflake = attr.field(hash=True, repr=True) """The ID of this entity.""" icon_hash: typing.Optional[str] = attr.field(eq=False, hash=False, repr=False) """The hash for the guild icon, if there is one.""" name: str = attr.field(eq=False, hash=False, repr=True) """The name of the guild.""" def __str__(self) -> str: return self.name @property def icon_url(self) -> typing.Optional[files.URL]: """Icon URL for the guild, if set; otherwise `None`.""" return self.make_icon_url() @property def shard_id(self) -> typing.Optional[int]: """Return the ID of the shard this guild is served by. This may return `None` if the application does not have a gateway connection. """ if not isinstance(self.app, traits.ShardAware): return None shard_count = self.app.shard_count assert isinstance(shard_count, int) return snowflakes.calculate_shard_id(shard_count, self.id) 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, ) 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) 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) 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) 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, ) 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) 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) 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) 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) 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) 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 ) 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) 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 ) 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, ) 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, ) 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, ) 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, ) 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 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) 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)
Base object for any partial guild objects.
Variables and properties
The client application that models may use for procedures.
When the object was created.
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.
Return the ID of the shard this guild is served by.
This may return None
if the application does not have a gateway connection.
Methods
self,
*,
app: hikari.traits.RESTAware,
id: hikari.snowflakes.Snowflake,
icon_hash: Optional[str],
name: str
):
View Source
def __init__(self, *, app, id, icon_hash, name): self.app = app self.id = id self.icon_hash = icon_hash self.name = name
Method generated by attrs for class PartialGuild.
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.
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_extensions.with_copy @attr.define(hash=True, kw_only=True, weakref_slot=False) class PartialIntegration(snowflakes.Unique): """A partial representation of an integration, found in audit logs.""" account: IntegrationAccount = attr.field(eq=False, hash=False, repr=False) """The account connected to this integration.""" id: snowflakes.Snowflake = attr.field(hash=True, repr=True) """The ID of this entity.""" name: str = attr.field(eq=False, hash=False, repr=True) """The name of this integration.""" type: typing.Union[IntegrationType, str] = attr.field(eq=False, hash=False, repr=True) """The type of this integration.""" def __str__(self) -> str: return self.name
A partial representation of an integration, found in audit logs.
Variables and properties
The account connected to this integration.
When the object was created.
The ID of this entity.
The name of this integration.
The type of this integration.
Methods
self,
*,
account: hikari.guilds.IntegrationAccount,
id: hikari.snowflakes.Snowflake,
name: str,
type: Union[hikari.guilds.IntegrationType, str]
):
View Source
def __init__(self, *, account, id, name, type): self.account = account self.id = id self.name = name self.type = type
Method generated by attrs for class PartialIntegration.
View Source
@attr_extensions.with_copy @attr.define(hash=True, kw_only=True, weakref_slot=False) class PartialRole(snowflakes.Unique): """Represents a partial guild bound role object.""" 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.""" id: snowflakes.Snowflake = attr.field(hash=True, repr=True) """The ID of this entity.""" name: str = attr.field(eq=False, hash=False, repr=True) """The role's name.""" @property def mention(self) -> str: """Return a raw mention string for the role.""" return f"<@&{self.id}>" def __str__(self) -> str: return self.name
Represents a partial guild bound role object.
Variables and properties
The client application that models may use for procedures.
When the object was created.
The ID of this entity.
Return a raw mention string for the role.
The role's name.
Methods
View Source
def __init__(self, *, app, id, name): self.app = app self.id = id self.name = name
Method generated by attrs for class PartialRole.
View Source
@attr.define(hash=True, kw_only=True, weakref_slot=False) class RESTGuild(Guild): """Guild specialization that is sent via the REST API only.""" emojis: typing.Mapping[snowflakes.Snowflake, emojis_.KnownCustomEmoji] = attr.field( eq=False, hash=False, repr=False ) """A mapping of emoji IDs to the objects of the emojis this guild provides.""" roles: typing.Mapping[snowflakes.Snowflake, Role] = attr.field(eq=False, hash=False, repr=False) """The roles in this guild, represented as a mapping of role ID to role object.""" approximate_active_member_count: typing.Optional[int] = attr.field(eq=False, hash=False, repr=False) """The approximate number of members in the guild that are not offline. This will be `None` when creating a guild. """ approximate_member_count: typing.Optional[int] = attr.field(eq=False, hash=False, repr=False) """The approximate number of members in the guild. This will be `None` when creating a guild. """ max_presences: typing.Optional[int] = attr.field(eq=False, hash=False, repr=False) """The maximum number of presences for the guild. If `None`, then there is no limit. """ max_members: int = attr.field(eq=False, hash=False, repr=False) """The maximum number of members allowed in this guild."""
Guild specialization that is sent via the REST API only.
Variables and properties
The ID for the channel that AFK voice users get sent to.
If None
, then no AFK channel is set up for this guild.
Timeout for activity before a member is classed as AFK.
How long a voice user has to be AFK for before they are classed as being AFK and are moved to the AFK channel (Guild.afk_channel_id
).
The client application that models may use for procedures.
The ID of the application that created this guild.
This will always be None
for guilds that weren't created by a bot.
The approximate number of members in the guild that are not offline.
This will be None
when creating a guild.
The approximate number of members in the guild.
This will be None
when creating a guild.
When the object was created.
The default setting for message notifications in this guild.
The guild's description.
This is only present if certain GuildFeature
's are set in Guild.features
for this guild. Otherwise, this will always be None
.
The hash of the discovery splash for the guild, if there is one.
Discovery splash URL for the guild, if set.
A mapping of emoji IDs to the objects of the emojis this guild provides.
The setting for the explicit content filter in this guild.
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.
Describes whether the guild widget is enabled or not.
If this information is not present, this will be None
.
The maximum number of members allowed in this guild.
The maximum number of presences for the guild.
If None
, then there is no limit.
The maximum number of users allowed in a video channel together.
This information may not be present, in which case, it will be None
.
The required MFA level for users wishing to participate in this guild.
The name of the guild.
The NSFW level of the guild.
The ID of the owner of this guild.
The preferred locale to use for this guild.
This can only be change if GuildFeature.COMMUNITY
is in Guild.features
for this guild and will otherwise default to en-US
.
The channel ID of the channel where admins and moderators receive notices from Discord.
This is only present if GuildFeature.COMMUNITY
is in Guild.features
for this guild. For all other purposes, it should be considered to be None
.
The roles in this guild, represented as a mapping of role ID to role object.
The ID of the channel where guilds with the GuildFeature.COMMUNITY
features
display rules and guidelines.
If the GuildFeature.COMMUNITY
feature is not defined, then this is None
.
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.
Return flags for the guild system channel.
These are used to describe which notifications are suppressed.
The ID of the system channel or None
if it is not enabled.
Welcome messages and Nitro boost messages may be sent to this channel.
The vanity URL code for the guild's vanity URL.
This is only present if GuildFeature.VANITY_URL
is in Guild.features
for this guild. If not, this will always be None
.
The verification level needed for a user to participate in this guild.
The channel ID that the widget's generated invite will send the user to.
If this information is unavailable or this is not enabled for the guild then this will be None
.
Methods
self,
*,
app: hikari.traits.RESTAware,
id: hikari.snowflakes.Snowflake,
icon_hash: Optional[str],
name: str,
features: Sequence[Union[str, hikari.guilds.GuildFeature]],
application_id: Optional[hikari.snowflakes.Snowflake],
afk_channel_id: Optional[hikari.snowflakes.Snowflake],
afk_timeout: datetime.timedelta,
banner_hash: Optional[str],
default_message_notifications: Union[hikari.guilds.GuildMessageNotificationsLevel, int],
description: Optional[str],
discovery_splash_hash: Optional[str],
explicit_content_filter: Union[hikari.guilds.GuildExplicitContentFilterLevel, int],
is_widget_enabled: Optional[bool],
max_video_channel_users: Optional[int],
mfa_level: Union[hikari.guilds.GuildMFALevel, int],
owner_id: hikari.snowflakes.Snowflake,
preferred_locale: Union[str, hikari.locales.Locale],
premium_subscription_count: Optional[int],
premium_tier: Union[hikari.guilds.GuildPremiumTier, int],
public_updates_channel_id: Optional[hikari.snowflakes.Snowflake],
rules_channel_id: Optional[hikari.snowflakes.Snowflake],
splash_hash: Optional[str],
system_channel_flags: hikari.guilds.GuildSystemChannelFlag,
system_channel_id: Optional[hikari.snowflakes.Snowflake],
vanity_url_code: Optional[str],
verification_level: Union[hikari.guilds.GuildVerificationLevel, int],
widget_channel_id: Optional[hikari.snowflakes.Snowflake],
nsfw_level: hikari.guilds.GuildNSFWLevel,
emojis: Mapping[hikari.snowflakes.Snowflake, hikari.emojis.KnownCustomEmoji],
roles: Mapping[hikari.snowflakes.Snowflake, hikari.guilds.Role],
approximate_active_member_count: Optional[int],
approximate_member_count: Optional[int],
max_presences: Optional[int],
max_members: int
):
View Source
def __init__(self, *, app, id, icon_hash, name, features, application_id, afk_channel_id, afk_timeout, banner_hash, default_message_notifications, description, discovery_splash_hash, explicit_content_filter, is_widget_enabled, max_video_channel_users, mfa_level, owner_id, preferred_locale, premium_subscription_count, premium_tier, public_updates_channel_id, rules_channel_id, splash_hash, system_channel_flags, system_channel_id, vanity_url_code, verification_level, widget_channel_id, nsfw_level, emojis, roles, approximate_active_member_count, approximate_member_count, max_presences, max_members): self.app = app self.id = id self.icon_hash = icon_hash self.name = name self.features = features self.application_id = application_id self.afk_channel_id = afk_channel_id self.afk_timeout = afk_timeout self.banner_hash = banner_hash self.default_message_notifications = default_message_notifications self.description = description self.discovery_splash_hash = discovery_splash_hash self.explicit_content_filter = explicit_content_filter self.is_widget_enabled = is_widget_enabled self.max_video_channel_users = max_video_channel_users self.mfa_level = mfa_level self.owner_id = owner_id self.preferred_locale = preferred_locale self.premium_subscription_count = premium_subscription_count self.premium_tier = premium_tier self.public_updates_channel_id = public_updates_channel_id self.rules_channel_id = rules_channel_id self.splash_hash = splash_hash self.system_channel_flags = system_channel_flags self.system_channel_id = system_channel_id self.vanity_url_code = vanity_url_code self.verification_level = verification_level self.widget_channel_id = widget_channel_id self.nsfw_level = nsfw_level self.emojis = emojis self.roles = roles self.approximate_active_member_count = approximate_active_member_count self.approximate_member_count = approximate_member_count self.max_presences = max_presences self.max_members = max_members
Method generated by attrs for class RESTGuild.
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.
View Source
async def fetch_afk_channel(self) -> typing.Optional[channels_.GuildVoiceChannel]: """Fetch the channel that AFK voice users get sent to. Returns ------- typing.Optional[hikari.channels.GuildVoiceChannel] The AFK channel or `None` if not enabled. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `READ_MESSAGES` 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. """ if not self.afk_channel_id: return None afk_channel = await self.app.rest.fetch_channel(self.afk_channel_id) assert isinstance(afk_channel, channels_.GuildVoiceChannel) return afk_channel
Fetch the channel that AFK voice users get sent to.
Returns
- typing.Optional[hikari.channels.GuildVoiceChannel]: The AFK channel or
None
if not enabled.
Raises
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.ForbiddenError: If you are missing the
READ_MESSAGES
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,
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_owner(self) -> Member: """Fetch the owner of the guild. Returns ------- hikari.guilds.Member The guild owner. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.NotFoundError If the guild or the 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. """ return await self.app.rest.fetch_member(self.id, self.owner_id)
Fetch the owner of the guild.
Returns
- hikari.guilds.Member: The guild owner.
Raises
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.NotFoundError: If the guild or the 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
async def fetch_public_updates_channel(self) -> typing.Optional[channels_.GuildTextChannel]: """Fetch channel ID of the channel where admins and moderators receive notices from Discord. This is only present if `GuildFeature.COMMUNITY` is in `Guild.features` for this guild. For all other purposes, it should be considered to be `None`. Returns ------- typing.Optional[hikari.channels.GuildTextChannel] The channel where discord sends relevant updates to moderators and admins. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `READ_MESSAGES` 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. """ if not self.public_updates_channel_id: return None updates_channel = await self.app.rest.fetch_channel(self.public_updates_channel_id) assert isinstance(updates_channel, channels_.GuildTextChannel) return updates_channel
Fetch channel ID of the channel where admins and moderators receive notices from Discord.
This is only present if GuildFeature.COMMUNITY
is in Guild.features
for this guild. For all other purposes, it should be considered to be None
.
Returns
- typing.Optional[hikari.channels.GuildTextChannel]: The channel where discord sends relevant updates to moderators and admins.
Raises
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.ForbiddenError: If you are missing the
READ_MESSAGES
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.
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_rules_channel(self) -> typing.Optional[channels_.GuildTextChannel]: """Fetch the channel where guilds display rules and guidelines. If the `GuildFeature.COMMUNITY` feature is not defined, then this is `None`. Returns ------- typing.Optional[hikari.channels.GuildTextChannel] The channel where the rules of the guild are specified or else `None`. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `READ_MESSAGES` 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. """ if not self.rules_channel_id: return None rules_channel = await self.app.rest.fetch_channel(self.rules_channel_id) assert isinstance(rules_channel, channels_.GuildTextChannel) return rules_channel
Fetch the channel where guilds display rules and guidelines.
If the GuildFeature.COMMUNITY
feature is not defined, then this is None
.
Returns
- typing.Optional[hikari.channels.GuildTextChannel]: The channel where the rules of the guild are specified or else
None
.
Raises
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.ForbiddenError: If you are missing the
READ_MESSAGES
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.
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.
View Source
async def fetch_system_channel(self) -> typing.Optional[channels_.GuildTextChannel]: """Fetch the system channel. Returns ------- typing.Optional[hikari.channels.GuildTextChannel] The system channel for this guild or `None` if not enabled. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `READ_MESSAGES` 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. """ if not self.system_channel_id: return None system_channel = await self.app.rest.fetch_channel(self.system_channel_id) assert isinstance(system_channel, channels_.GuildTextChannel) return system_channel
Fetch the system channel.
Returns
- typing.Optional[hikari.channels.GuildTextChannel]: The system channel for this guild or
None
if not enabled.
Raises
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.ForbiddenError: If you are missing the
READ_MESSAGES
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.
View Source
async def fetch_widget_channel(self) -> typing.Optional[channels_.GuildChannel]: """Fetch the widget channel. This will be `None` if not set. Returns ------- typing.Optional[hikari.channels.GuildChannel] The channel the widget is linked to or else `None`. Raises ------ hikari.errors.UnauthorizedError If you are unauthorized to make the request (invalid/missing token). hikari.errors.ForbiddenError If you are missing the `READ_MESSAGES` 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. """ if not self.widget_channel_id: return None widget_channel = await self.app.rest.fetch_channel(self.widget_channel_id) assert isinstance(widget_channel, channels_.GuildChannel) return widget_channel
Fetch the widget channel.
This will be None
if not set.
Returns
- typing.Optional[hikari.channels.GuildChannel]: The channel the widget is linked to or else
None
.
Raises
- hikari.errors.UnauthorizedError: If you are unauthorized to make the request (invalid/missing token).
- hikari.errors.ForbiddenError: If you are missing the
READ_MESSAGES
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,
channel: Union[hikari.channels.PartialChannel, hikari.snowflakes.Snowflake, int]
) -> Optional[hikari.channels.GuildChannel]:
View Source
def get_channel( self, channel: snowflakes.SnowflakeishOr[channels_.PartialChannel], ) -> typing.Optional[channels_.GuildChannel]: """Get a cached channel that belongs to the guild by it's ID or object. Parameters ---------- channel : hikari.snowflakes.SnowflakeishOr[hikari.channels.PartialChannel] The object or ID of the guild channel to get from the cache. Returns ------- typing.Optional[hikari.channels.GuildChannel] The object of the guild channel found in cache or `None. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_guild_channel(channel)
Get a cached channel that belongs to the guild by it's ID or object.
Parameters
- channel (hikari.snowflakes.SnowflakeishOr[hikari.channels.PartialChannel]): The object or ID of the guild channel to get from the cache.
Returns
- typing.Optional[hikari.channels.GuildChannel]: The object of the guild channel found in cache or `None.
View Source
def get_channels(self) -> typing.Mapping[snowflakes.Snowflake, channels_.GuildChannel]: """Get the channels cached for the guild. Returns ------- typing.Mapping[hikari.snowflakes.Snowflake, hikari.channels.GuildChannel] A mapping of channel IDs to objects of the channels cached for the guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_guild_channels_view_for_guild(self.id)
Get the channels cached for the guild.
Returns
- typing.Mapping[hikari.snowflakes.Snowflake, hikari.channels.GuildChannel]: A mapping of channel IDs to objects of the channels cached for the guild.
self,
emoji: Union[hikari.emojis.CustomEmoji, hikari.snowflakes.Snowflake, int]
) -> Optional[hikari.emojis.KnownCustomEmoji]:
View Source
def get_emoji( self, emoji: snowflakes.SnowflakeishOr[emojis_.CustomEmoji] ) -> typing.Optional[emojis_.KnownCustomEmoji]: """Get a cached emoji that belongs to the guild by it's ID or object. Parameters ---------- emoji : hikari.snowflakes.SnowflakeishOr[hikari.emojis.CustomEmoji] The object or ID of the emoji to get from the cache. Returns ------- typing.Optional[hikari.emojis.KnownCustomEmoji] The object of the custom emoji if found in cache, else `None`. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_emoji(emoji)
Get a cached emoji that belongs to the guild by it's ID or object.
Parameters
- emoji (hikari.snowflakes.SnowflakeishOr[hikari.emojis.CustomEmoji]): The object or ID of the emoji to get from the cache.
Returns
- typing.Optional[hikari.emojis.KnownCustomEmoji]: The object of the custom emoji if found in cache, else
None
.
View Source
def get_emojis(self) -> typing.Mapping[snowflakes.Snowflake, emojis_.KnownCustomEmoji]: """Return the emojis in this guild. Returns ------- typing.Mapping[hikari.snowflakes.Snowflake, hikari.emojis.KnownCustomEmoji] A mapping of emoji IDs to the objects of emojis in this guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_emojis_view_for_guild(self.id)
Return the emojis in this guild.
Returns
- typing.Mapping[hikari.snowflakes.Snowflake, hikari.emojis.KnownCustomEmoji]: A mapping of emoji IDs to the objects of emojis in this guild.
self,
user: Union[hikari.users.PartialUser, hikari.snowflakes.Snowflake, int]
) -> Optional[hikari.guilds.Member]:
View Source
def get_member(self, user: snowflakes.SnowflakeishOr[users.PartialUser]) -> typing.Optional[Member]: """Get a cached member that belongs to the guild by it's user ID or object. Parameters ---------- user : hikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser] The object or ID of the user to get the cached member for. Returns ------- typing.Optional[Member] The cached member object if found, else `None`. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_member(self.id, user)
Get a cached member that belongs to the guild by it's user ID or object.
Parameters
- user (hikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser]): The object or ID of the user to get the cached member for.
Returns
- typing.Optional[Member]: The cached member object if found, else
None
.
View Source
def get_members(self) -> typing.Mapping[snowflakes.Snowflake, Member]: """Get the members cached for the guild. typing.Mapping[hikari.snowflakes.Snowflake, Member] A mapping of user IDs to objects of the members cached for the guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_members_view_for_guild(self.id)
Get the members cached for the guild.
typing.Mapping[hikari.snowflakes.Snowflake, Member] A mapping of user IDs to objects of the members cached for the guild.
View Source
def get_my_member(self) -> typing.Optional[Member]: """Return the cached member for the bot user in this guild, if known. Returns ------- typing.Optional[Member] The cached member for this guild, or `None` if not known. """ if not isinstance(self.app, traits.ShardAware): return None me = self.app.get_me() if me is None: return None return self.get_member(me.id)
Return the cached member for the bot user in this guild, if known.
Returns
- typing.Optional[Member]: The cached member for this guild, or
None
if not known.
self,
user: Union[hikari.users.PartialUser, hikari.snowflakes.Snowflake, int]
) -> Optional[hikari.presences.MemberPresence]:
View Source
def get_presence( self, user: snowflakes.SnowflakeishOr[users.PartialUser] ) -> typing.Optional[presences_.MemberPresence]: """Get a cached presence that belongs to the guild by it's user ID or object. Parameters ---------- user : hikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser] The object or ID of the user to get the cached presence for. Returns ------- typing.Optional[hikari.presences.MemberPresence] The cached presence object if found, else `None`. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_presence(self.id, user)
Get a cached presence that belongs to the guild by it's user ID or object.
Parameters
- user (hikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser]): The object or ID of the user to get the cached presence for.
Returns
- typing.Optional[hikari.presences.MemberPresence]: The cached presence object if found, else
None
.
self
) -> Mapping[hikari.snowflakes.Snowflake, hikari.presences.MemberPresence]:
View Source
def get_presences(self) -> typing.Mapping[snowflakes.Snowflake, presences_.MemberPresence]: """Get the presences cached for the guild. typing.Mapping[hikari.snowflakes.Snowflake, hikari.presences.MemberPresence] A mapping of user IDs to objects of the presences cached for the guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_presences_view_for_guild(self.id)
Get the presences cached for the guild.
typing.Mapping[hikari.snowflakes.Snowflake, hikari.presences.MemberPresence] A mapping of user IDs to objects of the presences cached for the guild.
self,
role: Union[hikari.guilds.PartialRole, hikari.snowflakes.Snowflake, int]
) -> Optional[hikari.guilds.Role]:
View Source
def get_role(self, role: snowflakes.SnowflakeishOr[PartialRole]) -> typing.Optional[Role]: """Get a cached role that belongs to the guild by it's ID or object. Parameters ---------- role : hikari.snowflakes.SnowflakeishOr[PartialRole] The object or ID of the role to get for this guild from the cache. Returns ------- typing.Optional[Role] The object of the role found in cache, else `None`. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_role(role)
Get a cached role that belongs to the guild by it's ID or object.
Parameters
- role (hikari.snowflakes.SnowflakeishOr[PartialRole]): The object or ID of the role to get for this guild from the cache.
Returns
- typing.Optional[Role]: The object of the role found in cache, else
None
.
View Source
def get_roles(self) -> typing.Mapping[snowflakes.Snowflake, Role]: """Return the roles in this guild. Returns ------- typing.Mapping[hikari.snowflakes.Snowflake, Role] A mapping of role IDs to the objects of roles in this guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_roles_view_for_guild(self.id)
Return the roles in this guild.
Returns
- typing.Mapping[hikari.snowflakes.Snowflake, Role]: A mapping of role IDs to the objects of roles in this guild.
self,
user: Union[hikari.users.PartialUser, hikari.snowflakes.Snowflake, int]
) -> Optional[hikari.voices.VoiceState]:
View Source
def get_voice_state( self, user: snowflakes.SnowflakeishOr[users.PartialUser] ) -> typing.Optional[voices_.VoiceState]: """Get a cached voice state that belongs to the guild by it's user. Parameters ---------- user : hikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser] The object or ID of the user to get the cached voice state for. Returns ------- typing.Optional[hikari.voices.VoiceState] The cached voice state object if found, else `None`. """ if not isinstance(self.app, traits.CacheAware): return None return self.app.cache.get_voice_state(self.id, user)
Get a cached voice state that belongs to the guild by it's user.
Parameters
- user (hikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser]): The object or ID of the user to get the cached voice state for.
Returns
- typing.Optional[hikari.voices.VoiceState]: The cached voice state object if found, else
None
.
View Source
def get_voice_states(self) -> typing.Mapping[snowflakes.Snowflake, voices_.VoiceState]: """Get the voice states cached for the guild. Returns ------- typing.Mapping[hikari.snowflakes.Snowflake, hikari.voices.VoiceState] A mapping of user IDs to objects of the voice states cached for the guild. """ if not isinstance(self.app, traits.CacheAware): return {} return self.app.cache.get_voice_states_view_for_guild(self.id)
Get the voice states cached for the guild.
Returns
- typing.Mapping[hikari.snowflakes.Snowflake, hikari.voices.VoiceState]: A mapping of user IDs to objects of the voice states cached for the guild.
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: str = 'png',
size: int = 4096
) -> Optional[hikari.files.URL]:
View Source
def make_discovery_splash_url(self, *, ext: str = "png", size: int = 4096) -> typing.Optional[files.URL]: """Generate the guild's discovery 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 string URL. Raises ------ ValueError If `size` is not a power of two or not between 16 and 4096. """ if self.discovery_splash_hash is None: return None return routes.CDN_GUILD_DISCOVERY_SPLASH.compile_to_file( urls.CDN_URL, guild_id=self.id, hash=self.discovery_splash_hash, size=size, file_format=ext, )
Generate the guild's discovery 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 string URL.
Raises
- ValueError: If
size
is not a power of two or not between 16 and 4096.
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 Role(PartialRole): """Represents a guild bound Role object.""" color: colors.Color = attr.field(eq=False, hash=False, repr=True) """The colour of this role. This will be applied to a member's name in chat if it's their top coloured role. """ guild_id: snowflakes.Snowflake = attr.field(eq=False, hash=False, repr=True) """The ID of the guild this role belongs to""" is_hoisted: bool = attr.field(eq=False, hash=False, repr=True) """Whether this role is hoisting the members it's attached to in the member list. members will be hoisted under their highest role where this is set to `True`. """ icon_hash: typing.Optional[str] = attr.field(eq=False, hash=False, repr=False) """Hash of the role's icon if set, else `None`.""" unicode_emoji: typing.Optional[emojis_.UnicodeEmoji] = attr.field(eq=False, hash=False, repr=False) """Role's icon as an unicode emoji if set, else `None`.""" is_managed: bool = attr.field(eq=False, hash=False, repr=False) """Whether this role is managed by an integration.""" is_mentionable: bool = attr.field(eq=False, hash=False, repr=False) """Whether this role can be mentioned by all regardless of permissions.""" permissions: permissions_.Permissions = attr.field(eq=False, hash=False, repr=False) """The guild wide permissions this role gives to the members it's attached to, This may be overridden by channel overwrites. """ position: int = attr.field(eq=False, hash=False, repr=True) """The position of this role in the role hierarchy. This will start at `0` for the lowest role (@everyone) and increase as you go up the hierarchy. """ bot_id: typing.Optional[snowflakes.Snowflake] = attr.field(eq=False, hash=False, repr=True) """The ID of the bot this role belongs to. If `None`, this is not a bot role. """ integration_id: typing.Optional[snowflakes.Snowflake] = attr.field(eq=False, hash=False, repr=True) """The ID of the integration this role belongs to. If `None`, this is not a integration role. """ is_premium_subscriber_role: bool = attr.field(eq=False, hash=False, repr=True) """Whether this role is the guild's nitro subscriber role.""" @property def colour(self) -> colours.Colour: """Alias for the `color` field.""" return self.color @property def icon_url(self) -> typing.Optional[files.URL]: """Role icon URL, if there is one. Returns ------- typing.Optional[hikari.files.URL] The URL, or `None` if no icon exists. """ return self.make_icon_url() def make_icon_url(self, *, ext: str = "png", size: int = 4096) -> typing.Optional[files.URL]: """Generate the icon URL for this role, if set. If no role icon is set, this returns `None`. 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 icon, or `None` if not present. Raises ------ ValueError If `size` is not a power of two or not between 16 and 4096. """ if self.icon_hash is None: return None return routes.CDN_ROLE_ICON.compile_to_file( urls.CDN_URL, role_id=self.id, hash=self.icon_hash, size=size, file_format=ext, )
Represents a guild bound Role object.
Variables and properties
The client application that models may use for procedures.
The ID of the bot this role belongs to.
If None
, this is not a bot role.
The colour of this role.
This will be applied to a member's name in chat if it's their top coloured role.
Alias for the color
field.
When the object was created.
The ID of the guild this role belongs to
Hash of the role's icon if set, else None
.
Role icon URL, if there is one.
Returns
- typing.Optional[hikari.files.URL]: The URL, or
None
if no icon exists.
The ID of this entity.
The ID of the integration this role belongs to.
If None
, this is not a integration role.
Whether this role is hoisting the members it's attached to in the member list.
members will be hoisted under their highest role where this is set to True
.
Whether this role is managed by an integration.
Whether this role can be mentioned by all regardless of permissions.
Return a raw mention string for the role.
The role's name.
The guild wide permissions this role gives to the members it's attached to,
This may be overridden by channel overwrites.
The position of this role in the role hierarchy.
This will start at 0
for the lowest role (@everyone) and increase as you go up the hierarchy.
Role's icon as an unicode emoji if set, else None
.
Methods
self,
*,
app: hikari.traits.RESTAware,
id: hikari.snowflakes.Snowflake,
name: str,
color: hikari.colors.Color,
guild_id: hikari.snowflakes.Snowflake,
is_hoisted: bool,
icon_hash: Optional[str],
unicode_emoji: Optional[hikari.emojis.UnicodeEmoji],
is_managed: bool,
is_mentionable: bool,
permissions: hikari.permissions.Permissions,
position: int,
bot_id: Optional[hikari.snowflakes.Snowflake],
integration_id: Optional[hikari.snowflakes.Snowflake],
is_premium_subscriber_role: bool
):
View Source
def __init__(self, *, app, id, name, color, guild_id, is_hoisted, icon_hash, unicode_emoji, is_managed, is_mentionable, permissions, position, bot_id, integration_id, is_premium_subscriber_role): self.app = app self.id = id self.name = name self.color = color self.guild_id = guild_id self.is_hoisted = is_hoisted self.icon_hash = icon_hash self.unicode_emoji = unicode_emoji self.is_managed = is_managed self.is_mentionable = is_mentionable self.permissions = permissions self.position = position self.bot_id = bot_id self.integration_id = integration_id self.is_premium_subscriber_role = is_premium_subscriber_role
Method generated by attrs for class Role.
View Source
def make_icon_url(self, *, ext: str = "png", size: int = 4096) -> typing.Optional[files.URL]: """Generate the icon URL for this role, if set. If no role icon is set, this returns `None`. 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 icon, or `None` if not present. Raises ------ ValueError If `size` is not a power of two or not between 16 and 4096. """ if self.icon_hash is None: return None return routes.CDN_ROLE_ICON.compile_to_file( urls.CDN_URL, role_id=self.id, hash=self.icon_hash, size=size, file_format=ext, )
Generate the icon URL for this role, if set.
If no role icon is set, this returns None
.
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 icon, or
None
if not present.
Raises
- ValueError: If
size
is not a power of two or not between 16 and 4096.
View Source
@attr_extensions.with_copy @attr.define(hash=False, weakref_slot=False) class WelcomeChannel: """Used to represent channels on guild welcome screens.""" channel_id: snowflakes.Snowflake = attr.field(hash=False, repr=True) """ID of the channel shown in the welcome screen.""" description: str = attr.field(hash=False, repr=False) """The description shown for this channel.""" emoji_name: typing.Union[str, emojis_.UnicodeEmoji, None] = attr.field( default=None, kw_only=True, hash=False, repr=True ) """The emoji shown in the welcome screen channel if set to a unicode emoji. .. warning:: While it may also be present for custom emojis, this is neither guaranteed to be provided nor accurate. """ emoji_id: typing.Optional[snowflakes.Snowflake] = attr.field(default=None, kw_only=True, hash=False, repr=True) """ID of the emoji shown in the welcome screen channel if it's set to a custom emoji."""
Used to represent channels on guild welcome screens.
Variables and properties
ID of the channel shown in the welcome screen.
The description shown for this channel.
ID of the emoji shown in the welcome screen channel if it's set to a custom emoji.
The emoji shown in the welcome screen channel if set to a unicode emoji.
Warning: While it may also be present for custom emojis, this is neither guaranteed to be provided nor accurate.
Methods
self,
channel_id: hikari.snowflakes.Snowflake,
description: str,
*,
emoji_name: Union[str, hikari.emojis.UnicodeEmoji, NoneType] = None,
emoji_id: Optional[hikari.snowflakes.Snowflake] = None
):
View Source
def __init__(self, channel_id, description, *, emoji_name=attr_dict['emoji_name'].default, emoji_id=attr_dict['emoji_id'].default): self.channel_id = channel_id self.description = description self.emoji_name = emoji_name self.emoji_id = emoji_id
Method generated by attrs for class WelcomeChannel.
View Source
@attr_extensions.with_copy @attr.define(hash=False, kw_only=True, weakref_slot=False) class WelcomeScreen: """Used to represent guild welcome screens on Discord.""" description: typing.Optional[str] = attr.field(hash=False, repr=True) """The guild's description shown in the welcome screen.""" channels: typing.Sequence[WelcomeChannel] = attr.field(hash=False, repr=True) """An array of up to 5 of the channels shown in the welcome screen."""
Used to represent guild welcome screens on Discord.
Variables and properties
An array of up to 5 of the channels shown in the welcome screen.
The guild's description shown in the welcome screen.
Methods
self,
*,
description: Optional[str],
channels: Sequence[hikari.guilds.WelcomeChannel]
):
View Source
def __init__(self, *, description, channels): self.description = description self.channels = channels
Method generated by attrs for class WelcomeScreen.