Skip to content
This repository has been archived by the owner on Dec 26, 2022. It is now read-only.

✨ Adding Interaction Flag support for list to message #346

Merged
merged 2 commits into from
Jan 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pincer/utils/convert_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

from __future__ import annotations

from collections import defaultdict
from collections.abc import Iterable
from typing import TYPE_CHECKING, Tuple, List
from typing import Union

Expand Down Expand Up @@ -41,8 +43,8 @@ def convert_message(client: Client, message: MessageConvertable) -> Message:
:class:`~pincer.objects.message.message.Message`
The message object to be sent
"""
if message and isinstance(message, (tuple, list)):
kwargs = {"attachments": [], "embeds": [], "components": []}
if message and isinstance(message, Iterable):
kwargs = defaultdict(list)
for item in message:
list_to_message_dict(item, kwargs)
message = Message(**kwargs)
Expand Down Expand Up @@ -71,3 +73,5 @@ def list_to_message_dict(item, kwargs):
kwargs["components"].append(item)
elif isinstance(item, str):
kwargs["content"] = item
elif isinstance(item, InteractionFlags):
kwargs["flags"] = item