Message¶
discord_http.message module¶
- class discord_http.message.Attachment(*, state, data)¶
Bases:
object
- Parameters:
state (DiscordAPI)
data (dict)
- async fetch(*, use_cached=False) bytes ¶
Fetches the file from the attachment URL and returns it as bytes.
- Parameters:
use_cached (
bool
) – Whether to use the cached URL or not, defaults to False- Return type:
- Returns:
The attachment as bytes
- Raises:
HTTPException – If the request returned anything other than 2XX
- async save(path, *, use_cached=False) int ¶
Fetches the file from the attachment URL and saves it locally to the path.
- class discord_http.message.JumpURL(*, state, url=None, guild_id=None, channel_id=None, message_id=None)¶
Bases:
object
- Parameters:
state (DiscordAPI)
url (str | None)
guild_id (int | None)
channel_id (int | None)
message_id (int | None)
- property channel: BaseChannel | PartialChannel | None¶
Returns the channel the message was sent in.
If guild and channel cache is enabled, it can also return full channel object.
- async fetch_channel() BaseChannel ¶
Returns the channel the message was sent in.
- Return type:
- property guild: Guild | PartialGuild | None¶
The guild the message was sent in.
- property message: PartialMessage | None¶
Returns the message if a message_id is available.
- class discord_http.message.Message(*, state, data, guild=None)¶
Bases:
PartialMessage
- Parameters:
state (DiscordAPI)
data (dict)
guild (PartialGuild | None)
- property channel_mentions: list[BaseChannel | PartialChannel]¶
Returns the channel mentions in the message.
Can return full role object if guild and channel cache is enabled
- property emojis: list[EmojiParser]¶
Returns the emojis in the message.
- property role_mentions: list[Role | PartialRole]¶
Returns the role mentions in the message.
Can return full role object if guild and role cache is enabled
- class discord_http.message.MessageInteraction(*, state, data)¶
Bases:
PartialBase
- Parameters:
state (DiscordAPI)
data (dict)
- class discord_http.message.MessageReference(*, state, data)¶
Bases:
object
- Parameters:
state (DiscordAPI)
data (dict)
- property channel: PartialChannel | None¶
Returns the channel the message was sent in.
- property guild: Guild | PartialGuild | None¶
The guild the message was sent in.
- property message: PartialMessage | None¶
Returns the message if a message_id and channel_id is available.
- class discord_http.message.PartialMessage(*, state, id, channel_id, guild_id=None)¶
Bases:
PartialBase
- Parameters:
state (DiscordAPI)
id (int)
channel_id (int)
guild_id (int | None)
- property channel: BaseChannel | PartialChannel¶
Returns the channel the message was sent in.
- async create_public_thread(name, *, auto_archive_duration=60, rate_limit_per_user=None, reason=None) PublicThread ¶
Create a public thread from the message.
- Parameters:
- Return type:
- Returns:
The created thread
- Raises:
If auto_archive_duration is not 60, 1440, 4320 or 10080 - If rate_limit_per_user is not between 0 and 21600 seconds
- async edit(*, content=<MISSING>, embed=<MISSING>, embeds=<MISSING>, view=<MISSING>, attachment=<MISSING>, attachments=<MISSING>, allowed_mentions=<MISSING>, flags=<MISSING>) Message ¶
Edit the message.
- Parameters:
attachments (
list
[File
] |None
) – New attachments of the messageallowed_mentions (
AllowedMentions
|None
) – Allowed mentions of the messageflags (
MessageFlags
|None
) – Flags of the message
- Return type:
- Returns:
The edited message
- async expire_poll() Message ¶
Immediately end the poll, then returns new Message object.
This can only be done if you created it
- Return type:
- Returns:
The message object of the poll
- async fetch_poll_voters(answer, after=None, limit=100) AsyncIterator[User] ¶
Fetch the users who voted for this answer.
- Parameters:
- Yields:
User – User object of people who voted
- Return type:
- async forward(*, channel_id) Message ¶
Forwards the message to another channel.
This does not accept any normal message parameters, only channel ID.
- property guild: Guild | PartialGuild | None¶
Returns the guild the message was sent in.
- async reply(content=<MISSING>, *, embed=<MISSING>, embeds=<MISSING>, file=<MISSING>, files=<MISSING>, view=<MISSING>, tts=False, allowed_mentions=<MISSING>) Message ¶
Sends a reply to a message in a channel.
- Parameters:
tts (
bool
|None
) – If the message should be sent as a TTS messagetype – The type of response to the message
allowed_mentions (
AllowedMentions
|None
) – The allowed mentions for the message
- Return type:
- Returns:
The message object
- class discord_http.message.Poll(*, text, allow_multiselect=False, duration=None)¶
Bases:
object
- add_answer(*, text=None, emoji=None) PollAnswer ¶
Add an answer to the poll.
- Parameters:
emoji (
EmojiParser
|str
|None
) – The emoji of the answer
- Return type:
PollAnswer
- classmethod from_dict(data) Self ¶
Create a poll from a dictionary.
- Return type:
Self
- Parameters:
data (dict)
- class discord_http.message.WebhookMessage(*, state, data, application_id, token)¶
Bases:
Message
- Parameters:
state (DiscordAPI)
data (dict)
application_id (int)
token (str)
- async edit(*, content=<MISSING>, embed=<MISSING>, embeds=<MISSING>, attachment=<MISSING>, attachments=<MISSING>, view=<MISSING>, flags=<MISSING>, allowed_mentions=<MISSING>) WebhookMessage ¶
Edit the webhook message.
- Parameters:
attachments (
list
[File
] |None
) – Attachments of the messageallowed_mentions (
AllowedMentions
|None
) – Allowed mentions of the messageflags (
MessageFlags
|None
) – Flags of the message
- Return type:
- Returns:
The edited message