когда я пытаюсь запустить свой код, он запускается. но после ввода команды в Discord я получаю эту ошибку:
ОШИБКА: [youtube] ZGZKhMsjcPc: войдите в систему, чтобы подтвердить, что вы не бот. Я тестировал этот код в Visual Studio, там все работало нормально, но когда я загрузил его на свой хост-сайт (sillydev), он больше не работал
это мой код:
#Music Bot
class MusicBot(commands.Cog):
def __init__(self, client):
self.client = client
self.queue = []
self.loop_queue = False
self.is_paused = False
self.previous_songs = [] # Stack to keep track of previously played songs
@app_commands.command(name="play", description="Play a song from YouTube")
async def play(self, interaction: discord.Interaction, search: str):
voice_channel = interaction.user.voice.channel if interaction.user.voice else None
if not voice_channel:
return await interaction.response.send_message("You are not in a voice channel", ephemeral=True)
if not interaction.guild.voice_client:
await voice_channel.connect()
# Defer the response to allow for time to process the download
await interaction.response.defer()
try:
with yt_dlp.YoutubeDL(YDL_OPTIONS) as ydl:
info = ydl.extract_info(f"ytsearch:{search}", download=False)
if 'entries' in info:
info = info['entries'][0]
url = info['url']
title = info['title']
duration = info['duration'] # Duration in seconds
thumbnail = info.get('thumbnail') # Get the thumbnail URL if available
self.queue.append((url, title, duration, thumbnail, interaction.user)) # Append the requester
# Send a simple message when a song is added to the queue
await interaction.followup.send(f'Added to queue: **{title}**')
# Check if audio is playing
if not interaction.guild.voice_client.is_playing():
await self.play_next(interaction.guild.voice_client, interaction.channel)
except Exception as e:
await interaction.followup.send(f"An error occurred: {e}")
return
async def play_next(self, voice_client, channel):
if self.queue:
url, title, duration, thumbnail, requester = self.queue.pop(0) # Unpack the requester
source = await discord.FFmpegOpusAudio.from_probe(url, **FFMPEG_OPTIONS)
voice_client.play(source, after=lambda _: self.client.loop.create_task(self.play_next(voice_client, channel)))
# Keep track of the previous song
self.previous_songs.append((url, title, duration, thumbnail, requester))
# Create an embedded message for the currently playing song
embed = discord.Embed(title="Now Playing", description=f"**{title}**", color=discord.Color.blue())
embed.set_author(name=voice_client.guild.name, icon_url=voice_client.guild.icon.url if voice_client.guild.icon else None)
embed.add_field(name="Duration", value=self.format_duration(duration), inline=True)
embed.add_field(name="Queue Length", value=str(len(self.queue)), inline=True)
if thumbnail:
embed.set_thumbnail(url=thumbnail)
embed.set_footer(text=f"Requested by: {requester.display_name}")
# Re-add to the queue if looping is enabled
if self.loop_queue:
self.queue.append((url, title, duration, thumbnail, requester))
elif not voice_client.is_playing():
await channel.send("Queue is empty!")
async def setup(client):
await client.add_cog(MusicBot(client))
i looked for code changes but nothing worked.
Подробнее здесь: https://stackoverflow.com/questions/787 ... -not-a-bot
ОШИБКА: [youtube] ZGZKhMsjcPc: Войдите в систему, чтобы подтвердить, что вы не бот. ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Войдите в систему, чтобы подтвердить, что вы не бот на сайте act-native-youtube-iframe.
Anonymous » » в форуме Android - 0 Ответы
- 48 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Музыкальный бот Discord, когда я пропускаю трек, бот пропускает сразу 2 трека
Anonymous » » в форуме Python - 0 Ответы
- 41 Просмотры
-
Последнее сообщение Anonymous
-