File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
15
15
- New ` View.get_item() ` method. ([ #1659 ] ( https://github.com/Pycord-Development/pycord/pull/1659 ) )
16
16
- Permissions support for bridge commands. ([ #1642 ] ( https://github.com/Pycord-Development/pycord/pull/1642 ) )
17
17
- New ` BridgeCommand.invoke() ` method. ([ #1642 ] ( https://github.com/Pycord-Development/pycord/pull/1642 ) )
18
+ - New ` raw_mentions ` , ` raw_role_mentions ` and ` raw_channel_mentions ` functions in ` discord.utils ` .
19
+ ([ #1658 ] ( https://github.com/Pycord-Development/pycord/pull/1658 ) )
18
20
19
21
### Deprecated
20
22
- The ` delete_message_days ` parameter in ban methods is now deprecated. Please use ` delete_message_seconds ` instead.
Original file line number Diff line number Diff line change 88
88
"remove_markdown" ,
89
89
"escape_markdown" ,
90
90
"escape_mentions" ,
91
+ "raw_mentions" ,
92
+ "raw_channel_mentions" ,
93
+ "raw_role_mentions" ,
91
94
"as_chunks" ,
92
95
"format_dt" ,
93
96
"basic_autocomplete" ,
@@ -931,6 +934,50 @@ def escape_mentions(text: str) -> str:
931
934
"""
932
935
return re .sub (r"@(everyone|here|[!&]?[0-9]{17,20})" , "@\u200b \\ 1" , text )
933
936
937
+ def raw_mentions (text : str ) -> List [int ]:
938
+ """Returns a list of user IDs matching ``<@user_id>`` in the string.
939
+
940
+ Parameters
941
+ -----------
942
+ text: :class:`str`
943
+ The string to get user mentions from.
944
+
945
+ Returns
946
+ --------
947
+ List[:class:`int`]
948
+ A list of user IDs found in the string.
949
+ """
950
+ return [int (x ) for x in re .findall (r"<@!?([0-9]+)>" , text )]
951
+
952
+ def raw_channel_mentions (text : str ) -> List [int ]:
953
+ """Returns a list of channel IDs matching ``<@#channel_id>`` in the string.
954
+
955
+ Parameters
956
+ -----------
957
+ text: :class:`str`
958
+ The string to get channel mentions from.
959
+
960
+ Returns
961
+ --------
962
+ List[:class:`int`]
963
+ A list of channel IDs found in the string.
964
+ """
965
+ return [int (x ) for x in re .findall (r"<#([0-9]+)>" , text )]
966
+
967
+ def raw_role_mentions (text : str ) -> List [int ]:
968
+ """Returns a list of role IDs matching ``<@&role_id>`` in the string.
969
+
970
+ Parameters
971
+ -----------
972
+ text: :class:`str`
973
+ The string to get role mentions from.
974
+
975
+ Returns
976
+ --------
977
+ List[:class:`int`]
978
+ A list of role IDs found in the string.
979
+ """
980
+ return [int (x ) for x in re .findall (r"<@&([0-9]+)>" , text )]
934
981
935
982
def _chunk (iterator : Iterator [T ], max_size : int ) -> Iterator [List [T ]]:
936
983
ret = []
You can’t perform that action at this time.
0 commit comments