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(
|
return next(
|
||||||
(
|
(
|
||||||
(cmd, self.commands[cmd.lower()])
|
(cmd, self.commands[cmd.split()[0].lower()])
|
||||||
for cmd in [
|
for cmd in [
|
||||||
_command,
|
_command,
|
||||||
self.aliases.get(_command.lower()),
|
self.aliases.get(_command.lower()),
|
||||||
self.find_alias(_command),
|
self.find_alias(_command),
|
||||||
]
|
]
|
||||||
if cmd and cmd.lower() in self.commands
|
if cmd and cmd.split()[0].lower() in self.commands
|
||||||
),
|
),
|
||||||
(_command, None),
|
(_command, None),
|
||||||
)
|
)
|
||||||
|
@ -1165,12 +1165,12 @@ class Modules:
|
||||||
handler.id,
|
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"""
|
"""Make an alias"""
|
||||||
if cmd not in self.commands:
|
if cmd not in self.commands:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.aliases[alias.lower().strip()] = cmd
|
self.aliases[alias.lower().strip()] = f"{cmd} {args}" if args else cmd
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def remove_alias(self, alias: str) -> bool:
|
def remove_alias(self, alias: str) -> bool:
|
||||||
|
|
|
@ -240,17 +240,18 @@ class CoreMod(loader.Module):
|
||||||
|
|
||||||
@loader.command()
|
@loader.command()
|
||||||
async def addalias(self, message: Message):
|
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"))
|
await utils.answer(message, self.strings("alias_args"))
|
||||||
return
|
return
|
||||||
|
|
||||||
alias, cmd = args
|
alias, cmd, *rest = args
|
||||||
if self.allmodules.add_alias(alias, cmd):
|
rest = " ".join(rest) if rest else None
|
||||||
|
if self.allmodules.add_alias(alias, cmd, rest):
|
||||||
self.set(
|
self.set(
|
||||||
"aliases",
|
"aliases",
|
||||||
{
|
{
|
||||||
**self.get("aliases", {}),
|
**self.get("aliases", {}),
|
||||||
alias: cmd,
|
alias: f"{cmd} {rest}" if rest else cmd,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
await utils.answer(
|
await utils.answer(
|
||||||
|
|
Loading…
Reference in New Issue