t_music.py
from interactions import *
from music.music import *
class NotMusic(Extension):
@slash_command()
@slash_option('t', 'test', OptionType.STRING, required=True)
async def music_test(self, ctx: SlashContext, t: str):
await ctx.defer()
await ctx.send('downloading track')
await add_search(t, ctx)
wtf_is_going_on = get_queue(ctx)[0]
if wtf_is_going_on.error == TrackError.PROCESSING:
return await ctx.send('you fucked up man im sorry')
await ctx.send(f'found **{wtf_is_going_on.title}**')
await play_track(ctx)
await ctx.send('Finished downloading track :)')
music.py
async def play_track(ctx: Union[SlashContext, ComponentContext], track_id: int = 0):
q = get_queue(ctx)
if len(q) == 0:
return 'empty_queue'
target_track = q[track_id]
del global_queue[ctx.guild_id][track_id]
directory = f'bot/music/output/{str(ctx.guild_id)}'
file_directory = os.path.join(directory + '/output')
if not ctx.voice_state:
await ctx.author.voice.channel.connect()
audio = await AudioVolume(file_directory)
await ctx.send(f"Now Playing: **{target_track.title}**\n{target_track.thumbnail}")
await ctx.voice_state.play(audio)