Skip to content

Commit

Permalink
Merge pull request #55 from sushi-chaaaan/refactor/#54-view-processing
Browse files Browse the repository at this point in the history
fix: implicily clear value if None is passed
  • Loading branch information
sushichan044 authored Oct 18, 2023
2 parents 635d676 + 022f769 commit 81d7c9e
Showing 1 changed file with 20 additions and 26 deletions.
46 changes: 20 additions & 26 deletions src/ductile/controller/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,32 +140,26 @@ def _process_view_for_discord(
"""
view_object: "ViewObject" = self.__view.render()

if mode == "attachment":
d_attachment: "ViewObjectDictWithAttachment" = {}
d_attachment["content"] = view_object.content
if view_object.embeds:
d_attachment["embeds"] = view_object.embeds
if view_object.files:
d_attachment["attachments"] = view_object.files
if view_object.components:
v = self.__raw_view
v.clear_items()
for child in view_object.components:
v.add_item(child)
d_attachment["view"] = v
return d_attachment

d_file: "ViewObjectDictWithFiles" = {}
d_file["content"] = view_object.content
if view_object.embeds:
d_file["embeds"] = view_object.embeds
if view_object.files:
d_file["files"] = view_object.files

# implicitly clear view every time see:#54
v = self.__raw_view
v.clear_items()
if view_object.components:
v = self.__raw_view
v.clear_items()
for child in view_object.components:
v.add_item(child)
d_file["view"] = v
return d_file

if mode == "attachment":
# implicitly clear items every time see:#54

return {
"content": view_object.content,
"embeds": view_object.embeds or [],
"view": v,
"attachments": view_object.files or [],
}

return {
"content": view_object.content,
"embeds": view_object.embeds or [],
"view": v,
"files": view_object.files or [],
}

0 comments on commit 81d7c9e

Please sign in to comment.