mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
Bump d.py version to 2.6.2 (#6597)
This commit is contained in:
parent
0e25534677
commit
72f8952baf
@ -528,7 +528,7 @@ class Filter(commands.Cog):
|
|||||||
texts.append(attachment.description or "")
|
texts.append(attachment.description or "")
|
||||||
for embed in snapshot.embeds:
|
for embed in snapshot.embeds:
|
||||||
texts.extend(_extract_string_values(embed.to_dict().values()))
|
texts.extend(_extract_string_values(embed.to_dict().values()))
|
||||||
for component in snapshot.components:
|
for component in _walk_all_components(snapshot.components):
|
||||||
texts.extend(_extract_string_values_from_component(component))
|
texts.extend(_extract_string_values_from_component(component))
|
||||||
|
|
||||||
hits = await self.filter_hits(message.channel, *texts)
|
hits = await self.filter_hits(message.channel, *texts)
|
||||||
@ -642,17 +642,52 @@ class Filter(commands.Cog):
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def _extract_string_values_from_component(
|
_ChildComponent = Union[
|
||||||
component: Union[discord.ActionRow, discord.Button, discord.SelectMenu],
|
discord.Button,
|
||||||
) -> Iterable[str]:
|
discord.FileComponent,
|
||||||
if isinstance(component, discord.ActionRow):
|
discord.LabelComponent,
|
||||||
for child in component.children:
|
discord.MediaGalleryComponent,
|
||||||
yield from _extract_string_values_from_component(child)
|
discord.SelectMenu,
|
||||||
elif isinstance(component, discord.Button):
|
discord.TextDisplay,
|
||||||
|
discord.TextInput,
|
||||||
|
discord.ThumbnailComponent,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def _extract_string_values_from_component(component: _ChildComponent) -> Iterable[str]:
|
||||||
|
for value in _extract_values_from_component(component):
|
||||||
|
if value:
|
||||||
|
yield value
|
||||||
|
|
||||||
|
|
||||||
|
def _extract_values_from_component(component: _ChildComponent) -> Iterable[Optional[str]]:
|
||||||
|
if isinstance(component, discord.Button):
|
||||||
yield component.url
|
yield component.url
|
||||||
yield component.label
|
yield component.label
|
||||||
|
elif isinstance(component, discord.MediaGalleryComponent):
|
||||||
|
for item in component.items:
|
||||||
|
yield item.description
|
||||||
elif isinstance(component, discord.SelectMenu):
|
elif isinstance(component, discord.SelectMenu):
|
||||||
yield component.placeholder
|
yield component.placeholder
|
||||||
|
elif isinstance(component, discord.TextDisplay):
|
||||||
|
yield component.content
|
||||||
|
elif isinstance(component, discord.ThumbnailComponent):
|
||||||
|
yield component.description
|
||||||
|
# FileComponent does not have any user-provided text fields
|
||||||
|
# LabelComponent and TextInput are modal-only components
|
||||||
|
|
||||||
|
|
||||||
|
def _walk_all_components(components: Iterable[discord.Component]) -> Iterable[_ChildComponent]:
|
||||||
|
for item in components:
|
||||||
|
if isinstance(item, discord.ActionRow):
|
||||||
|
yield from item.children
|
||||||
|
elif isinstance(item, discord.Container):
|
||||||
|
yield from _walk_all_components(item.children)
|
||||||
|
elif isinstance(item, discord.SectionComponent):
|
||||||
|
yield from item.children
|
||||||
|
yield item.accessory
|
||||||
|
else:
|
||||||
|
yield item
|
||||||
|
|
||||||
|
|
||||||
def _extract_string_values(data: Iterable[Any]) -> Iterable[str]:
|
def _extract_string_values(data: Iterable[Any]) -> Iterable[str]:
|
||||||
|
|||||||
@ -18,7 +18,7 @@ brotli==1.1.0
|
|||||||
# via -r base.in
|
# via -r base.in
|
||||||
click==8.1.8
|
click==8.1.8
|
||||||
# via -r base.in
|
# via -r base.in
|
||||||
discord-py==2.5.2
|
discord-py==2.6.2
|
||||||
# via
|
# via
|
||||||
# -r base.in
|
# -r base.in
|
||||||
# red-lavalink
|
# red-lavalink
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user