database rewrite

This commit is contained in:
2021-11-19 21:10:29 +01:00
parent 998749f1ef
commit ebb07960bf
18 changed files with 435 additions and 76 deletions
+5 -9
View File
@@ -4,24 +4,20 @@ import re
from typing import Optional
import discord
from discord.channel import TextChannel
from discord.ext.commands.context import Context
from discord.ext.commands.errors import CommandError
import lavalink
from discord import Embed
from discord.channel import TextChannel
from discord.ext import commands
from discord.ext.commands.context import Context
from discord.ext.commands.errors import CommandError
from lavalink.models import AudioTrack
from lavalink.models import DefaultPlayer
from bot import TuneBot
from utils.classes import BaseCog
from context import CustomContext
from utils.database import AutoJoin
from utils.database import Playlist
from utils.exceptions import EmbeddedCommandException
from utils.classes import BaseCog
from utils.EmbedGenerator import EmbedGenerator
from utils.exceptions import EmbeddedCommandException
url_rx = re.compile(r"https?://(?:www\.)?.+")
@@ -92,7 +88,7 @@ class Music(BaseCog):
await self.async_init()
async def async_init(self):
redis_result = await AutoJoin.get_channels(self.bot._redis_client)
redis_result = await self.bot.global_autojoin.fetch_channels()
while len(self.bot.lavalink.node_manager.available_nodes) == 0:
await asyncio.sleep(1)
@@ -112,7 +108,7 @@ class Music(BaseCog):
await textchannel.send("Automatically joined the voice channel")
async def fill_player_queue(self, player: DefaultPlayer, buffer: Optional[int] = 1):
queries = await Playlist.random(self.bot._redis_client, buffer)
queries = await self.bot.global_playlist.pick_random(buffer)
# Get the results for the query from Lavalink.
for query in queries:
result = await player.node.get_tracks(query)