Conditions | 4 |
Total Lines | 33 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | """Deals with long message sending""" |
||
11 | async def admin_log(bot: commands.Bot, message: str, log_status: bool = True) -> None: |
||
12 | """Admin Log |
||
13 | |||
14 | **Asynchronous Function** |
||
15 | |||
16 | |||
17 | Log **message** to the admin channels. |
||
18 | |||
19 | :param bot: Discord bot |
||
20 | :type bot: discord.ext.commands.Bot |
||
21 | :param message: Message to log |
||
22 | :type message: str |
||
23 | :param log_status: Will be sent to logging channels (true) |
||
24 | or non logging channels including debug |
||
25 | :type log_status: bool |
||
26 | |||
27 | """ |
||
28 | if len(message) > 2000: |
||
29 | log.warning("Log message length too long, it will not be sent. Length: %s", len(message)) |
||
30 | |||
31 | channels = await select("admin_channels", "id", "log", log_status) |
||
32 | for channel in channels: |
||
33 | to_send = bot.get_channel(channel) |
||
34 | if to_send is None: |
||
35 | log.warning(f"No channel found for id {channel}") |
||
36 | else: |
||
37 | embed = discord.Embed( |
||
38 | title="Log Update:", |
||
39 | description=message, |
||
40 | color=discord.Color(int("FF0000", 16)), |
||
41 | ) |
||
42 | await to_send.send(embed=embed) |
||
43 | return None |
||
44 |