From 5667501e8850aa4afc399106247650a78a4d86fe Mon Sep 17 00:00:00 2001 From: Lemon Rose Date: Wed, 1 Nov 2023 17:40:13 +0530 Subject: [PATCH] [VoiceNoteLog] add notice --- voicenotelog/core.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/voicenotelog/core.py b/voicenotelog/core.py index 68f7b32..61be25b 100644 --- a/voicenotelog/core.py +++ b/voicenotelog/core.py @@ -23,6 +23,7 @@ """ import io +import asyncio import logging from typing import Any, Dict, Final, List, Optional, Tuple, Union @@ -61,8 +62,13 @@ def __init__(self, bot: Red) -> None: "channel": None, "toggle": False, } + default_global: Dict[str, bool] = { + "notice": False, + } self.config.register_guild(**default_guild) + self.task: asyncio.Task[Any] = asyncio.create_task(self.initialize()) + def format_help_for_context(self, ctx: commands.Context) -> str: pre_processed = super().format_help_for_context(ctx) n = "\n" if "\n\n" not in pre_processed else "" @@ -78,6 +84,22 @@ def _has_voice_note(self, message: discord.Message) -> bool: return False return True + async def initialize(self) -> None: + await self.bot.wait_until_red_ready() + if not await self.config.notice(): + try: + await self.bot.send_to_owners( + "In order to use the **VoiceNoteLog** cog, you'll have to install ffmpeg in your server.\n" + "**Linux:** `sudo apt install ffmpeg -y`\n" + "**WIndows:** \n" + ) + await self.config.notice.set(True) + except (discord.NotFound, discord.HTTPException): + log.exception("Failed to send the notice message!") + + async def cog_unload(self) -> None: + self.task.cancel() + async def _embed(self, text: str, message: discord.Message) -> discord.Embed: embed: discord.Embed = discord.Embed( description=(