def _play(self, ctx: DogbotContext, url, *, search=False):
msg = await ctx.send(f'\N{INBOX TRAY} {random.choice(SEARCHING_TEXT)}')
# grab the source
url = 'ytsearch:' + url if search else url
try:
source = await YouTubeDLSource.create(url, ctx.bot)
except youtube_dl.DownloadError:
return await msg.edit(content='\U0001f4ed YouTube gave me nothing.')
except YouTubeError as yterr:
return await msg.edit(content='\N{CROSS MARK} ' + str(yterr))
disp = '**{}**'.format(source.title)
state = self.state_for(ctx.guild)
if state.is_playing():
# add it to the queue
log.debug('Adding to queue.')
state.queue.append(source)
await msg.edit(content=f'\N{LINKED PAPERCLIPS} Added {disp} to queue.')
else:
# play immediately since we're not playing anything
log.debug('Playing immediately.')
state.play(source)
await msg.edit(content=f'\N{MULTIPLE MUSICAL NOTES} Playing {disp}.')
评论列表
文章目录