in kundali/main.py [0:0]
def main(_) -> None:
# Define the intents
intents = discord.Intents.default()
# Initialize Client
client = discord.Client(intents=intents, heartbeat_timeout=120)
# Event listener for when the client has switched from offline to online
@client.event
async def on_ready():
logging.info(f"Logged in as {client.user}")
@client.event
async def on_message(message):
# Don't let the client respond to its own messages
if message.author == client.user:
return
purged_content = purge_mentions(message.content)
# Check if the client was mentioned in the message
if (
client.user.mentioned_in(message)
and message.mention_everyone is False
):
logging.info(purged_content)
await message.channel.send(
f"{message.author.mention}, ok! Generating report."
)
report = tempfile.NamedTemporaryFile(
suffix=".md", mode="w", delete=False
)
report.write(report_match(purged_content))
report.close()
# Send a direct message to the author
await message.channel.send(
file=discord.File(report.name),
content=f"{message.author.mention}, here's your report!",
)
client.run(params.DISCORD_TOKEN)