Skip to content

Commit

Permalink
Merge pull request #187 from xsnowstorm/fix
Browse files Browse the repository at this point in the history
Fixed help command
  • Loading branch information
logicguy1 authored Nov 5, 2023
2 parents baefd7d + 6cfdd58 commit 271d331
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 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
23 changes: 10 additions & 13 deletions bot/commands/utility/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
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 @@ -155,14 +154,12 @@ async def execute(self, arguments, message) -> None:
except KeyError:
try:
cmdobj = [
[c for c in i.commands if c.name == command]
for i in bot.manager.categories
[c for c in i.commands if c.name == args[0]]
for i in self.manager.categories
if i.prefix is None
]
cmdobj = [i for i in cmdobj if len(i) != 0][0][0]
return self.command_help(message, cmdobj)
except IndexError:
return await logger.send_error(
f"Command '{command}' not found", message
)
return await self.command_help(message, cmdobj)
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 271d331

Please sign in to comment.