Skip to content

Commit

Permalink
use raise instead of logger.send_error
Browse files Browse the repository at this point in the history
  • Loading branch information
xsnowstorm committed Nov 4, 2023
1 parent 9f42046 commit 6cfdd58
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
3 changes: 2 additions & 1 deletion bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,8 @@ async def on_message(message: discord.Message):
or not bot.is_ready()
or message.channel.id == config.general_channel
):
await bot.event_manager.event_map()["on_message"].execute(message)
if not "on_message.py" in Config.testing["ignored_files"]:
await bot.event_manager.event_map()["on_message"].execute(message)
return

command, arguments = parse_user_input(message.content[len(config.prefix) :])
Expand Down
19 changes: 8 additions & 11 deletions bot/commands/utility/help.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import asyncio

from bot.base import Command, Logger
from bot.base import Command
from bot.config import Config, Embed


class cmd(Command):
"""Help command."""

Expand Down Expand Up @@ -45,7 +44,7 @@ async def category_help(self, message, name="") -> None:
title=f"{name} - Page {page+1} / {len(categories)+1}",
description=f"List of all commands and their description\nRun `{Config.prefix}{self.usage}` to get information about a specific command (still wip).\n\n",
)
embed.set_author(name=f"Help menu")
embed.set_author(name="Help menu")

for idx, command in zip(range(len(commands)), commands):
print(command, idx)
Expand All @@ -68,7 +67,7 @@ def check(reaction, user):
]

try:
reaction, user = await self.bot.wait_for(
reaction, _ = await self.bot.wait_for(
"reaction_add", timeout=120.0, check=check
)
except asyncio.TimeoutError:
Expand Down Expand Up @@ -107,7 +106,7 @@ def check(reaction, user):
return user == message.author and str(reaction.emoji) in ["↩️"]

try:
reaction, user = await self.bot.wait_for(
reaction, _ = await self.bot.wait_for(
"reaction_add", timeout=120.0, check=check
)
except asyncio.TimeoutError:
Expand Down Expand Up @@ -145,8 +144,8 @@ async def execute(self, arguments, message) -> None:
i.prefix: i for i in self.manager.categories if i.prefix is not None
}[args[0]].commands_map()[args[1]]
return await self.command_help(message, cmdobj)
except KeyError:
raise KeyError(f"Command {args[0]} {args[1]} not found")
except KeyError as exc:
raise KeyError(f"Command {args[0]} {args[1]} not found") from exc
except IndexError:
return await self.category_help(message, args[0])
else:
Expand All @@ -161,8 +160,6 @@ async def execute(self, arguments, message) -> None:
]
cmdobj = [i for i in cmdobj if len(i) != 0][0][0]
return await self.command_help(message, cmdobj)
except IndexError:
return await Logger.send_error(
f"Command '{args[0]}' not found", message
)
except IndexError as exc:
raise IndexError(f"Command '{args[0]}' not found") from exc
return await self.command_help(message, cmdobj)

0 comments on commit 6cfdd58

Please sign in to comment.