mirror of https://github.com/coddrago/Heroku
Merge branch 'dev-test' of https://github.com/coddrago/Heroku into dev-test
commit
3105a9c36c
|
@ -923,13 +923,13 @@ class Modules:
|
|||
|
||||
return next(
|
||||
(
|
||||
(cmd, self.commands[cmd.lower()])
|
||||
(cmd, self.commands[cmd.split()[0].lower()])
|
||||
for cmd in [
|
||||
_command,
|
||||
self.aliases.get(_command.lower()),
|
||||
self.find_alias(_command),
|
||||
]
|
||||
if cmd and cmd.lower() in self.commands
|
||||
if cmd and cmd.split()[0].lower() in self.commands
|
||||
),
|
||||
(_command, None),
|
||||
)
|
||||
|
@ -1165,12 +1165,12 @@ class Modules:
|
|||
handler.id,
|
||||
)
|
||||
|
||||
def add_alias(self, alias: str, cmd: str) -> bool:
|
||||
def add_alias(self, alias: str, cmd: str, args: str = None) -> bool:
|
||||
"""Make an alias"""
|
||||
if cmd not in self.commands:
|
||||
return False
|
||||
|
||||
self.aliases[alias.lower().strip()] = cmd
|
||||
self.aliases[alias.lower().strip()] = f"{cmd} {args}" if args else cmd
|
||||
return True
|
||||
|
||||
def remove_alias(self, alias: str) -> bool:
|
||||
|
|
|
@ -240,17 +240,18 @@ class CoreMod(loader.Module):
|
|||
|
||||
@loader.command()
|
||||
async def addalias(self, message: Message):
|
||||
if len(args := utils.get_args(message)) != 2:
|
||||
if len(args := utils.get_args(message)) < 2:
|
||||
await utils.answer(message, self.strings("alias_args"))
|
||||
return
|
||||
|
||||
alias, cmd = args
|
||||
if self.allmodules.add_alias(alias, cmd):
|
||||
alias, cmd, *rest = args
|
||||
rest = " ".join(rest) if rest else None
|
||||
if self.allmodules.add_alias(alias, cmd, rest):
|
||||
self.set(
|
||||
"aliases",
|
||||
{
|
||||
**self.get("aliases", {}),
|
||||
alias: cmd,
|
||||
alias: f"{cmd} {rest}" if rest else cmd,
|
||||
},
|
||||
)
|
||||
await utils.answer(
|
||||
|
|
Loading…
Reference in New Issue