Fix logging view field insertion
This commit is contained in:
parent
d0ca79d059
commit
e22847d5d6
@ -152,9 +152,18 @@ class LoggingCog(commands.Cog):
|
||||
|
||||
def add_field(self, name: str, value: str, inline: bool = False) -> None:
|
||||
field = ui.TextDisplay(f"**{name}:** {value}")
|
||||
if hasattr(self.container, "children"):
|
||||
index = self.container.children.index(self.bottom_separator)
|
||||
self.container.children.insert(index, field)
|
||||
# Ensure the field is properly registered with the view by using
|
||||
# add_item first, then repositioning it before the bottom separator
|
||||
if hasattr(self.container, "_children"):
|
||||
self.container.add_item(field)
|
||||
try:
|
||||
children = self.container._children
|
||||
index = children.index(self.bottom_separator)
|
||||
children.remove(field)
|
||||
children.insert(index, field)
|
||||
except ValueError:
|
||||
# Fallback to default behaviour if the separator is missing
|
||||
pass
|
||||
else:
|
||||
self.content_container.add_item(field)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user