cleanup
This commit is contained in:
		| @@ -80,7 +80,8 @@ class MemeModal(discord.ui.Modal): | |||||||
|             await interaction.response.send_message("ERR: Text is limited to 80 characters for each the top and bottom lines.") |             await interaction.response.send_message("ERR: Text is limited to 80 characters for each the top and bottom lines.") | ||||||
|             return |             return | ||||||
|          |          | ||||||
|         meme_link: str = await self.meme_generator.create_meme(top_line=meme_top_line, bottom_line=meme_bottom_line, meme=selected_meme) |         meme_link: str = await self.meme_generator.create_meme(top_line=meme_top_line, | ||||||
|  |                                                                bottom_line=meme_bottom_line, meme=selected_meme) | ||||||
|              |              | ||||||
|         embed: discord.Embed = discord.Embed(title="Generated Meme") |         embed: discord.Embed = discord.Embed(title="Generated Meme") | ||||||
|         embed.set_image(url=meme_link) |         embed.set_image(url=meme_link) | ||||||
|   | |||||||
| @@ -4,6 +4,7 @@ | |||||||
| import os | import os | ||||||
| import logging | import logging | ||||||
| import importlib | import importlib | ||||||
|  | from typing import Optional | ||||||
| import discord | import discord | ||||||
| import setproctitle | import setproctitle | ||||||
| import hypercorn | import hypercorn | ||||||
| @@ -11,6 +12,7 @@ import hypercorn.asyncio | |||||||
| from dotenv import load_dotenv | from dotenv import load_dotenv | ||||||
| from discord.ext import bridge, commands | from discord.ext import bridge, commands | ||||||
| from termcolor import colored | from termcolor import colored | ||||||
|  | from constants import OWNERS, BOT_CHANIDS | ||||||
| import api | import api | ||||||
|  |  | ||||||
| logging.basicConfig(level=logging.INFO, | logging.basicConfig(level=logging.INFO, | ||||||
| @@ -18,23 +20,8 @@ logging.basicConfig(level=logging.INFO, | |||||||
|                     encoding='utf-8') |                     encoding='utf-8') | ||||||
| setproctitle.setproctitle('disc-havoc') | setproctitle.setproctitle('disc-havoc') | ||||||
|  |  | ||||||
| owners = [1172340700663255091, 992437729927376996] | """Auto Load Cogs""" | ||||||
| BOT_CHANIDS = [ | cogs_list: list[str] = [ | ||||||
|     1145182936442875997, |  | ||||||
|     1157535700774834236, |  | ||||||
|     1156710277266542624, |  | ||||||
|     1179232748385341530, |  | ||||||
|     1219638300654964807, |  | ||||||
|     1193632849740439665, |  | ||||||
|     1202288798315335831, |  | ||||||
|     1157529874936909934, |  | ||||||
|     1272333206066167959, |  | ||||||
|     1228740577068322839, |  | ||||||
|     1228740577068322841, |  | ||||||
|     1324142398741151784, |  | ||||||
|     ] |  | ||||||
|  |  | ||||||
| cogs_list = [ |  | ||||||
|     'misc', |     'misc', | ||||||
|     'owner', |     'owner', | ||||||
|     'sing', |     'sing', | ||||||
| @@ -53,25 +40,27 @@ load_dotenv() | |||||||
| intents = discord.Intents.all() | intents = discord.Intents.all() | ||||||
| intents.message_content = True | intents.message_content = True | ||||||
| bot = bridge.Bot(command_prefix=".", intents=intents, | bot = bridge.Bot(command_prefix=".", intents=intents, | ||||||
|                  owner_ids=owners, activity=bot_activity, |                  owner_ids=OWNERS, activity=bot_activity, | ||||||
|                  help_command=commands.MinimalHelpCommand()) |                  help_command=commands.MinimalHelpCommand()) | ||||||
|  |  | ||||||
|  |  | ||||||
| @bot.event | @bot.event | ||||||
| async def on_ready(): | async def on_ready() -> None: | ||||||
|     """Run on Bot Ready""" |     """Run on Bot Ready""" | ||||||
|     logging.info("%s online!", bot.user)   |     logging.info("%s online!", bot.user)   | ||||||
|  |  | ||||||
| def load_exts(initialRun=True): | def load_exts(initialRun: Optional[bool] = True) -> None: | ||||||
|     """Load Cogs/Extensions""" |     """ | ||||||
|  |     Load Cogs/Extensions | ||||||
|  |     Args:  | ||||||
|  |         initialRun (Optional[bool]) default: True | ||||||
|  |     Returns: | ||||||
|  |         None""" | ||||||
|     load_method = bot.load_extension if initialRun else bot.reload_extension |     load_method = bot.load_extension if initialRun else bot.reload_extension | ||||||
|  |  | ||||||
|     for cog in cogs_list: |     for cog in cogs_list: | ||||||
|         logging.info("Loading: %s", cog) |         logging.info("Loading: %s", cog) | ||||||
|         load_method(f'cogs.{cog}')    |         load_method(f'cogs.{cog}')    | ||||||
|  |  | ||||||
|     # asyncio.get_event_loop().create_task(bot.sync_commands()) |  | ||||||
|  |  | ||||||
|     importlib.reload(api) |     importlib.reload(api) | ||||||
|     from api import API  # pylint: disable=unused-import     |     from api import API  # pylint: disable=unused-import     | ||||||
|     api_config = hypercorn.config.Config() |     api_config = hypercorn.config.Config() | ||||||
| @@ -79,15 +68,18 @@ def load_exts(initialRun=True): | |||||||
|     api_instance = api.API(bot) |     api_instance = api.API(bot) | ||||||
|     try: |     try: | ||||||
|         bot.fapi_task.cancel() |         bot.fapi_task.cancel() | ||||||
|     except: |     except Exception as e: | ||||||
|         pass |         logging.debug("Failed to cancel fapi_task: %s",  | ||||||
|  |                       str(e)) | ||||||
|      |      | ||||||
|     logging.info("Starting FAPI Task") |     logging.info("Starting FAPI Task") | ||||||
|  |  | ||||||
|     bot.fapi_task = bot.loop.create_task(hypercorn.asyncio.serve(api_instance.api_app, api_config))  |     bot.fapi_task = bot.loop.create_task(hypercorn.asyncio.serve(api_instance.api_app, | ||||||
|  |                                                                  api_config))  | ||||||
|              |              | ||||||
| def __init__(): | def __init__() -> None: | ||||||
|     logging.info(colored(f"Log level: {logging.getLevelName(logging.root.level)}", "red", attrs=['reverse'])) |     logging.info(colored(f"Log level: {logging.getLevelName(logging.root.level)}", | ||||||
|  |                          "red", attrs=['reverse'])) | ||||||
|     bot.BOT_CHANIDS = BOT_CHANIDS |     bot.BOT_CHANIDS = BOT_CHANIDS | ||||||
|     bot.load_exts = load_exts |     bot.load_exts = load_exts | ||||||
|     bot.load_exts() |     bot.load_exts() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user