test fix
This commit is contained in:
parent
a00a006995
commit
5b464883bf
1 changed files with 4 additions and 10 deletions
14
main.py
14
main.py
|
@ -5,37 +5,31 @@ import os
|
||||||
from fuzzywuzzy import process
|
from fuzzywuzzy import process
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
load_dotenv() # Load environment variables from .env file
|
load_dotenv()
|
||||||
|
|
||||||
intents = discord.Intents.default()
|
intents = discord.Intents.default()
|
||||||
intents.message_content = True
|
intents.message_content = True
|
||||||
intents.voice_states = True
|
intents.voice_states = True
|
||||||
|
|
||||||
bot = commands.Bot(command_prefix='!', intents=intents)
|
bot = commands.Bot(command_prefix='!', intents=intents)
|
||||||
|
queued_songs = []
|
||||||
|
|
||||||
def find_song(query, songs_dir):
|
def find_song(query, songs_dir):
|
||||||
# Initialize variables to store the best match and confidence
|
|
||||||
best_match = None
|
best_match = None
|
||||||
best_confidence = 0
|
best_confidence = 0
|
||||||
|
|
||||||
# Recursively search through directories for song files
|
|
||||||
for root, dirs, files in os.walk(songs_dir):
|
for root, dirs, files in os.walk(songs_dir):
|
||||||
for file in files:
|
for file in files:
|
||||||
if file.endswith(".mp3"):
|
if file.endswith(".mp3"):
|
||||||
song_path = os.path.join(root, file)
|
song_path = os.path.join(root, file)
|
||||||
song_name = os.path.relpath(song_path, start=songs_dir) # Get the song name relative to songs_dir
|
#song_name = os.path.relpath(song_path, start=songs_dir)
|
||||||
|
song_name = os.path.splitext(file)[0]
|
||||||
confidence = process.extractOne(query, [song_name])[1]
|
confidence = process.extractOne(query, [song_name])[1]
|
||||||
|
|
||||||
# Update best match if confidence is higher
|
|
||||||
if confidence > best_confidence:
|
if confidence > best_confidence:
|
||||||
best_match = song_path
|
best_match = song_path
|
||||||
best_confidence = confidence
|
best_confidence = confidence
|
||||||
|
|
||||||
return best_match, best_confidence
|
return best_match, best_confidence
|
||||||
|
|
||||||
# Define a global list to store the queued songs
|
|
||||||
queued_songs = []
|
|
||||||
|
|
||||||
@bot.command()
|
@bot.command()
|
||||||
async def play(ctx, *, query):
|
async def play(ctx, *, query):
|
||||||
voice_client = discord.utils.get(bot.voice_clients, guild=ctx.guild)
|
voice_client = discord.utils.get(bot.voice_clients, guild=ctx.guild)
|
||||||
|
|
Loading…
Reference in a new issue