Skip to content

Commit

Permalink
SetupUI and main logging messages minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
GitGinocchio committed Dec 13, 2024
1 parent 0055882 commit fce7a7b
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 16 deletions.
61 changes: 61 additions & 0 deletions notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,67 @@ https://apidocs.cheapshark.com/
https://www.freetogame.com/api-doc
https://www.gamerpower.com/api-read

Ignoring exception in command <nextcord.application_command.SlashApplicationSubcommand object at 0x000001C5384B05F0>:
Traceback (most recent call last):
File "B:\Desktop\Coding\Python\GGsBot\.venv\Lib\site-packages\aiohttp\connector.py", line 1317, in _create_direct_connection
hosts = await self._resolve_host(host, port, traces=traces)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "B:\Desktop\Coding\Python\GGsBot\.venv\Lib\site-packages\aiohttp\connector.py", line 971, in _resolve_host
return await asyncio.shield(resolved_host_task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "B:\Desktop\Coding\Python\GGsBot\.venv\Lib\site-packages\aiohttp\connector.py", line 1002, in _resolve_host_with_throttle
addrs = await self._resolver.resolve(host, port, family=self._family)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "B:\Desktop\Coding\Python\GGsBot\.venv\Lib\site-packages\aiohttp\resolver.py", line 38, in resolve
infos = await self._loop.getaddrinfo(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Software\Python 3.12.1 (64-bit)\Lib\asyncio\base_events.py", line 898, in getaddrinfo
return await self.run_in_executor(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Software\Python 3.12.1 (64-bit)\Lib\concurrent\futures\thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Software\Python 3.12.1 (64-bit)\Lib\socket.py", line 963, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
socket.gaierror: [Errno 11001] getaddrinfo failed

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "B:\Desktop\Coding\Python\GGsBot\.venv\Lib\site-packages\nextcord\application_command.py", line 918, in invoke_callback_with_hooks
await self(interaction, *args, **kwargs)
File "b:\Desktop\Coding\Python\GGsBot\src\commands\games\CheapGames.py", line 190, in add_update
if message:
^^^^^^^^^
File "B:\Desktop\Coding\Python\GGsBot\.venv\Lib\site-packages\nextcord\webhook\async_.py", line 796, in edit
message = await self._state._webhook.edit_message(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "B:\Desktop\Coding\Python\GGsBot\.venv\Lib\site-packages\nextcord\webhook\async_.py", line 1719, in edit_message
data = await adapter.edit_webhook_message(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "B:\Desktop\Coding\Python\GGsBot\.venv\Lib\site-packages\nextcord\webhook\async_.py", line 148, in request
async with session.request(
File "B:\Desktop\Coding\Python\GGsBot\.venv\Lib\site-packages\aiohttp\client.py", line 1359, in __aenter__
self._resp: _RetType = await self._coro
^^^^^^^^^^^^^^^^
File "B:\Desktop\Coding\Python\GGsBot\.venv\Lib\site-packages\aiohttp\client.py", line 663, in _request
conn = await self._connector.connect(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "B:\Desktop\Coding\Python\GGsBot\.venv\Lib\site-packages\aiohttp\connector.py", line 563, in connect
proto = await self._create_connection(req, traces, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "B:\Desktop\Coding\Python\GGsBot\.venv\Lib\site-packages\aiohttp\connector.py", line 1032, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "B:\Desktop\Coding\Python\GGsBot\.venv\Lib\site-packages\aiohttp\connector.py", line 1323, in _create_direct_connection
raise ClientConnectorDNSError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorDNSError: Cannot connect to host discord.com:443 ssl:default [getaddrinfo failed]

The above exception was the direct cause of the following exception:

nextcord.errors.ApplicationInvokeError: Command raised an exception: ClientConnectorDNSError: Cannot connect to host discord.com:443 ssl:default [getaddrinfo failed]

Ignoring exception in command <nextcord.application_command.MessageApplicationCommand object at 0x7c71c08f3cb0>:
Traceback (most recent call last):
File "/home/container/.local/lib/python3.12/site-packages/nextcord/application_command.py", line 918, in invoke_callback_with_hooks
Expand Down
3 changes: 1 addition & 2 deletions src/commands/manager/CommandsManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ async def setup(self,
#1. Inviare una modal o view specifica per quel comando
#2. Ogni modal o view deve avere un pulsante submit e un pulsante cancel (che chiude la modal o view) e altri campi facoltativi per la configurazione

config = {}
if ui_type is not None:
ui = ui_type(self.bot, interaction.guild, extension)
else:
Expand All @@ -126,7 +125,7 @@ async def setup(self,
if message:
await message.edit(e, view=None, embed=None)
else:
await interaction.followup.send(e)
await interaction.followup.send(e, ephemeral=True)
except ExtensionException as e:
await message.edit(embed=e.asEmbed(), view=None)
else:
Expand Down
16 changes: 7 additions & 9 deletions src/commands/music/MusicCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,10 @@ async def leave(self, interaction : nextcord.Interaction):
logger.fatal(e)

def setup(bot : commands.Bot):
try:
assert os.path.exists(ffmpeg_path:=f"{config['music']['ffmpeg_path'].format(os=OS,arch=ARCH)}{'.exe' if OS == 'Windows' else ''}"), f"The extension cannot start, the ffmpeg executable at \'{ffmpeg_path}\' is missing"
assert os.path.isfile(ffmpeg_path), f"The extension cannot start, the ffmpeg executable at \'{ffmpeg_path}\' must be an executable"
if not (permissions:=os.stat(ffmpeg_path).st_mode) & stat.S_IXUSR:
os.chmod(ffmpeg_path, permissions | stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH)
except Exception as e:
logger.critical(e)
else:
bot.add_cog(MusicCommands(bot))
assert os.path.exists(ffmpeg_path:=f"{config['music']['ffmpeg_path'].format(os=OS,arch=ARCH)}{'.exe' if OS == 'Windows' else ''}"), f"The extension cannot start, the ffmpeg executable at \'{ffmpeg_path}\' is missing"
assert os.path.isfile(ffmpeg_path), f"The extension cannot start, the ffmpeg executable at \'{ffmpeg_path}\' must be an executable"

if not (permissions:=os.stat(ffmpeg_path).st_mode) & stat.S_IXUSR:
os.chmod(ffmpeg_path, permissions | stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH)

bot.add_cog(MusicCommands(bot))
7 changes: 4 additions & 3 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,19 @@ def load_commands():
categories = [c for c in os.listdir('./src/commands') if c not in config['ignore_categories']]
logger.info('Loading commands...')
for category in categories:
logger.info(f'Looking in commands.{category}...')
#logger.info(f'Looking in commands.{category}...')
for filename in os.listdir(f'./src/commands/{category}'):
if filename.endswith('.py') and filename not in config['ignore_files']:
try:
Bot.load_extension(f'commands.{category}.{filename[:-3]}')
except (commands.ExtensionFailed,
commands.ExtensionAlreadyLoaded,
except (commands.ExtensionAlreadyLoaded,
commands.ExtensionNotFound,
commands.InvalidSetupArguments) as e:
logger.critical(f'Loading command error: Cog {e.name} message: \n{traceback.format_exc()}')
except commands.NoEntryPointError as e:
continue # if no entry point found maybe is a file used by the main command file.
except commands.ExtensionFailed as e:
logger.warning(e)
else:
logger.info(f'Imported command {F.LIGHTMAGENTA_EX}{category}.{filename[:-3]}{F.RESET}')

Expand Down
4 changes: 2 additions & 2 deletions src/utils/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def __init__(self,
guild : Guild,
title : str,
submit_callback : Callable[[Interaction], None],
timeout : int = 120,
submit_title : str = "Submit"
submit_title : str = "Submit",
timeout : int = 120
):
Embed.__init__(self, title=title)
View.__init__(self, timeout=timeout)
Expand Down

0 comments on commit fce7a7b

Please sign in to comment.