Skip to content

Commit

Permalink
[Discord] Separate audio file and file into distinct commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Harmon758 committed Nov 20, 2023
1 parent 7ea2325 commit 3275f62
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions Discord/cogs/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def __init__(self, bot):
command.parent is None and
name not in (
"audio", "join", "leave", "pause", "resume", "replay",
"empty", "shuffle", "queue", "deafen", "mute", "undeafen",
"unmute"
"empty", "shuffle", "file", "queue", "deafen", "mute",
"undeafen", "unmute"
)
):
self.bot.add_command(command)
Expand Down Expand Up @@ -576,17 +576,30 @@ async def tts_options(
"Please stop it first"
)

@commands.command()
@audio.command(name = "file")
@checks.is_voice_connected()
@commands.check_any(checks.is_permitted(), checks.is_guild_owner())
async def file(self, ctx, *, filename: str = ""):
async def audio_file(self, ctx, *, filename: str = ""):
'''Play an audio file'''
# Note: file command invokes this command
if not (await self.players[ctx.guild.id].play_file(ctx, filename)):
await ctx.embed_reply(
":warning: Something else is already playing\n"
"Please stop it first"
)

@commands.command()
@checks.is_voice_connected()
@commands.check_any(checks.is_permitted(), checks.is_guild_owner())
async def file(self, ctx, *, filename: str = ""):
'''Play an audio file'''
if command := ctx.bot.get_command("audio file", filename = filename):
await ctx.invoke(command)
else:
raise RuntimeError(
"audio file command not found when file command invoked"
)

@commands.command()
@checks.not_forbidden()
@checks.is_voice_connected()
Expand Down

0 comments on commit 3275f62

Please sign in to comment.