Author SHA1 Message Date
matthew f81c89119c Gotta remove shit to be compliant yaknow 2022-12-07 00:13:52 +01:00
5 changed files with 20 additions and 15 deletions
+8 -5
View File
@@ -129,12 +129,15 @@ class TuneBot(commands.Bot):
self.lavalink = self.create_lavalink(self.user.id) self.lavalink = self.create_lavalink(self.user.id)
def create_lavalink(self, user_id: int) -> "lavalink.Client": def create_lavalink(self, user_id: int) -> "lavalink.Client":
nodes = self.config["nodes"] cfg = self.config["lavalink"]
client: lavalink.Client = lavalink.Client(user_id, player=CustomPlayer) client: lavalink.Client = lavalink.Client(user_id, player=CustomPlayer)
# get the lavalink nodes from the config client.add_node(
for node in nodes: cfg["host"],
client.add_node(nodes[node]["host"], nodes[node]["port"], nodes[node]["password"], nodes[node]["region"], nodes[node]["name"]) cfg["port"],
cfg["password"],
cfg["region"],
cfg["name"],
)
return client return client
async def get_context(self, message: Message, *, cls=CustomContext): async def get_context(self, message: Message, *, cls=CustomContext):
+2
View File
@@ -26,6 +26,7 @@ class MusicCog(BaseCog, name="Music"):
self.bot.lavalink.add_event_hook(self.track_hook) self.bot.lavalink.add_event_hook(self.track_hook)
"""
@commands.Cog.listener() @commands.Cog.listener()
async def on_ready(self): async def on_ready(self):
while not self.is_lavalink_ready(): while not self.is_lavalink_ready():
@@ -43,6 +44,7 @@ class MusicCog(BaseCog, name="Music"):
await player.play() await player.play()
except: except:
logger.error(f"Failed to autojoin guild {guild_id}.") logger.error(f"Failed to autojoin guild {guild_id}.")
"""
async def track_hook(self, event: lavalink.Event): async def track_hook(self, event: lavalink.Event):
if isinstance(event, lavalink.events.QueueEndEvent): if isinstance(event, lavalink.events.QueueEndEvent):
+2 -2
View File
@@ -1,7 +1,7 @@
from discord.ext import commands from discord.ext import commands
from bot import TuneBot from bot import TuneBot
from cogs.settings.interactions import SettingCommands #from cogs.settings.interactions import SettingCommands
from cogs.settings.interactions import SourceCommands from cogs.settings.interactions import SourceCommands
from context import CustomContext from context import CustomContext
from utils.classes import BaseCog from utils.classes import BaseCog
@@ -13,5 +13,5 @@ class SettingsCog(BaseCog, name="Settings"):
async def setup(bot: TuneBot): async def setup(bot: TuneBot):
await bot.add_cog(SettingsCog(bot)) await bot.add_cog(SettingsCog(bot))
bot.tree.add_command(SettingCommands(bot), override=True) #bot.tree.add_command(SettingCommands(bot), override=True)
bot.tree.add_command(SourceCommands(bot), override=True) bot.tree.add_command(SourceCommands(bot), override=True)
+2
View File
@@ -105,6 +105,7 @@ class SourceCommands(app_commands.Group):
await ctx.response.send_message(embed=embed) await ctx.response.send_message(embed=embed)
"""
class SettingCommands(app_commands.Group): class SettingCommands(app_commands.Group):
def __init__(self, bot: "TuneBot"): def __init__(self, bot: "TuneBot"):
super().__init__(name="settings", description="Tweak and customize") super().__init__(name="settings", description="Tweak and customize")
@@ -143,3 +144,4 @@ class SettingCommands(app_commands.Group):
await autojoin.disable() await autojoin.disable()
embed.title = "AutoJoin disabled" embed.title = "AutoJoin disabled"
await ctx.response.send_message(embed=embed) await ctx.response.send_message(embed=embed)
"""
+1 -3
View File
@@ -8,14 +8,12 @@
"prefix": "ck!", "prefix": "ck!",
"redis_url": "", "redis_url": "",
"redis_prefix": "", "redis_prefix": "",
"nodes": { "lavalink": {
"example": {
"host": "", "host": "",
"port": 2333, "port": 2333,
"password": "", "password": "",
"region": "", "region": "",
"name": "" "name": ""
}
}, },
"colors": { "colors": {
"embed": "7289da" "embed": "7289da"