Нужна помощь в создании декоративного музыкального ботаPython

Программы на Python
Ответить Пред. темаСлед. тема
Anonymous
 Нужна помощь в создании декоративного музыкального бота

Сообщение Anonymous »

Я делаю музыкальный бот, и я борюсь с некоторыми частями. Я не знаю, как сделать часть пропуска или сыграть следующую песню в очереди, как только текущий заканчивается. Есть помощь?
Вот весь код (все это, потому что на всякий случай) < /p>
часть очереди находится в нижней части, часть пропуска также находится рядом с дном, и игра песня находится прямо здесь. < /P>
import os
import re
import urllib.request
import youtube_dl
import shutil
import discord

from discord.ext import commands
from discord.utils import get

bot = commands.Bot(command_prefix='g.')
token = ''

@bot.command(pass_context=True)
async def play(ctx, *args: str):
search = '+'.join(args)
print(search)
if search == " ":
await ctx.send("Uso: g.play (Video)")
return
else:
html = urllib.request.urlopen("https://www.youtube.com/results?search_query=" + search)
video_ids = re.findall(r"watch\?v=(\S{11})", html.read().decode())
url = "https://www.youtube.com/watch?v=" + video_ids[0]
print(url)

def check_queue():
Queue_infile = os.path.isdir("./Queue")
if Queue_infile is True:
DIR = os.path.abspath(os.path.realpath("Queue"))
length = len(os.listdir(DIR))
still_q = length - 1
try:
first_file = os.listdir(DIR)[0]
except:
print("No more queued song(s)\n")
queues.clear()
return
main_location = os.path.dirname(os.path.realpath(__file__))
song_path = os.path.abspath(os.path.realpath("Queue") + "\\" + first_file)
if length != 0:
print("Song done, playing next queued\n")
print(f"Songs still in queue: {still_q}")
song_there = os.path.isfile("song.mp3")
if song_there:
os.remove("song.mp3")
shutil.move(song_path, main_location)
for file in os.listdir("./"):
if file.endswith(".mp3"):
os.rename(file, 'song.mp3')
enfile = file

voice.play(discord.FFmpegPCMAudio("song.mp3"), after=lambda e: check_queue())
voice.source = discord.PCMVolumeTransformer(voice.source)
voice.source.volume = 0.07
print(f"Playing {nname[0]}")

else:
queues.clear()
return
else:
queues.clear()
print("No songs were queued before the ending of the last song\n")

song_there = os.path.isfile("song.mp3")
try:
if song_there:
os.remove("song.mp3")
queues.clear()
print("Removed old song file")
except PermissionError:
print("Trying to delete song file, but it's being played.")
print("ERROR: Music Playing")
await ctx.send("Error: Ya estoy poniendo musica! Usa g.queue (cancion) para agregar una cancion a la lista.")
search = ' '.join(args)
channel = ctx.message.channel
return

Queue_infile = os.path.isdir("./Queue")
try:
Queue_folder = "./Queue"
if Queue_infile is True:
print("Removed old Queue Folder")
shutil.rmtree(Queue_folder)
except:
print("No old queue folder.")

print("Getting everytihng ready now.")
await ctx.send("Preparando cancion...")

voice = get(bot.voice_clients, guild=ctx.guild)

ydl_opts = {
'format': 'bestaudio/best',
'quiet': True,
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',

}],
}

with youtube_dl.YoutubeDL(ydl_opts) as ydl:
print("Downloading audio now\n")
ydl.download() for file in os.listdir("./"): if fil ... -music-bot
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение
  • Как создать музыкального бота для голосового чата в Telegram на Java?
    Гость » » в форуме JAVA
    0 Ответы
    82 Просмотры
    Последнее сообщение Гость
  • Нужна ли мне скрытая ария для декоративного внутри
    Anonymous » » в форуме Html
    0 Ответы
    9 Просмотры
    Последнее сообщение Anonymous
  • Нужна ли мне скрытая ария для декоративного внутри
    Anonymous » » в форуме Html
    0 Ответы
    6 Просмотры
    Последнее сообщение Anonymous
  • Нужна ли мне скрытая ария для декоративного внутри
    Anonymous » » в форуме Html
    0 Ответы
    6 Просмотры
    Последнее сообщение Anonymous
  • Поиск места для хранения музыкального файла
    Anonymous » » в форуме IOS
    0 Ответы
    15 Просмотры
    Последнее сообщение Anonymous

Вернуться в «Python»