Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make alias console specific by not using alias #1270

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions utils/mdcmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ async def simple_cmd(self, ctx: commands.Context):
return cmd_obj

new_commands: 'dict[str, dict[str, discord.Embed]]' = defaultdict(dict)
aliases: 'dict[str, list[str]]' = defaultdict(list)
aliases_map: 'dict[str, str]' = {}
cooldowns: 'dict[str, tuple[int, int]]' = {}
helpdescs: 'dict[str, Optional[str]]' = defaultdict(lambda: None)

Expand All @@ -236,8 +236,13 @@ async def simple_cmd(self, ctx: commands.Context):
for md in iglob(join(md_dir, '*.md')):
command, console, header, embed = md_file_to_embed(md, format_map)
new_commands[command][console] = embed
aliases_map[command] = command
if header['aliases']:
aliases[command].extend(header['aliases'].split(','))
for alias in header['aliases'].split(','):
alias = alias.strip()
new_commands[alias][console] = embed
# this will break if the same alias point to different command in different consoles, but hope that's fine
aliases_map[alias] = command
if header['help-desc']:
# in case some don't have a help-desc, don't delete a previous one
helpdescs[command] = header['help-desc']
Expand All @@ -253,8 +258,7 @@ async def simple_cmd(self, ctx: commands.Context):
continue
elif len(embed_dict) == 1 and not any(x in embed_dict for x in system_ignore_filter):
continue
new_aliases = list(set(aliases[command]))
command_obj = make_cmd(command, helpdescs[command], embed_dict, cooldowns[command], new_aliases)
command_obj = make_cmd(command, helpdescs[aliases_map[command]], embed_dict, cooldowns[aliases_map[command]], list())
setattr(cog_class, command, command_obj)
# there has to be a better way to do this...
cog_class.__cog_commands__.append(command_obj)