refactor(commands): add purge as an alternative to clear
This commit is contained in:
parent
2060e25f75
commit
59c4b37831
@ -7,6 +7,7 @@ class Command(enum.Enum):
|
|||||||
RELOAD = "reload"
|
RELOAD = "reload"
|
||||||
EXECUTE = "execute"
|
EXECUTE = "execute"
|
||||||
CLEAR = "clear"
|
CLEAR = "clear"
|
||||||
|
PURGE = "purge"
|
||||||
JOIN = "join"
|
JOIN = "join"
|
||||||
LEAVE = "leave"
|
LEAVE = "leave"
|
||||||
QUEUE = "queue"
|
QUEUE = "queue"
|
||||||
|
26
events.py
26
events.py
@ -23,14 +23,15 @@ async def on_message(message):
|
|||||||
|
|
||||||
if len(matched) > 1:
|
if len(matched) > 1:
|
||||||
await message.reply(
|
await message.reply(
|
||||||
f"ambiguous command, could be {' or '.join(['`' + match.value + '`' for match in matched])}",
|
f"ambiguous command, could be {' or '.join([f'`{match.value}`' for match in matched])}",
|
||||||
mention_author=False,
|
mention_author=False,
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
C = commands.Command
|
||||||
try:
|
try:
|
||||||
match matched[0]:
|
match matched[0]:
|
||||||
case commands.Command.EXECUTE if message.author.id in constants.OWNERS:
|
case C.EXECUTE if message.author.id in constants.OWNERS:
|
||||||
code = message.content[len(tokens[0]) + 1 :].strip().strip("`")
|
code = message.content[len(tokens[0]) + 1 :].strip().strip("`")
|
||||||
for replacement in ["python", "py"]:
|
for replacement in ["python", "py"]:
|
||||||
if code.startswith(replacement):
|
if code.startswith(replacement):
|
||||||
@ -75,21 +76,21 @@ async def on_message(message):
|
|||||||
await message.add_reaction("✅")
|
await message.add_reaction("✅")
|
||||||
else:
|
else:
|
||||||
await message.channel.send(output)
|
await message.channel.send(output)
|
||||||
case commands.Command.CLEAR:
|
case C.CLEAR | C.PURGE:
|
||||||
await commands.tools.clear(message)
|
await commands.tools.clear(message)
|
||||||
case commands.Command.JOIN:
|
case C.JOIN:
|
||||||
await commands.voice.join(message)
|
await commands.voice.join(message)
|
||||||
case commands.Command.LEAVE:
|
case C.LEAVE:
|
||||||
await commands.voice.leave(message)
|
await commands.voice.leave(message)
|
||||||
case commands.Command.QUEUE | commands.Command.PLAY:
|
case C.QUEUE | C.PLAY:
|
||||||
await commands.voice.queue_or_play(message)
|
await commands.voice.queue_or_play(message)
|
||||||
case commands.Command.SKIP:
|
case C.SKIP:
|
||||||
await commands.voice.skip(message)
|
await commands.voice.skip(message)
|
||||||
case commands.Command.RESUME:
|
case C.RESUME:
|
||||||
await commands.voice.resume(message)
|
await commands.voice.resume(message)
|
||||||
case commands.Command.PAUSE:
|
case C.PAUSE:
|
||||||
await commands.voice.pause(message)
|
await commands.voice.pause(message)
|
||||||
case commands.Command.VOLUME:
|
case C.VOLUME:
|
||||||
await commands.voice.volume(message)
|
await commands.voice.volume(message)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
await message.reply(
|
await message.reply(
|
||||||
@ -100,7 +101,10 @@ async def on_message(message):
|
|||||||
|
|
||||||
def __reload_module__():
|
def __reload_module__():
|
||||||
for name, module in globals().items():
|
for name, module in globals().items():
|
||||||
if inspect.ismodule(module) and name not in constants.RELOAD_BLACKLISTED_MODULES:
|
if (
|
||||||
|
inspect.ismodule(module)
|
||||||
|
and name not in constants.RELOAD_BLACKLISTED_MODULES
|
||||||
|
):
|
||||||
importlib.reload(module)
|
importlib.reload(module)
|
||||||
if "__reload_module__" in dir(module) and name not in reloaded_modules:
|
if "__reload_module__" in dir(module) and name not in reloaded_modules:
|
||||||
reloaded_modules.add(name)
|
reloaded_modules.add(name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user