hikari.messages
#
Application and entities that are used to describe messages on Discord.
Attachment
#
Bases: Unique
, WebResource
Represents a file attached to a message.
You can use this object in the same way as a hikari.files.WebResource
,
by passing it as an attached file when creating a message, etc.
It can also be used when editing a message to keep a previous attachment.
duration
class-attribute
instance-attribute
#
The duration (in seconds) of the voice message.
filename
class-attribute
instance-attribute
#
The name of the file.
height
class-attribute
instance-attribute
#
The height of the image (if the file is an image).
id
class-attribute
instance-attribute
#
The ID of this entity.
is_ephemeral
class-attribute
instance-attribute
#
Whether this attachment is ephemeral.
This is a part of the ephemeral message response interactions feature and indicates that the attachment will be removed after a set period of time (but will exist as long as their relevant message exists).
media_type
class-attribute
instance-attribute
#
The media type of the file.
proxy_url
class-attribute
instance-attribute
#
The proxied URL of file.
size
class-attribute
instance-attribute
#
The size of the file in bytes.
url
class-attribute
instance-attribute
#
The source URL of file.
waveform
class-attribute
instance-attribute
#
A base64 encoded representation of the sampled waveform for the voice message.
width
class-attribute
instance-attribute
#
The width of the image (if the file is an image).
read
async
#
Read the entire resource at once into memory.
data = await resource.read(...)
# ^-- This is a shortcut for the following --v
async with resource.stream(...) as reader:
data = await reader.read()
Warning
If you simply wish to re-upload this resource to Discord via any endpoint in Hikari, you should opt to just pass this resource object directly. This way, Hikari can perform byte inception, which significantly reduces the memory usage for your bot as it grows larger.
PARAMETER | DESCRIPTION |
---|---|
executor |
The executor to run in for blocking operations.
If |
RETURNS | DESCRIPTION |
---|---|
bytes
|
The entire resource. |
save
async
#
Save this resource to disk.
This writes the resource file in chunks, and so does not load the entire resource into memory.
PARAMETER | DESCRIPTION |
---|---|
path |
The path to save this resource to. If this is a string, the path will be relative to the current working directory.
TYPE:
|
executor |
The executor to run in for blocking operations.
If |
force |
Whether to overwrite an existing file.
TYPE:
|
stream
#
stream(
*, executor: Optional[Executor] = None, head_only: bool = False
) -> AsyncReaderContextManager[WebReader]
Start streaming the content into memory by downloading it.
You can use this to fetch the entire resource, parts of the resource, or just to view any metadata that may be provided.
PARAMETER | DESCRIPTION |
---|---|
executor |
Not used. Provided only to match the underlying interface. |
head_only |
If
TYPE:
|
Examples:
Downloading an entire resource at once into memory:
Checking the metadata:
async with obj.stream() as stream:
mimetype = stream.mimetype
if mimetype is None:
...
elif mimetype not in whitelisted_mimetypes:
...
else:
...
Fetching the data-uri of a resource:
RETURNS | DESCRIPTION |
---|---|
AsyncReaderContextManager[WebReader]
|
An async context manager that when entered, produces the data stream. |
RAISES | DESCRIPTION |
---|---|
BadRequestError
|
If a 400 is returned. |
UnauthorizedError
|
If a 401 is returned. |
ForbiddenError
|
If a 403 is returned. |
NotFoundError
|
If a 404 is returned. |
ClientHTTPResponseError
|
If any other 4xx is returned. |
InternalServerError
|
If any other 5xx is returned. |
HTTPResponseError
|
If any other unexpected response code is returned. |
Message
#
Bases: PartialMessage
Represents a message with all known details.
activity
class-attribute
instance-attribute
#
activity: Optional[MessageActivity] = field(hash=False, eq=False, repr=False)
The message activity.
Note
This will only be provided for messages with rich-presence related chat embeds.
app
class-attribute
instance-attribute
#
Client application that models may use for procedures.
application
class-attribute
instance-attribute
#
application: Optional[MessageApplication] = field(
hash=False, eq=False, repr=False
)
The message application.
Note
This will only be provided for messages with rich-presence related chat embeds.
application_id
class-attribute
instance-attribute
#
ID of the application this message was sent by.
Note
This will only be provided for interaction messages.
attachments
class-attribute
instance-attribute
#
attachments: Sequence[Attachment] = field(hash=False, eq=False, repr=False)
The message attachments.
author
class-attribute
instance-attribute
#
The author of this message.
channel_id
class-attribute
instance-attribute
#
The ID of the channel that the message was sent in.
channel_mention_ids
property
#
channel_mention_ids: UndefinedOr[Sequence[Snowflake]]
Ids of channels that reference channels in the target crosspost's guild.
If the message is not crossposted, this will always be empty.
Warning
If the contents have not mutated and this is a message update event, some fields that are not affected may be empty instead.
This is a Discord limitation.
channel_mentions
class-attribute
instance-attribute
#
channel_mentions: UndefinedOr[Mapping[Snowflake, PartialChannel]] = field(
hash=False, eq=False, repr=False
)
Channel mentions that reference channels in the target crosspost's guild.
If the message is not crossposted, this will always be empty.
Warning
If the contents have not mutated and this is a message update event, some fields that are not affected may be empty instead.
This is a Discord limitation.
components
class-attribute
instance-attribute
#
components: Sequence[MessageActionRowComponent] = field(
hash=False, eq=False, repr=False
)
Sequence of the components attached to this message.
content
class-attribute
instance-attribute
#
The content of the message.
edited_timestamp
class-attribute
instance-attribute
#
The timestamp that the message was last edited at.
Will be None
if it wasn't ever edited.
embeds
class-attribute
instance-attribute
#
The message embeds.
flags
class-attribute
instance-attribute
#
flags: MessageFlag = field(hash=False, eq=False, repr=True)
The message flags.
guild_id
class-attribute
instance-attribute
#
The ID of the guild that the message was sent in or None
for messages out of guilds.
Warning
This will also be None
for messages received from the REST API.
This is a Discord limitation as stated here https://github.com/discord/discord-api-docs/issues/912
id
class-attribute
instance-attribute
#
The ID of this entity.
interaction
class-attribute
instance-attribute
#
interaction: Optional[MessageInteraction] = field(
hash=False, eq=False, repr=False
)
Information about the interaction this message was created by.
is_pinned
class-attribute
instance-attribute
#
Whether the message is pinned.
is_tts
class-attribute
instance-attribute
#
Whether the message is a TTS message.
member
class-attribute
instance-attribute
#
The member properties for the message's author.
mentions_everyone
class-attribute
instance-attribute
#
mentions_everyone: UndefinedOr[bool] = field(hash=False, eq=False, repr=False)
Whether the message notifies using @everyone
or @here
.
Warning
If the contents have not mutated and this is a message update event, some fields that are not affected may be empty instead.
This is a Discord limitation.
message_reference
class-attribute
instance-attribute
#
message_reference: Optional[MessageReference] = field(
hash=False, eq=False, repr=False
)
The message reference data.
nonce
class-attribute
instance-attribute
#
The message nonce. This is a string used for validating a message was sent.
reactions
class-attribute
instance-attribute
#
The message reactions.
referenced_message
class-attribute
instance-attribute
#
referenced_message: Optional[PartialMessage] = field(
hash=False, eq=False, repr=False
)
The message that was replied to.
If type
is hikari.messages.MessageType.REPLY
and None
, the message was deleted.
role_mention_ids
class-attribute
instance-attribute
#
role_mention_ids: UndefinedOr[Sequence[Snowflake]] = field(
hash=False, eq=False, repr=False
)
IDs of roles that were notified by their mention in the message.
Warning
If the contents have not mutated and this is a message update event, some fields that are not affected may be empty instead.
This is a Discord limitation.
stickers
class-attribute
instance-attribute
#
stickers: Sequence[PartialSticker] = field(hash=False, eq=False, repr=False)
The stickers sent with this message.
timestamp
class-attribute
instance-attribute
#
The timestamp that the message was sent at.
type
class-attribute
instance-attribute
#
type: Union[MessageType, int] = field(hash=False, eq=False, repr=False)
The message type.
user_mentions
class-attribute
instance-attribute
#
user_mentions: UndefinedOr[Mapping[Snowflake, User]] = field(
hash=False, eq=False, repr=False
)
Users who were notified by their mention in the message.
Warning
If the contents have not mutated and this is a message update event, some fields that are not affected may be empty instead.
This is a Discord limitation.
user_mentions_ids
property
#
user_mentions_ids: UndefinedOr[Sequence[Snowflake]]
Ids of the users who were notified by their mention in the message.
Warning
If the contents have not mutated and this is a message update event, some fields that are not affected may be empty instead.
This is a Discord limitation.
webhook_id
class-attribute
instance-attribute
#
If the message was generated by a webhook, the webhook's id.
add_reaction
async
#
add_reaction(
emoji: Union[str, Emoji],
emoji_id: UndefinedOr[SnowflakeishOr[CustomEmoji]] = undefined.UNDEFINED,
) -> None
Add a reaction to this message.
PARAMETER | DESCRIPTION |
---|---|
emoji |
Object or name of the emoji to react with. Note that if the emoji is an |
PARAMETER | DESCRIPTION |
---|---|
emoji_id |
ID of the custom emoji to react with.
This should only be provided when a custom emoji's name is passed
for Note that this will fail if the emoji is from a guild the bot isn't in.
TYPE:
|
Examples:
# Using a unicode emoji.
await message.add_reaction("👌")
# Using a unicode emoji name.
await message.add_reaction("\N{OK HAND SIGN}")
# Using the name and id.
await message.add_reaction("rooAYAYA", 705837374319493284)
# Using an Emoji-derived object.
await message.add_reaction(some_emoji_object)
RAISES | DESCRIPTION |
---|---|
BadRequestError
|
If the emoji is invalid, unknown, or formatted incorrectly. |
ForbiddenError
|
If this is the first reaction using this specific emoji on this
message and you lack the |
NotFoundError
|
If the channel or message is not found, or if the emoji is not found. This will also occur if you try to add an emoji from a guild you are not part of if no one else has previously reacted with the same emoji. |
delete
async
#
Delete this message.
RAISES | DESCRIPTION |
---|---|
NotFoundError
|
If the channel this message was created in is not found, or if the message has already been deleted. |
ForbiddenError
|
If you lack the permissions to delete the message. |
edit
async
#
edit(
content: UndefinedOr[Any] = undefined.UNDEFINED,
*,
attachment: UndefinedNoneOr[
Union[Resourceish, Attachment]
] = undefined.UNDEFINED,
attachments: UndefinedNoneOr[
Sequence[Union[Resourceish, Attachment]]
] = undefined.UNDEFINED,
component: UndefinedNoneOr[ComponentBuilder] = undefined.UNDEFINED,
components: UndefinedNoneOr[
Sequence[ComponentBuilder]
] = undefined.UNDEFINED,
embed: UndefinedNoneOr[Embed] = undefined.UNDEFINED,
embeds: UndefinedNoneOr[Sequence[Embed]] = undefined.UNDEFINED,
mentions_everyone: UndefinedOr[bool] = undefined.UNDEFINED,
mentions_reply: UndefinedOr[bool] = undefined.UNDEFINED,
user_mentions: UndefinedOr[
Union[SnowflakeishSequence[PartialUser], bool]
] = undefined.UNDEFINED,
role_mentions: UndefinedOr[
Union[SnowflakeishSequence[PartialRole], bool]
] = undefined.UNDEFINED,
flags: UndefinedOr[MessageFlag] = undefined.UNDEFINED
) -> Message
Edit an existing message in a given channel.
Note
Mentioning everyone, roles, or users in message edits currently will not send a push notification showing a new mention to people on Discord. It will still highlight in their chat as if they were mentioned, however.
Warning
If you specify a text content
, mentions_everyone
,
mentions_reply
, user_mentions
, and role_mentions
will default
to False
as the message will be re-parsed for mentions. This will
also occur if only one of the four are specified
This is a limitation of Discord's design. If in doubt, specify all four of them each time.
Warning
If the message was not sent by your user, the only parameter
you may provide to this call is the flags
parameter. Anything
else will result in a hikari.errors.ForbiddenError
being raised.
PARAMETER | DESCRIPTION |
---|---|
content |
If provided, the message content to update with. If
Any other value will be cast to a If this is a
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
attachment |
If provided, the attachment to set on the message. If
TYPE:
|
attachments |
If provided, the attachments to set on the message. If
TYPE:
|
component |
If provided, builder object of the component to set for this message.
This component will replace any previously set components and passing
TYPE:
|
components |
If provided, a sequence of the component builder objects set for
this message. These components will replace any previously set
components and passing
TYPE:
|
embed |
If provided, the embed to set on the message. If
TYPE:
|
embeds |
If provided, the embeds to set on the message. If
TYPE:
|
mentions_everyone |
Sanitation for
TYPE:
|
mentions_reply |
If provided, whether to mention the author of the message that is being replied to. This will not do anything if this is not a reply message.
TYPE:
|
user_mentions |
Sanitation for user mentions. If
You may alternatively pass a collection of
TYPE:
|
role_mentions |
Sanitation for role mentions. If
You may alternatively pass a collection of
TYPE:
|
flags |
Optional flags to set on the message. If
Note that some flags may not be able to be set. Currently the only
flags that can be set are
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Message
|
The edited message. |
RAISES | DESCRIPTION |
---|---|
BadRequestError
|
This may be raised in several discrete situations, such as messages being empty with no embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; invalid image URLs in embeds. |
UnauthorizedError
|
If you are unauthorized to make the request (invalid/missing token). |
ForbiddenError
|
If you lack permissions to send messages in the given channel; if you try to change the contents of another user's message; or if you try to edit the flags on another user's message without the permissions to manage messages. |
NotFoundError
|
If the channel or message is not found. |
InternalServerError
|
If an internal error occurs on Discord while handling the request. |
fetch_channel
async
#
fetch_channel() -> PartialChannel
Fetch the channel this message was created in.
RETURNS | DESCRIPTION |
---|---|
PartialChannel
|
The object of the channel this message belongs to. |
RAISES | DESCRIPTION |
---|---|
BadRequestError
|
If any invalid snowflake IDs are passed; a snowflake may be invalid due to it being outside of the range of a 64 bit integer. |
ForbiddenError
|
If you don't have access to the channel this message belongs to. |
NotFoundError
|
If the channel this message was created in does not exist. |
UnauthorizedError
|
If you are unauthorized to make the request (invalid/missing token). |
RateLimitTooLongError
|
Raised in the event that a rate limit occurs that is
longer than |
InternalServerError
|
If an internal error occurs on Discord while handling the request. |
get_member_mentions
#
get_member_mentions() -> UndefinedOr[Mapping[Snowflake, Member]]
Discover any cached members notified by this message.
If this message was sent in a DM, this will always be empty.
Warning
This will only return valid results on gateway events. For REST endpoints, this will potentially be empty. This is a limitation of Discord's API, as they do not consistently notify of the ID of the guild a message was sent in.
Note
If you are using a stateless application such as a stateless bot or a REST-only client, this will always be empty. Furthermore, if you are running a stateful bot and have the GUILD_MEMBERS intent disabled, this will also be empty.
Members that are not cached will not appear in this mapping. This
means that there is a very small chance that some users provided
in hikari.messages.PartialMessage.user_mentions
may not be
present here.
get_role_mentions
#
get_role_mentions() -> UndefinedOr[Mapping[Snowflake, Role]]
Attempt to look up the roles that are notified by this message.
If this message was sent in a DM, this will always be empty.
Warning
This will only return valid results on gateway events. For REST endpoints, this will potentially be empty. This is a limitation of Discord's API, as they do not consistently notify of the ID of the guild a message was sent in.
Note
If you are using a stateless application such as a stateless bot or a REST-only client, this will always be empty. Furthermore, if you are running a stateful bot and have the GUILD intent disabled, this will also be empty.
Roles that are not cached will not appear in this mapping. This
means that there is a very small chance that some role IDs provided
in hikari.messages.PartialMessage.role_mention_ids
may not be
present here. This is a limitation of Discord, again.
make_link
#
make_link(guild: Optional[SnowflakeishOr[PartialGuild]]) -> str
Generate a jump link to this message.
PARAMETER | DESCRIPTION |
---|---|
guild |
Object or ID of the guild this message is in or This parameter is necessary since
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The jump link to the message. |
remove_all_reactions
async
#
remove_all_reactions(
emoji: UndefinedOr[Union[str, Emoji]] = undefined.UNDEFINED,
emoji_id: UndefinedOr[SnowflakeishOr[CustomEmoji]] = undefined.UNDEFINED,
) -> None
Remove all users' reactions for a specific emoji from the message.
PARAMETER | DESCRIPTION |
---|---|
emoji |
Object or name of the emoji to get the reactions for. If not specified then all reactions are removed.
TYPE:
|
emoji_id |
ID of the custom emoji to react with.
This should only be provided when a custom emoji's name is passed
for
TYPE:
|
Examples:
# Using a unicode emoji and removing all 👌 reacts from the message.
# reaction.
await message.remove_all_reactions("\N{OK HAND SIGN}")
# Using the name and id.
await message.add_reaction("rooAYAYA", 705837374319493284)
# Removing all reactions entirely.
await message.remove_all_reactions()
RAISES | DESCRIPTION |
---|---|
ForbiddenError
|
If you are missing the |
NotFoundError
|
If the channel or message is not found, or if the emoji is not found. |
BadRequestError
|
If the emoji is invalid, unknown, or formatted incorrectly. If any invalid snowflake IDs are passed; a snowflake may be invalid due to it being outside of the range of a 64 bit integer. |
remove_reaction
async
#
remove_reaction(
emoji: Union[str, Emoji],
emoji_id: UndefinedOr[SnowflakeishOr[CustomEmoji]] = undefined.UNDEFINED,
*,
user: UndefinedOr[SnowflakeishOr[PartialUser]] = undefined.UNDEFINED
) -> None
Remove a reaction from this message.
PARAMETER | DESCRIPTION |
---|---|
emoji |
Object or name of the emoji to remove the reaction for. |
PARAMETER | DESCRIPTION |
---|---|
emoji_id |
ID of the custom emoji to remove the reaction for.
This should only be provided when a custom emoji's name is passed
for
TYPE:
|
user |
The user of the reaction to remove. If unspecified, then the bot's reaction is removed instead.
TYPE:
|
Examples:
# Using a unicode emoji and removing the bot's reaction from this
# reaction.
await message.remove_reaction("\N{OK HAND SIGN}")
# Using a custom emoji's name and ID to remove a specific user's
# reaction from this reaction.
await message.remove_reaction("a:Distraction", 745991233939439616, user=some_user)
# Using a unicode emoji and removing a specific user from this
# reaction.
await message.remove_reaction("\N{OK HAND SIGN}", user=some_user)
# Using the name and id.
await message.add_reaction("rooAYAYA", 705837374319493284)
# Using an Emoji object and removing a specific user from this
# reaction.
await message.remove_reaction(some_emoji_object, user=some_user)
RAISES | DESCRIPTION |
---|---|
BadRequestError
|
If the emoji is invalid, unknown, or formatted incorrectly. If any invalid snowflake IDs are passed; a snowflake may be invalid due to it being outside of the range of a 64 bit integer. |
ForbiddenError
|
If this is the first reaction using this specific emoji on this
message and you lack the |
NotFoundError
|
If the channel or message is not found, or if the emoji is not found. |
respond
async
#
respond(
content: UndefinedOr[Any] = undefined.UNDEFINED,
*,
attachment: UndefinedOr[Resourceish] = undefined.UNDEFINED,
attachments: UndefinedOr[Sequence[Resourceish]] = undefined.UNDEFINED,
component: UndefinedOr[ComponentBuilder] = undefined.UNDEFINED,
components: UndefinedOr[Sequence[ComponentBuilder]] = undefined.UNDEFINED,
embed: UndefinedOr[Embed] = undefined.UNDEFINED,
embeds: UndefinedOr[Sequence[Embed]] = undefined.UNDEFINED,
sticker: UndefinedOr[SnowflakeishOr[PartialSticker]] = undefined.UNDEFINED,
stickers: UndefinedOr[
SnowflakeishSequence[PartialSticker]
] = undefined.UNDEFINED,
tts: UndefinedOr[bool] = undefined.UNDEFINED,
reply: Union[
UndefinedType, SnowflakeishOr[PartialMessage], bool
] = undefined.UNDEFINED,
reply_must_exist: UndefinedOr[bool] = undefined.UNDEFINED,
mentions_everyone: UndefinedOr[bool] = undefined.UNDEFINED,
mentions_reply: UndefinedOr[bool] = undefined.UNDEFINED,
user_mentions: UndefinedOr[
Union[SnowflakeishSequence[PartialUser], bool]
] = undefined.UNDEFINED,
role_mentions: UndefinedOr[
Union[SnowflakeishSequence[PartialRole], bool]
] = undefined.UNDEFINED,
flags: Union[UndefinedType, int, MessageFlag] = undefined.UNDEFINED
) -> Message
Create a message in the channel this message belongs to.
PARAMETER | DESCRIPTION |
---|---|
content |
If provided, the message contents. If
If this is a Likewise, if this is a
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
attachment |
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.
TYPE:
|
attachments |
If provided, the message attachments. These can be resources, or strings consisting of paths on your computer or URLs.
TYPE:
|
component |
If provided, builder object of the component to include in this message.
TYPE:
|
components |
If provided, a sequence of the component builder objects to include in this message.
TYPE:
|
embed |
If provided, the message embed.
TYPE:
|
embeds |
If provided, the message embeds.
TYPE:
|
sticker |
If provided, object or ID of a sticker to send on the message. As of writing, bots can only send custom stickers from the current guild.
TYPE:
|
stickers |
If provided, object or ID of up to 3 stickers to send on the message. As of writing, bots can only send custom stickers from the current guild. |
tts |
If provided, whether the message will be TTS (Text To Speech).
TYPE:
|
reply |
TYPE:
|
reply_must_exist |
If provided, whether to error if the message being replied to does not exist instead of sending as a normal (non-reply) message. This will not do anything if not being used with
TYPE:
|
mentions_everyone |
If provided, whether the message should parse @everyone/@here mentions.
TYPE:
|
mentions_reply |
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
TYPE:
|
user_mentions |
If provided, and
TYPE:
|
role_mentions |
If provided, and
TYPE:
|
flags |
If provided, optional flags to set on the message. If
Note that some flags may not be able to be set. Currently the only
flags that can be set are
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Message
|
The created message. |
RAISES | DESCRIPTION |
---|---|
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; |
UnauthorizedError
|
If you are unauthorized to make the request (invalid/missing token). |
ForbiddenError
|
If you lack permissions to send messages in the given channel. |
NotFoundError
|
If the channel is not found. |
InternalServerError
|
If an internal error occurs on Discord while handling the request. |
ValueError
|
If more than 100 unique objects/entities are passed for
|
TypeError
|
If both |
MessageActivity
#
Represents the activity of a rich presence-enabled message.
MessageApplication
#
Bases: PartialApplication
The representation of an application used in messages.
cover_image_hash
class-attribute
instance-attribute
#
The CDN's hash of this application's default rich presence invite cover image.
cover_image_url
property
#
Rich presence cover image URL for this application, if set.
description
class-attribute
instance-attribute
#
The description of this application, if any.
icon_hash
class-attribute
instance-attribute
#
The CDN hash of this application's icon, if set.
id
class-attribute
instance-attribute
#
The ID of this entity.
name
class-attribute
instance-attribute
#
The name of this application.
make_cover_image_url
#
Generate the rich presence cover image URL for this application, if set.
PARAMETER | DESCRIPTION |
---|---|
ext |
The extension to use for this URL.
supports
TYPE:
|
size |
The size to set for the URL.
Can be any power of two between
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Optional[URL]
|
The URL, or |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the size is not an integer power of 2 between 16 and 4096 (inclusive). |
make_icon_url
#
Generate the icon URL for this application.
PARAMETER | DESCRIPTION |
---|---|
ext |
The extension to use for this URL.
Supports
TYPE:
|
size |
The size to set for the URL.
Can be any power of two between
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Optional[URL]
|
The URL, or |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the size is not an integer power of 2 between 16 and 4096 (inclusive). |
MessageFlag
#
Bases: Flag
Additional flags for message options.
CROSSPOSTED
class-attribute
instance-attribute
#
This message has been published to subscribed channels via channel following.
EPHEMERAL
class-attribute
instance-attribute
#
This message is only visible to the user that invoked the interaction.
FAILED_TO_MENTION_SOME_ROLES_IN_THREAD
class-attribute
instance-attribute
#
This message failed to mention some roles and add their mentions to the thread.
IS_CROSSPOST
class-attribute
instance-attribute
#
This message originated from a message in another channel via channel following.
IS_VOICE_MESSAGE
class-attribute
instance-attribute
#
This message is a voice message.
LOADING
class-attribute
instance-attribute
#
This message symbolizes that the interaction is 'thinking'.
SOURCE_MESSAGE_DELETED
class-attribute
instance-attribute
#
The message this crosspost originated from was deleted via channel following.
SUPPRESS_EMBEDS
class-attribute
instance-attribute
#
Any embeds on this message should be omitted when serializing the message.
SUPPRESS_NOTIFICATIONS
class-attribute
instance-attribute
#
This message will not trigger push and desktop notifications.
URGENT
class-attribute
instance-attribute
#
This message came from the urgent message system.
difference
#
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.
intersection
#
Return a combination of flags that are set for both given values.
Equivalent to using the "AND" &
operator.
is_disjoint
#
is_subset
#
Return whether another set contains this set or not.
Equivalent to using the "in" operator.
is_superset
#
Return whether this set contains another set or not.
none
#
none(*flags: Self) -> bool
Check if none of the given flags are part of this value.
Note
This is essentially the opposite of hikari.internal.enums.Flag.any
.
RETURNS | DESCRIPTION |
---|---|
bool
|
split
#
split() -> Sequence[Self]
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
symmetric_difference
#
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)
.
MessageInteraction
#
Representation of information provided for a message from an interaction.
id
class-attribute
instance-attribute
#
ID of the interaction this message was sent by.
name
class-attribute
instance-attribute
#
Name of the application command the interaction is tied to.
type
class-attribute
instance-attribute
#
type: Union[InteractionType, int] = field(eq=False, repr=True)
The type of interaction this message was created by.
MessageReference
#
Represents information about a referenced message.
This will be included in crossposted messages, channel follow add message, pin add messages and replies.
app
class-attribute
instance-attribute
#
Client application that models may use for procedures.
channel_id
class-attribute
instance-attribute
#
The ID of the channel that the original message originated from.
channel_link
property
#
channel_link: str
Generate a jump link to the channel the referenced message was sent in.
This will always be a valid link.
guild_id
class-attribute
instance-attribute
#
The ID of the guild that the message originated from.
This will be None
when the original message is not from
a guild.
MessageType
#
Bases: int
, Enum
The type of a message.
CHANNEL_ICON_CHANGE
class-attribute
instance-attribute
#
A message to denote that the icon of a channel changed.
CHANNEL_NAME_CHANGE
class-attribute
instance-attribute
#
A message to denote that the name of a channel changed.
CHANNEL_PINNED_MESSAGE
class-attribute
instance-attribute
#
A message to denote that a message was pinned.
CHAT_INPUT
class-attribute
instance-attribute
#
A message sent to indicate a chat input application command has been executed.
CONTEXT_MENU_COMMAND
class-attribute
instance-attribute
#
A message sent to indicate a context menu has been executed.
GUILD_DISCOVERY_DISQUALIFIED
class-attribute
instance-attribute
#
A message to indicate that a guild has been disqualified from discovery.
GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING
class-attribute
instance-attribute
#
A message to indicate the final warning before removal from discovery.
GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING
class-attribute
instance-attribute
#
A message to indicate that the grace period before removal from discovery has started.
GUILD_DISCOVERY_REQUALIFIED
class-attribute
instance-attribute
#
A message to indicate that a guild has re-qualified for discovery.
GUILD_INVITE_REMINDER
class-attribute
instance-attribute
#
A message sent to remind to invite people to the guild.
GUILD_MEMBER_JOIN
class-attribute
instance-attribute
#
A message to denote that a member joined the guild.
RECIPIENT_ADD
class-attribute
instance-attribute
#
A message to denote a new recipient in a group.
RECIPIENT_REMOVE
class-attribute
instance-attribute
#
A message to denote that a recipient left the group.
ROLE_SUBSCRIPTION_PURCHASE
class-attribute
instance-attribute
#
A message sent to indicate a role subscription has been purchased.
USER_PREMIUM_GUILD_SUBSCRIPTION
class-attribute
instance-attribute
#
A message to denote a Nitro subscription.
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1
class-attribute
instance-attribute
#
A message to denote a tier 1 Nitro subscription.
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2
class-attribute
instance-attribute
#
A message to denote a tier 2 Nitro subscription.
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3
class-attribute
instance-attribute
#
A message to denote a tier 3 Nitro subscription.
PartialMessage
#
Bases: Unique
A message representation containing partially populated information.
This contains arbitrary fields that may be updated in a
hikari.events.message_events.MessageUpdateEvent
, but for all other purposes should be treated as
being optionally specified.
Warning
All fields on this model except id
and channel_id
may be set to
hikari.undefined.UNDEFINED
if we have not received information
about their state from Discord alongside field nullability.
activity
class-attribute
instance-attribute
#
activity: UndefinedNoneOr[MessageActivity] = field(
hash=False, eq=False, repr=False
)
The message activity.
Note
This will only be provided for messages with rich-presence related chat embeds.
app
class-attribute
instance-attribute
#
Client application that models may use for procedures.
application
class-attribute
instance-attribute
#
application: UndefinedNoneOr[MessageApplication] = field(
hash=False, eq=False, repr=False
)
The message application.
Note
This will only be provided for messages with rich-presence related chat embeds.
application_id
class-attribute
instance-attribute
#
application_id: UndefinedNoneOr[Snowflake] = field(
hash=False, eq=False, repr=False
)
ID of the application this message was sent by.
Note
This will only be provided for interaction messages.
attachments
class-attribute
instance-attribute
#
attachments: UndefinedOr[Sequence[Attachment]] = field(
hash=False, eq=False, repr=False
)
The message attachments.
author
class-attribute
instance-attribute
#
author: UndefinedOr[User] = field(hash=False, eq=False, repr=True)
The author of this message.
This will also be hikari.undefined.UNDEFINED
in some cases such as when Discord
updates a message with an embed URL preview or in messages fetched from the REST API.
channel_id
class-attribute
instance-attribute
#
The ID of the channel that the message was sent in.
channel_mention_ids
property
#
channel_mention_ids: UndefinedOr[Sequence[Snowflake]]
Ids of channels that reference channels in the target crosspost's guild.
If the message is not crossposted, this will always be empty.
Warning
If the contents have not mutated and this is a message update event, some fields that are not affected may be empty instead.
This is a Discord limitation.
channel_mentions
class-attribute
instance-attribute
#
channel_mentions: UndefinedOr[Mapping[Snowflake, PartialChannel]] = field(
hash=False, eq=False, repr=False
)
Channel mentions that reference channels in the target crosspost's guild.
If the message is not crossposted, this will always be empty.
Warning
If the contents have not mutated and this is a message update event, some fields that are not affected may be empty instead.
This is a Discord limitation.
components
class-attribute
instance-attribute
#
components: UndefinedOr[Sequence[MessageActionRowComponent]] = field(
hash=False, eq=False, repr=False
)
Sequence of the components attached to this message.
content
class-attribute
instance-attribute
#
content: UndefinedNoneOr[str] = field(hash=False, eq=False, repr=False)
The content of the message.
edited_timestamp
class-attribute
instance-attribute
#
edited_timestamp: UndefinedNoneOr[datetime] = field(
hash=False, eq=False, repr=False
)
The timestamp that the message was last edited at.
Will be [None] if the message wasn't ever edited, or hikari.undefined.UNDEFINED
if the info is not available.
embeds
class-attribute
instance-attribute
#
embeds: UndefinedOr[Sequence[Embed]] = field(hash=False, eq=False, repr=False)
The message embeds.
flags
class-attribute
instance-attribute
#
flags: UndefinedOr[MessageFlag] = field(hash=False, eq=False, repr=False)
The message flags.
guild_id
class-attribute
instance-attribute
#
The ID of the guild that the message was sent in or None
for messages out of guilds.
Warning
This will also be None
for messages received from the REST API.
This is a Discord limitation as stated here https://github.com/discord/discord-api-docs/issues/912
id
class-attribute
instance-attribute
#
The ID of this entity.
interaction
class-attribute
instance-attribute
#
interaction: UndefinedNoneOr[MessageInteraction] = field(
hash=False, eq=False, repr=False
)
Information about the interaction this message was created by.
is_pinned
class-attribute
instance-attribute
#
is_pinned: UndefinedOr[bool] = field(hash=False, eq=False, repr=False)
Whether the message is pinned.
is_tts
class-attribute
instance-attribute
#
is_tts: UndefinedOr[bool] = field(hash=False, eq=False, repr=False)
Whether the message is a TTS message.
member
class-attribute
instance-attribute
#
member: UndefinedNoneOr[Member] = field(hash=False, eq=False, repr=False)
The member for the author who created the message.
If the message is not in a guild, this will be None
.
This will also be hikari.undefined.UNDEFINED
in some cases such as when Discord
updates a message with an embed URL preview.
Warning
This will also be None
for messages received from the REST API.
This is a Discord limitation as stated here https://github.com/discord/discord-api-docs/issues/912
mentions_everyone
class-attribute
instance-attribute
#
mentions_everyone: UndefinedOr[bool] = field(hash=False, eq=False, repr=False)
Whether the message notifies using @everyone
or @here
.
Warning
If the contents have not mutated and this is a message update event, some fields that are not affected may be empty instead.
This is a Discord limitation.
message_reference
class-attribute
instance-attribute
#
message_reference: UndefinedNoneOr[MessageReference] = field(
hash=False, eq=False, repr=False
)
The message reference data.
nonce
class-attribute
instance-attribute
#
nonce: UndefinedNoneOr[str] = field(hash=False, eq=False, repr=False)
The message nonce.
This is a string used for validating a message was sent.
reactions
class-attribute
instance-attribute
#
reactions: UndefinedOr[Sequence[Reaction]] = field(
hash=False, eq=False, repr=False
)
The message reactions.
referenced_message
class-attribute
instance-attribute
#
referenced_message: UndefinedNoneOr[PartialMessage] = field(
hash=False, eq=False, repr=False
)
The message that was replied to.
If type
is hikari.messages.MessageType.REPLY
and hikari.undefined.UNDEFINED
, Discord's
backend didn't attempt to fetch the message, so the status is unknown. If
type
is hikari.messages.MessageType.REPLY
and None
, the message was deleted.
role_mention_ids
class-attribute
instance-attribute
#
role_mention_ids: UndefinedOr[Sequence[Snowflake]] = field(
hash=False, eq=False, repr=False
)
IDs of roles that were notified by their mention in the message.
Warning
If the contents have not mutated and this is a message update event, some fields that are not affected may be empty instead.
This is a Discord limitation.
stickers
class-attribute
instance-attribute
#
stickers: UndefinedOr[Sequence[PartialSticker]] = field(
hash=False, eq=False, repr=False
)
The stickers sent with this message.
timestamp
class-attribute
instance-attribute
#
timestamp: UndefinedOr[datetime] = field(hash=False, eq=False, repr=False)
The timestamp that the message was sent at.
type
class-attribute
instance-attribute
#
type: UndefinedOr[Union[MessageType, int]] = field(
hash=False, eq=False, repr=False
)
The message type.
user_mentions
class-attribute
instance-attribute
#
user_mentions: UndefinedOr[Mapping[Snowflake, User]] = field(
hash=False, eq=False, repr=False
)
Users who were notified by their mention in the message.
Warning
If the contents have not mutated and this is a message update event, some fields that are not affected may be empty instead.
This is a Discord limitation.
user_mentions_ids
property
#
user_mentions_ids: UndefinedOr[Sequence[Snowflake]]
Ids of the users who were notified by their mention in the message.
Warning
If the contents have not mutated and this is a message update event, some fields that are not affected may be empty instead.
This is a Discord limitation.
webhook_id
class-attribute
instance-attribute
#
webhook_id: UndefinedNoneOr[Snowflake] = field(hash=False, eq=False, repr=False)
If the message was generated by a webhook, the webhook's ID.
add_reaction
async
#
add_reaction(
emoji: Union[str, Emoji],
emoji_id: UndefinedOr[SnowflakeishOr[CustomEmoji]] = undefined.UNDEFINED,
) -> None
Add a reaction to this message.
PARAMETER | DESCRIPTION |
---|---|
emoji |
Object or name of the emoji to react with. Note that if the emoji is an |
PARAMETER | DESCRIPTION |
---|---|
emoji_id |
ID of the custom emoji to react with.
This should only be provided when a custom emoji's name is passed
for Note that this will fail if the emoji is from a guild the bot isn't in.
TYPE:
|
Examples:
# Using a unicode emoji.
await message.add_reaction("👌")
# Using a unicode emoji name.
await message.add_reaction("\N{OK HAND SIGN}")
# Using the name and id.
await message.add_reaction("rooAYAYA", 705837374319493284)
# Using an Emoji-derived object.
await message.add_reaction(some_emoji_object)
RAISES | DESCRIPTION |
---|---|
BadRequestError
|
If the emoji is invalid, unknown, or formatted incorrectly. |
ForbiddenError
|
If this is the first reaction using this specific emoji on this
message and you lack the |
NotFoundError
|
If the channel or message is not found, or if the emoji is not found. This will also occur if you try to add an emoji from a guild you are not part of if no one else has previously reacted with the same emoji. |
delete
async
#
Delete this message.
RAISES | DESCRIPTION |
---|---|
NotFoundError
|
If the channel this message was created in is not found, or if the message has already been deleted. |
ForbiddenError
|
If you lack the permissions to delete the message. |
edit
async
#
edit(
content: UndefinedOr[Any] = undefined.UNDEFINED,
*,
attachment: UndefinedNoneOr[
Union[Resourceish, Attachment]
] = undefined.UNDEFINED,
attachments: UndefinedNoneOr[
Sequence[Union[Resourceish, Attachment]]
] = undefined.UNDEFINED,
component: UndefinedNoneOr[ComponentBuilder] = undefined.UNDEFINED,
components: UndefinedNoneOr[
Sequence[ComponentBuilder]
] = undefined.UNDEFINED,
embed: UndefinedNoneOr[Embed] = undefined.UNDEFINED,
embeds: UndefinedNoneOr[Sequence[Embed]] = undefined.UNDEFINED,
mentions_everyone: UndefinedOr[bool] = undefined.UNDEFINED,
mentions_reply: UndefinedOr[bool] = undefined.UNDEFINED,
user_mentions: UndefinedOr[
Union[SnowflakeishSequence[PartialUser], bool]
] = undefined.UNDEFINED,
role_mentions: UndefinedOr[
Union[SnowflakeishSequence[PartialRole], bool]
] = undefined.UNDEFINED,
flags: UndefinedOr[MessageFlag] = undefined.UNDEFINED
) -> Message
Edit an existing message in a given channel.
Note
Mentioning everyone, roles, or users in message edits currently will not send a push notification showing a new mention to people on Discord. It will still highlight in their chat as if they were mentioned, however.
Warning
If you specify a text content
, mentions_everyone
,
mentions_reply
, user_mentions
, and role_mentions
will default
to False
as the message will be re-parsed for mentions. This will
also occur if only one of the four are specified
This is a limitation of Discord's design. If in doubt, specify all four of them each time.
Warning
If the message was not sent by your user, the only parameter
you may provide to this call is the flags
parameter. Anything
else will result in a hikari.errors.ForbiddenError
being raised.
PARAMETER | DESCRIPTION |
---|---|
content |
If provided, the message content to update with. If
Any other value will be cast to a If this is a
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
attachment |
If provided, the attachment to set on the message. If
TYPE:
|
attachments |
If provided, the attachments to set on the message. If
TYPE:
|
component |
If provided, builder object of the component to set for this message.
This component will replace any previously set components and passing
TYPE:
|
components |
If provided, a sequence of the component builder objects set for
this message. These components will replace any previously set
components and passing
TYPE:
|
embed |
If provided, the embed to set on the message. If
TYPE:
|
embeds |
If provided, the embeds to set on the message. If
TYPE:
|
mentions_everyone |
Sanitation for
TYPE:
|
mentions_reply |
If provided, whether to mention the author of the message that is being replied to. This will not do anything if this is not a reply message.
TYPE:
|
user_mentions |
Sanitation for user mentions. If
You may alternatively pass a collection of
TYPE:
|
role_mentions |
Sanitation for role mentions. If
You may alternatively pass a collection of
TYPE:
|
flags |
Optional flags to set on the message. If
Note that some flags may not be able to be set. Currently the only
flags that can be set are
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Message
|
The edited message. |
RAISES | DESCRIPTION |
---|---|
BadRequestError
|
This may be raised in several discrete situations, such as messages being empty with no embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; invalid image URLs in embeds. |
UnauthorizedError
|
If you are unauthorized to make the request (invalid/missing token). |
ForbiddenError
|
If you lack permissions to send messages in the given channel; if you try to change the contents of another user's message; or if you try to edit the flags on another user's message without the permissions to manage messages. |
NotFoundError
|
If the channel or message is not found. |
InternalServerError
|
If an internal error occurs on Discord while handling the request. |
fetch_channel
async
#
fetch_channel() -> PartialChannel
Fetch the channel this message was created in.
RETURNS | DESCRIPTION |
---|---|
PartialChannel
|
The object of the channel this message belongs to. |
RAISES | DESCRIPTION |
---|---|
BadRequestError
|
If any invalid snowflake IDs are passed; a snowflake may be invalid due to it being outside of the range of a 64 bit integer. |
ForbiddenError
|
If you don't have access to the channel this message belongs to. |
NotFoundError
|
If the channel this message was created in does not exist. |
UnauthorizedError
|
If you are unauthorized to make the request (invalid/missing token). |
RateLimitTooLongError
|
Raised in the event that a rate limit occurs that is
longer than |
InternalServerError
|
If an internal error occurs on Discord while handling the request. |
get_member_mentions
#
get_member_mentions() -> UndefinedOr[Mapping[Snowflake, Member]]
Discover any cached members notified by this message.
If this message was sent in a DM, this will always be empty.
Warning
This will only return valid results on gateway events. For REST endpoints, this will potentially be empty. This is a limitation of Discord's API, as they do not consistently notify of the ID of the guild a message was sent in.
Note
If you are using a stateless application such as a stateless bot or a REST-only client, this will always be empty. Furthermore, if you are running a stateful bot and have the GUILD_MEMBERS intent disabled, this will also be empty.
Members that are not cached will not appear in this mapping. This
means that there is a very small chance that some users provided
in hikari.messages.PartialMessage.user_mentions
may not be
present here.
get_role_mentions
#
get_role_mentions() -> UndefinedOr[Mapping[Snowflake, Role]]
Attempt to look up the roles that are notified by this message.
If this message was sent in a DM, this will always be empty.
Warning
This will only return valid results on gateway events. For REST endpoints, this will potentially be empty. This is a limitation of Discord's API, as they do not consistently notify of the ID of the guild a message was sent in.
Note
If you are using a stateless application such as a stateless bot or a REST-only client, this will always be empty. Furthermore, if you are running a stateful bot and have the GUILD intent disabled, this will also be empty.
Roles that are not cached will not appear in this mapping. This
means that there is a very small chance that some role IDs provided
in hikari.messages.PartialMessage.role_mention_ids
may not be
present here. This is a limitation of Discord, again.
make_link
#
make_link(guild: Optional[SnowflakeishOr[PartialGuild]]) -> str
Generate a jump link to this message.
PARAMETER | DESCRIPTION |
---|---|
guild |
Object or ID of the guild this message is in or This parameter is necessary since
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The jump link to the message. |
remove_all_reactions
async
#
remove_all_reactions(
emoji: UndefinedOr[Union[str, Emoji]] = undefined.UNDEFINED,
emoji_id: UndefinedOr[SnowflakeishOr[CustomEmoji]] = undefined.UNDEFINED,
) -> None
Remove all users' reactions for a specific emoji from the message.
PARAMETER | DESCRIPTION |
---|---|
emoji |
Object or name of the emoji to get the reactions for. If not specified then all reactions are removed.
TYPE:
|
emoji_id |
ID of the custom emoji to react with.
This should only be provided when a custom emoji's name is passed
for
TYPE:
|
Examples:
# Using a unicode emoji and removing all 👌 reacts from the message.
# reaction.
await message.remove_all_reactions("\N{OK HAND SIGN}")
# Using the name and id.
await message.add_reaction("rooAYAYA", 705837374319493284)
# Removing all reactions entirely.
await message.remove_all_reactions()
RAISES | DESCRIPTION |
---|---|
ForbiddenError
|
If you are missing the |
NotFoundError
|
If the channel or message is not found, or if the emoji is not found. |
BadRequestError
|
If the emoji is invalid, unknown, or formatted incorrectly. If any invalid snowflake IDs are passed; a snowflake may be invalid due to it being outside of the range of a 64 bit integer. |
remove_reaction
async
#
remove_reaction(
emoji: Union[str, Emoji],
emoji_id: UndefinedOr[SnowflakeishOr[CustomEmoji]] = undefined.UNDEFINED,
*,
user: UndefinedOr[SnowflakeishOr[PartialUser]] = undefined.UNDEFINED
) -> None
Remove a reaction from this message.
PARAMETER | DESCRIPTION |
---|---|
emoji |
Object or name of the emoji to remove the reaction for. |
PARAMETER | DESCRIPTION |
---|---|
emoji_id |
ID of the custom emoji to remove the reaction for.
This should only be provided when a custom emoji's name is passed
for
TYPE:
|
user |
The user of the reaction to remove. If unspecified, then the bot's reaction is removed instead.
TYPE:
|
Examples:
# Using a unicode emoji and removing the bot's reaction from this
# reaction.
await message.remove_reaction("\N{OK HAND SIGN}")
# Using a custom emoji's name and ID to remove a specific user's
# reaction from this reaction.
await message.remove_reaction("a:Distraction", 745991233939439616, user=some_user)
# Using a unicode emoji and removing a specific user from this
# reaction.
await message.remove_reaction("\N{OK HAND SIGN}", user=some_user)
# Using the name and id.
await message.add_reaction("rooAYAYA", 705837374319493284)
# Using an Emoji object and removing a specific user from this
# reaction.
await message.remove_reaction(some_emoji_object, user=some_user)
RAISES | DESCRIPTION |
---|---|
BadRequestError
|
If the emoji is invalid, unknown, or formatted incorrectly. If any invalid snowflake IDs are passed; a snowflake may be invalid due to it being outside of the range of a 64 bit integer. |
ForbiddenError
|
If this is the first reaction using this specific emoji on this
message and you lack the |
NotFoundError
|
If the channel or message is not found, or if the emoji is not found. |
respond
async
#
respond(
content: UndefinedOr[Any] = undefined.UNDEFINED,
*,
attachment: UndefinedOr[Resourceish] = undefined.UNDEFINED,
attachments: UndefinedOr[Sequence[Resourceish]] = undefined.UNDEFINED,
component: UndefinedOr[ComponentBuilder] = undefined.UNDEFINED,
components: UndefinedOr[Sequence[ComponentBuilder]] = undefined.UNDEFINED,
embed: UndefinedOr[Embed] = undefined.UNDEFINED,
embeds: UndefinedOr[Sequence[Embed]] = undefined.UNDEFINED,
sticker: UndefinedOr[SnowflakeishOr[PartialSticker]] = undefined.UNDEFINED,
stickers: UndefinedOr[
SnowflakeishSequence[PartialSticker]
] = undefined.UNDEFINED,
tts: UndefinedOr[bool] = undefined.UNDEFINED,
reply: Union[
UndefinedType, SnowflakeishOr[PartialMessage], bool
] = undefined.UNDEFINED,
reply_must_exist: UndefinedOr[bool] = undefined.UNDEFINED,
mentions_everyone: UndefinedOr[bool] = undefined.UNDEFINED,
mentions_reply: UndefinedOr[bool] = undefined.UNDEFINED,
user_mentions: UndefinedOr[
Union[SnowflakeishSequence[PartialUser], bool]
] = undefined.UNDEFINED,
role_mentions: UndefinedOr[
Union[SnowflakeishSequence[PartialRole], bool]
] = undefined.UNDEFINED,
flags: Union[UndefinedType, int, MessageFlag] = undefined.UNDEFINED
) -> Message
Create a message in the channel this message belongs to.
PARAMETER | DESCRIPTION |
---|---|
content |
If provided, the message contents. If
If this is a Likewise, if this is a
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
attachment |
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.
TYPE:
|
attachments |
If provided, the message attachments. These can be resources, or strings consisting of paths on your computer or URLs.
TYPE:
|
component |
If provided, builder object of the component to include in this message.
TYPE:
|
components |
If provided, a sequence of the component builder objects to include in this message.
TYPE:
|
embed |
If provided, the message embed.
TYPE:
|
embeds |
If provided, the message embeds.
TYPE:
|
sticker |
If provided, object or ID of a sticker to send on the message. As of writing, bots can only send custom stickers from the current guild.
TYPE:
|
stickers |
If provided, object or ID of up to 3 stickers to send on the message. As of writing, bots can only send custom stickers from the current guild. |
tts |
If provided, whether the message will be TTS (Text To Speech).
TYPE:
|
reply |
TYPE:
|
reply_must_exist |
If provided, whether to error if the message being replied to does not exist instead of sending as a normal (non-reply) message. This will not do anything if not being used with
TYPE:
|
mentions_everyone |
If provided, whether the message should parse @everyone/@here mentions.
TYPE:
|
mentions_reply |
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
TYPE:
|
user_mentions |
If provided, and
TYPE:
|
role_mentions |
If provided, and
TYPE:
|
flags |
If provided, optional flags to set on the message. If
Note that some flags may not be able to be set. Currently the only
flags that can be set are
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Message
|
The created message. |
RAISES | DESCRIPTION |
---|---|
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; |
UnauthorizedError
|
If you are unauthorized to make the request (invalid/missing token). |
ForbiddenError
|
If you lack permissions to send messages in the given channel. |
NotFoundError
|
If the channel is not found. |
InternalServerError
|
If an internal error occurs on Discord while handling the request. |
ValueError
|
If more than 100 unique objects/entities are passed for
|
TypeError
|
If both |
Reaction
#
Represents a reaction in a message.
count
class-attribute
instance-attribute
#
The number of times the emoji has been used to react.
emoji
class-attribute
instance-attribute
#
emoji: Union[UnicodeEmoji, CustomEmoji] = field(hash=True, repr=True)
The emoji used to react.