Skip to content

Commit

Permalink
[VoiceNoteLog] add notice
Browse files Browse the repository at this point in the history
  • Loading branch information
japandotorg committed Nov 1, 2023
1 parent e572671 commit 5667501
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions voicenotelog/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"""

import io
import asyncio
import logging
from typing import Any, Dict, Final, List, Optional, Tuple, Union

Expand Down Expand Up @@ -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 ""
Expand All @@ -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:** <https://www.geeksforgeeks.org/how-to-install-ffmpeg-on-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=(
Expand Down

0 comments on commit 5667501

Please sign in to comment.