Ошибка в discord.py будто он не может что-то импортировать из disnake
Вот ошибка:
Traceback (most recent call last):
File "C:\discord bot\test\main.py", line 2, in <module>
import discord
File "C:\Users\scamm\AppData\Local\Programs\Python\lib\site-packages\discord\__init__.py", line 23, in <module>
from .client import *
File "C:\Users\scamm\AppData\Local\Programs\Python\lib\site-packages\discord\client.py", line 67, in <module>
from .state import ConnectionState
File "C:\Users\scamm\AppData\Local\Programs\Python\lib\site-packages\discord\state.py", line 70, in <module>
from .interactions import Interaction
File "C:\Users\scamm\AppData\Local\Programs\Python\lib\site-packages\discord\interactions\__init__.py", line 1, in <module>
from .base import *
File "C:\Users\scamm\AppData\Local\Programs\Python\lib\site-packages\discord\interactions\base.py", line 1, in <module>
from disnake.interactions.base import *
ImportError: cannot import name 'ClientException' from 'disnake.interactions.base' (C:\Users\scamm\AppData\Local\Programs\Python\lib\site-packages\disnake\interactions\base.py)
Код (не мой, но ошибку выдает практически что бы я не написал). Если не сложно укажите подробно ошибку или сразу исправленный код:
import discord
from discord.ext import commands, tasks
import os
import youtube_dl
intents = discord.Intents().all()
client = discord.Client(intents=intents)
bot = commands.Bot(command_prefix='!', intents=intents)
youtube_dl.utils.bug_reports_message = lambda: ''
ytdl_format_options = {
'format': 'bestaudio/best',
'restrictfilenames': True,
'noplaylist': True,
'nocheckcertificate': True,
'ignoreerrors': False,
'logtostderr': False,
'quiet': True,
'no_warnings': True,
'default_search': 'auto',
'source_address': '0.0.0.0' # bind to ipv4 since ipv6 addresses cause issues sometimes
}
ffmpeg_options = {
'options': '-vn'
}
ytdl = youtube_dl.YoutubeDL(ytdl_format_options)
class YTDLSource(discord.PCMVolumeTransformer):
def __init__(self, source, *, data, volume=0.5):
super().__init__(source, volume)
self.data = data
self.title = data.get('title')
self.url = ""
@classmethod
async def from_url(cls, url, *, loop=None, stream=False):
loop = loop or asyncio.get_event_loop()
data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=not stream))
if 'entries' in data:
# take first item from a playlist
data = data['entries'][0]
filename = data['title'] if stream else ytdl.prepare_filename(data)
return filename
@bot.command(name='play_song', help='To play song')
async def play(ctx, url):
server = ctx.message.guild
voice_channel = server.voice_client
async with ctx.typing():
filename = await YTDLSource.from_url(url, loop=bot.loop)
voice_channel.play(discord.FFmpegPCMAudio(executable="C:\\discord bot\\test\\ffmpeg.exe",
source=filename))
await ctx.send('**Now playing:** {}'.format(filename))
@bot.command(name='join', help='Tells the bot to join the voice channel')
async def join(ctx):
if not ctx.message.author.voice:
await ctx.send("{} is not connected to a voice channel".format(ctx.message.author.name))
return
else:
channel = ctx.message.author.voice.channel
await channel.connect()
@bot.command(name='pause', help='This command pauses the song')
async def pause(ctx):
voice_client = ctx.message.guild.voice_client
if voice_client.is_playing():
await voice_client.pause()
else:
await ctx.send("The bot is not playing anything at the moment.")
@bot.command(name='resume', help='Resumes the song')
async def resume(ctx):
voice_client = ctx.message.guild.voice_client
if voice_client.is_paused():
await voice_client.resume()
else:
await ctx.send("The bot was not playing anything before this. Use play_song command")
@bot.command(name='leave', help='To make the bot leave the voice channel')
async def leave(ctx):
voice_client = ctx.message.guild.voice_client
if voice_client.is_connected():
await voice_client.disconnect()
else:
await ctx.send("The bot is not connected to a voice channel.")
@bot.command(name='stop', help='Stops the song')
async def stop(ctx):
voice_client = ctx.message.guild.voice_client
if voice_client.is_playing():
await voice_client.stop()
else:
await ctx.send("The bot is not playing anything at the moment.")
if __name__ == "__main__":
bot.run("токен") ```