Util Functions¶
Note, this file should not be used by you. Only use the AntiSpamHandler to work with this package.
-
antispam.util.
dict_to_embed
(data, message, counts) → discord.embeds.Embed¶ Given a dictionary, will attempt to build a valid discord.Embed object to return
Parameters: - data (dict) – The given item to try build an embed from
- message (discord.Message) – Where we get all our info from
- counts (dict) – Our current warn & kick counts
Returns: Return type: discord.Embed
Notes
For you smart-ass’s out there. This does use
discord.Embed.from_dict()
except this also lets you use templated strings within fields you smart cookies
-
antispam.util.
embed_to_string
(embed) → str¶ Return the content of an embed, built to only return fields the package cares about for spam related issues
Parameters: embed (discord.Embed) – The embed to turn into a string Returns: The content of the string Return type: str
-
antispam.util.
substitute_args
(message, value, counts) → str¶ Given the options string, return the string with the relevant values substituted in
Parameters: - message (str) – The string to substitute with values
- value (discord.Message) – Where we get our values from to substitute
- counts (dict) – Our current warn & kick counts
Returns: The correctly substituted message
Return type: str
-
antispam.util.
transform_message
(item, value, counts)¶ Given an item of two possible values, create and return the correct thing
Parameters: - item ([str, dict]) – Either a straight string or dict to turn in an embed
- value (discord.Message) – Where things come from
- counts (dict) – Our current warn & kick counts
Returns: Return type: [str, discord.Embed]