import discord from typing import Optional from local_settings import OUTPUT_CHANNEL from query.guild import get_output_channel async def report(bot, message, user: Optional[discord.User]=None, guild: Optional[discord.Guild]=None, guild_id: Optional[int]=None, channel: Optional[discord.TextChannel]=None) -> None: output_channel = bot.get_channel(int(OUTPUT_CHANNEL)) prefix = "" if guild or guild_id: if guild_id: guild = bot.get_guild(guild_id) prefix += f"**{guild}**" if channel: prefix += f"/**{channel.mention}** - " if user: prefix += f"`{user}`|**{user.display_name}**: " await output_channel.send(prefix + message) # Send to local guild try: guild_output_channel = bot.get_channel(get_output_channel(guild.id)) await output_channel.send(prefix + message) except: pass