mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 18:27:59 -05:00
I promise I'm not doing this on purpose (#4565)
* Prep for 0.7.2 * So What di i do here? I done Magic, magic only found in the tales of old. * turns out formatting is something important * fixes * improved Error handling when Global API is enabled * further improve resuming logic * more of dat dark voodoo blood magic * major tweaks to auto restore when auto play is enabled 👀 * fix duplicated "Auto play stated." message + Auto play restart :feelsgoodman: * missed these * fix the new duplicated fucking message bitch. * Let discord handle player reconnects * eh * `Requires force install`, utilize new Exponential Backoff object on player and safer reconnect logic, emulating d.py and WL. * hmmmmm gotta monitor * mother fucking brackets * Why didnt i consider this the first time????????????? * new error code to handle? * soooooooooooooooo these are import so why arent we ensuring they are set. * improved logging * improved logging * aaaaaaaaaaaaaaa * We need our own error and special handling to not conflict with dpy * (Last Known Bug) Fix the infinite loop of 4006 that sometimes could happen as an edge case after a successful resume. * This will require a force reinstall to install `RLL 0.8.0`, this properly fixes the bug mentioned on the previous commit. * address "Localtrack names/paths need to be escaped." comment * address Fixators crash mentioned in #AT * style * fix preda's crash mentioned in PR * add a thing here add a thing there add a thing everywhere * style * fixes here, fixes there, and backbone for curated playlist. * bypass aiohttp and githubs and cloudflare and yo mammas cache * I propose the new style is no style. * allow curated playlist to be updated it `[p]playlist update` and show the diff * fix `[p]summon` not resuming playback until next track. * Hopefully handle predas rate limits. * what else did i break now * Update Lavalink.jar build * lets try this * reset the queue * Bring Edge commits over fix a bunch of shiz again * Bring Edge commits over fix a bunch of shiz again * Handle 4014 OPs, Change `skip_votes` key to be an int rather than guild object * aaaaaaaaaaaaaaa im dumb * ... * Simplify some shiz + use a set instead of a list for votes. Co-authored-by: aikaterna <20862007+aikaterna@users.noreply.github.com>
This commit is contained in:
@@ -558,7 +558,13 @@ class AudioSetCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
@command_audioset_autoplay.command(name="reset")
|
||||
async def command_audioset_autoplay_reset(self, ctx: commands.Context):
|
||||
"""Resets auto-play to the default playlist."""
|
||||
playlist_data = dict(enabled=False, id=None, name=None, scope=None)
|
||||
playlist_data = dict(
|
||||
enabled=True,
|
||||
id=42069,
|
||||
name="Aikaterna's curated tracks",
|
||||
scope=PlaylistScope.GLOBAL.value,
|
||||
)
|
||||
|
||||
await self.config.guild(ctx.guild).autoplaylist.set(playlist_data)
|
||||
return await self.send_embed_msg(
|
||||
ctx,
|
||||
|
||||
@@ -68,10 +68,14 @@ class PlayerControllerCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
eq = player.fetch("eq")
|
||||
player.queue = []
|
||||
player.store("playing_song", None)
|
||||
player.store("autoplay_notified", False)
|
||||
if eq:
|
||||
await self.config.custom("EQUALIZER", ctx.guild.id).eq_bands.set(eq.bands)
|
||||
await player.stop()
|
||||
await player.disconnect()
|
||||
await self.config.guild_from_id(guild_id=ctx.guild.id).currently_auto_playing_in.set(
|
||||
[]
|
||||
)
|
||||
self._ll_guild_updates.discard(ctx.guild.id)
|
||||
await self.api_interface.persistent_queue_api.drop(ctx.guild.id)
|
||||
|
||||
@@ -91,6 +95,8 @@ class PlayerControllerCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
}
|
||||
expected = tuple(emoji.values())
|
||||
player = lavalink.get_player(ctx.guild.id)
|
||||
player.store("channel", ctx.channel.id)
|
||||
player.store("guild", ctx.guild.id)
|
||||
if player.current:
|
||||
arrow = await self.draw_time(ctx)
|
||||
pos = self.format_time(player.position)
|
||||
@@ -212,7 +218,8 @@ class PlayerControllerCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
title=_("Unable To Manage Tracks"),
|
||||
description=_("You need the DJ role to pause or resume tracks."),
|
||||
)
|
||||
|
||||
player.store("channel", ctx.channel.id)
|
||||
player.store("guild", ctx.guild.id)
|
||||
if not player.current:
|
||||
return await self.send_embed_msg(ctx, title=_("Nothing playing."))
|
||||
description = await self.get_track_description(
|
||||
@@ -266,7 +273,8 @@ class PlayerControllerCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
"to enqueue the previous song tracks."
|
||||
),
|
||||
)
|
||||
|
||||
player.store("channel", ctx.channel.id)
|
||||
player.store("guild", ctx.guild.id)
|
||||
if player.fetch("prev_song") is None:
|
||||
return await self.send_embed_msg(
|
||||
ctx, title=_("Unable To Play Tracks"), description=_("No previous track.")
|
||||
@@ -332,7 +340,8 @@ class PlayerControllerCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
title=_("Unable To Seek Tracks"),
|
||||
description=_("You need the DJ role or be the track requester to use seek."),
|
||||
)
|
||||
|
||||
player.store("channel", ctx.channel.id)
|
||||
player.store("guild", ctx.guild.id)
|
||||
if player.current:
|
||||
if player.current.is_stream:
|
||||
return await self.send_embed_msg(
|
||||
@@ -405,6 +414,8 @@ class PlayerControllerCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
title=_("Unable To Toggle Shuffle"),
|
||||
description=_("You must be in the voice channel to toggle shuffle."),
|
||||
)
|
||||
player.store("channel", ctx.channel.id)
|
||||
player.store("guild", ctx.guild.id)
|
||||
|
||||
shuffle = await self.config.guild(ctx.guild).shuffle()
|
||||
await self.config.guild(ctx.guild).shuffle.set(not shuffle)
|
||||
@@ -448,6 +459,8 @@ class PlayerControllerCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
title=_("Unable To Toggle Shuffle"),
|
||||
description=_("You must be in the voice channel to toggle shuffle."),
|
||||
)
|
||||
player.store("channel", ctx.channel.id)
|
||||
player.store("guild", ctx.guild.id)
|
||||
|
||||
bumped = await self.config.guild(ctx.guild).shuffle_bumped()
|
||||
await self.config.guild(ctx.guild).shuffle_bumped.set(not bumped)
|
||||
@@ -504,7 +517,8 @@ class PlayerControllerCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
title=_("Unable To Skip Tracks"),
|
||||
description=_("You can only skip the current track."),
|
||||
)
|
||||
|
||||
player.store("channel", ctx.channel.id)
|
||||
player.store("guild", ctx.guild.id)
|
||||
if vote_enabled:
|
||||
if not can_skip:
|
||||
if skip_to_track is not None:
|
||||
@@ -516,10 +530,10 @@ class PlayerControllerCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
),
|
||||
)
|
||||
if ctx.author.id in self.skip_votes[ctx.guild.id]:
|
||||
self.skip_votes[ctx.guild.id].remove(ctx.author.id)
|
||||
self.skip_votes[ctx.guild.id].discard(ctx.author.id)
|
||||
reply = _("I removed your vote to skip.")
|
||||
else:
|
||||
self.skip_votes[ctx.guild.id].append(ctx.author.id)
|
||||
self.skip_votes[ctx.guild.id].add(ctx.author.id)
|
||||
reply = _("You voted to skip.")
|
||||
|
||||
num_votes = len(self.skip_votes[ctx.guild.id])
|
||||
@@ -532,7 +546,7 @@ class PlayerControllerCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
vote = int(100 * num_votes / num_members)
|
||||
percent = await self.config.guild(ctx.guild).vote_percent()
|
||||
if vote >= percent:
|
||||
self.skip_votes[ctx.guild.id] = []
|
||||
self.skip_votes[ctx.guild.id] = set()
|
||||
await self.send_embed_msg(ctx, title=_("Vote threshold met."))
|
||||
return await self._skip_action(ctx)
|
||||
else:
|
||||
@@ -583,6 +597,8 @@ class PlayerControllerCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
title=_("Unable To Stop Player"),
|
||||
description=_("You need the DJ role to stop the music."),
|
||||
)
|
||||
player.store("channel", ctx.channel.id)
|
||||
player.store("guild", ctx.guild.id)
|
||||
if (
|
||||
player.is_playing
|
||||
or (not player.is_playing and player.paused)
|
||||
@@ -597,7 +613,11 @@ class PlayerControllerCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
player.store("prev_requester", None)
|
||||
player.store("prev_song", None)
|
||||
player.store("requester", None)
|
||||
player.store("autoplay_notified", False)
|
||||
await player.stop()
|
||||
await self.config.guild_from_id(guild_id=ctx.guild.id).currently_auto_playing_in.set(
|
||||
[]
|
||||
)
|
||||
await self.send_embed_msg(ctx, title=_("Stopping..."))
|
||||
await self.api_interface.persistent_queue_api.drop(ctx.guild.id)
|
||||
|
||||
@@ -642,17 +662,28 @@ class PlayerControllerCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
description=_("I don't have permission to connect to your channel."),
|
||||
)
|
||||
if not self._player_check(ctx):
|
||||
await lavalink.connect(ctx.author.voice.channel)
|
||||
await lavalink.connect(
|
||||
ctx.author.voice.channel,
|
||||
deafen=await self.config.guild_from_id(ctx.guild.id).auto_deafen(),
|
||||
)
|
||||
player = lavalink.get_player(ctx.guild.id)
|
||||
player.store("connect", datetime.datetime.utcnow())
|
||||
await self.self_deafen(player)
|
||||
player.store("channel", ctx.channel.id)
|
||||
player.store("guild", ctx.guild.id)
|
||||
else:
|
||||
player = lavalink.get_player(ctx.guild.id)
|
||||
if ctx.author.voice.channel == player.channel:
|
||||
player.store("channel", ctx.channel.id)
|
||||
player.store("guild", ctx.guild.id)
|
||||
if (
|
||||
ctx.author.voice.channel == player.channel
|
||||
and ctx.guild.me in ctx.author.voice.channel.members
|
||||
):
|
||||
ctx.command.reset_cooldown(ctx)
|
||||
return
|
||||
await player.move_to(ctx.author.voice.channel)
|
||||
await self.self_deafen(player)
|
||||
await player.move_to(
|
||||
ctx.author.voice.channel,
|
||||
deafen=await self.config.guild_from_id(ctx.guild.id).auto_deafen(),
|
||||
)
|
||||
except AttributeError:
|
||||
ctx.command.reset_cooldown(ctx)
|
||||
return await self.send_embed_msg(
|
||||
@@ -693,23 +724,33 @@ class PlayerControllerCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
title=_("Unable To Change Volume"),
|
||||
description=_("You must be in the voice channel to change the volume."),
|
||||
)
|
||||
player.store("channel", ctx.channel.id)
|
||||
player.store("guild", ctx.guild.id)
|
||||
if dj_enabled and not can_skip and not await self._has_dj_role(ctx, ctx.author):
|
||||
return await self.send_embed_msg(
|
||||
ctx,
|
||||
title=_("Unable To Change Volume"),
|
||||
description=_("You need the DJ role to change the volume."),
|
||||
)
|
||||
|
||||
if vol < 0:
|
||||
vol = 0
|
||||
if vol > 150:
|
||||
vol = 150
|
||||
await self.config.guild(ctx.guild).volume.set(vol)
|
||||
if self._player_check(ctx):
|
||||
await lavalink.get_player(ctx.guild.id).set_volume(vol)
|
||||
player = lavalink.get_player(ctx.guild.id)
|
||||
await player.set_volume(vol)
|
||||
player.store("channel", ctx.channel.id)
|
||||
player.store("guild", ctx.guild.id)
|
||||
else:
|
||||
await self.config.guild(ctx.guild).volume.set(vol)
|
||||
if self._player_check(ctx):
|
||||
await lavalink.get_player(ctx.guild.id).set_volume(vol)
|
||||
player = lavalink.get_player(ctx.guild.id)
|
||||
await player.set_volume(vol)
|
||||
player.store("channel", ctx.channel.id)
|
||||
player.store("guild", ctx.guild.id)
|
||||
|
||||
embed = discord.Embed(title=_("Volume:"), description=str(vol) + "%")
|
||||
if not self._player_check(ctx):
|
||||
embed.set_footer(text=_("Nothing playing."))
|
||||
@@ -741,6 +782,8 @@ class PlayerControllerCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
title=_("Unable To Toggle Repeat"),
|
||||
description=_("You must be in the voice channel to toggle repeat."),
|
||||
)
|
||||
player.store("channel", ctx.channel.id)
|
||||
player.store("guild", ctx.guild.id)
|
||||
|
||||
autoplay = await self.config.guild(ctx.guild).auto_play()
|
||||
repeat = await self.config.guild(ctx.guild).repeat()
|
||||
@@ -784,6 +827,8 @@ class PlayerControllerCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
title=_("Unable To Modify Queue"),
|
||||
description=_("You must be in the voice channel to manage the queue."),
|
||||
)
|
||||
player.store("channel", ctx.channel.id)
|
||||
player.store("guild", ctx.guild.id)
|
||||
if isinstance(index_or_url, int):
|
||||
if index_or_url > len(player.queue) or index_or_url < 1:
|
||||
return await self.send_embed_msg(
|
||||
@@ -864,7 +909,8 @@ class PlayerControllerCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
title=_("Unable To Bump Track"),
|
||||
description=_("Song number must be greater than 1 and within the queue limit."),
|
||||
)
|
||||
|
||||
player.store("channel", ctx.channel.id)
|
||||
player.store("guild", ctx.guild.id)
|
||||
bump_index = index - 1
|
||||
bump_song = player.queue[bump_index]
|
||||
bump_song.extras["bumped"] = True
|
||||
|
||||
@@ -173,7 +173,8 @@ class EqualizerCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
title=_("Unable To Load Preset"),
|
||||
description=_("You need the DJ role to load equalizer presets."),
|
||||
)
|
||||
|
||||
player.store("channel", ctx.channel.id)
|
||||
player.store("guild", ctx.guild.id)
|
||||
await self.config.custom("EQUALIZER", ctx.guild.id).eq_bands.set(eq_values)
|
||||
await self._eq_check(ctx, player)
|
||||
eq = player.fetch("eq", Equalizer())
|
||||
@@ -202,6 +203,8 @@ class EqualizerCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
description=_("You need the DJ role to reset the equalizer."),
|
||||
)
|
||||
player = lavalink.get_player(ctx.guild.id)
|
||||
player.store("channel", ctx.channel.id)
|
||||
player.store("guild", ctx.guild.id)
|
||||
eq = player.fetch("eq", Equalizer())
|
||||
|
||||
for band in range(eq.band_count):
|
||||
@@ -284,6 +287,8 @@ class EqualizerCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
return await eq_exists_msg.edit(embed=embed2)
|
||||
|
||||
player = lavalink.get_player(ctx.guild.id)
|
||||
player.store("channel", ctx.channel.id)
|
||||
player.store("guild", ctx.guild.id)
|
||||
eq = player.fetch("eq", Equalizer())
|
||||
to_append = {eq_preset: {"author": ctx.author.id, "bands": eq.bands}}
|
||||
new_eq_presets = {**eq_presets, **to_append}
|
||||
@@ -325,6 +330,8 @@ class EqualizerCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
)
|
||||
|
||||
player = lavalink.get_player(ctx.guild.id)
|
||||
player.store("channel", ctx.channel.id)
|
||||
player.store("guild", ctx.guild.id)
|
||||
band_names = [
|
||||
"25",
|
||||
"40",
|
||||
|
||||
@@ -223,7 +223,7 @@ class LavalinkSetupCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
msg = "----" + _("Connection Settings") + "---- \n"
|
||||
msg += _("Host: [{host}]\n").format(host=host)
|
||||
msg += _("WS Port: [{port}]\n").format(port=ws_port)
|
||||
if ws_port != rest_port:
|
||||
if ws_port != rest_port and rest_port != 2333:
|
||||
msg += _("Rest Port: [{port}]\n").format(port=rest_port)
|
||||
msg += _("Password: [{password}]\n").format(password=password)
|
||||
try:
|
||||
|
||||
@@ -78,10 +78,14 @@ class PlayerCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
title=_("Unable To Play Tracks"),
|
||||
description=_("I don't have permission to connect to your channel."),
|
||||
)
|
||||
await lavalink.connect(ctx.author.voice.channel)
|
||||
await lavalink.connect(
|
||||
ctx.author.voice.channel,
|
||||
deafen=await self.config.guild_from_id(ctx.guild.id).auto_deafen(),
|
||||
)
|
||||
player = lavalink.get_player(ctx.guild.id)
|
||||
player.store("connect", datetime.datetime.utcnow())
|
||||
await self.self_deafen(player)
|
||||
player.store("channel", ctx.channel.id)
|
||||
player.store("guild", ctx.guild.id)
|
||||
except AttributeError:
|
||||
return await self.send_embed_msg(
|
||||
ctx,
|
||||
@@ -185,10 +189,14 @@ class PlayerCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
title=_("Unable To Play Tracks"),
|
||||
description=_("I don't have permission to connect to your channel."),
|
||||
)
|
||||
await lavalink.connect(ctx.author.voice.channel)
|
||||
await lavalink.connect(
|
||||
ctx.author.voice.channel,
|
||||
deafen=await self.config.guild_from_id(ctx.guild.id).auto_deafen(),
|
||||
)
|
||||
player = lavalink.get_player(ctx.guild.id)
|
||||
player.store("connect", datetime.datetime.utcnow())
|
||||
await self.self_deafen(player)
|
||||
player.store("channel", ctx.channel.id)
|
||||
player.store("guild", ctx.guild.id)
|
||||
except AttributeError:
|
||||
return await self.send_embed_msg(
|
||||
ctx,
|
||||
@@ -450,10 +458,14 @@ class PlayerCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
title=_("Unable To Play Tracks"),
|
||||
description=_("I don't have permission to connect to your channel."),
|
||||
)
|
||||
await lavalink.connect(ctx.author.voice.channel)
|
||||
await lavalink.connect(
|
||||
ctx.author.voice.channel,
|
||||
deafen=await self.config.guild_from_id(ctx.guild.id).auto_deafen(),
|
||||
)
|
||||
player = lavalink.get_player(ctx.guild.id)
|
||||
player.store("connect", datetime.datetime.utcnow())
|
||||
await self.self_deafen(player)
|
||||
player.store("channel", ctx.channel.id)
|
||||
player.store("guild", ctx.guild.id)
|
||||
except AttributeError:
|
||||
return await self.send_embed_msg(
|
||||
ctx,
|
||||
@@ -566,10 +578,14 @@ class PlayerCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
title=_("Unable To Play Tracks"),
|
||||
description=_("I don't have permission to connect to your channel."),
|
||||
)
|
||||
await lavalink.connect(ctx.author.voice.channel)
|
||||
await lavalink.connect(
|
||||
ctx.author.voice.channel,
|
||||
deafen=await self.config.guild_from_id(ctx.guild.id).auto_deafen(),
|
||||
)
|
||||
player = lavalink.get_player(ctx.guild.id)
|
||||
player.store("connect", datetime.datetime.utcnow())
|
||||
await self.self_deafen(player)
|
||||
player.store("channel", ctx.channel.id)
|
||||
player.store("guild", ctx.guild.id)
|
||||
except AttributeError:
|
||||
return await self.send_embed_msg(
|
||||
ctx,
|
||||
@@ -626,10 +642,8 @@ class PlayerCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
|
||||
if not guild_data["auto_play"]:
|
||||
await ctx.invoke(self.command_audioset_autoplay_toggle)
|
||||
if not guild_data["notify"] and (
|
||||
(player.current and not player.current.extras.get("autoplay")) or not player.current
|
||||
):
|
||||
await self.send_embed_msg(ctx, title=_("Auto play started."))
|
||||
if not guild_data["notify"] and not player.fetch("autoplay_notified", False):
|
||||
pass
|
||||
elif player.current:
|
||||
await self.send_embed_msg(ctx, title=_("Adding a track to queue."))
|
||||
|
||||
@@ -692,10 +706,14 @@ class PlayerCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
title=_("Unable To Search For Tracks"),
|
||||
description=_("I don't have permission to connect to your channel."),
|
||||
)
|
||||
await lavalink.connect(ctx.author.voice.channel)
|
||||
await lavalink.connect(
|
||||
ctx.author.voice.channel,
|
||||
deafen=await self.config.guild_from_id(ctx.guild.id).auto_deafen(),
|
||||
)
|
||||
player = lavalink.get_player(ctx.guild.id)
|
||||
player.store("connect", datetime.datetime.utcnow())
|
||||
await self.self_deafen(player)
|
||||
player.store("channel", ctx.channel.id)
|
||||
player.store("guild", ctx.guild.id)
|
||||
except AttributeError:
|
||||
return await self.send_embed_msg(
|
||||
ctx,
|
||||
|
||||
@@ -1678,7 +1678,7 @@ class PlaylistCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
try:
|
||||
if not await self.can_manage_playlist(scope, playlist, ctx, author, guild):
|
||||
return
|
||||
if playlist.url:
|
||||
if playlist.url or playlist.id == 42069:
|
||||
player = lavalink.get_player(ctx.guild.id)
|
||||
added, removed, playlist = await self._maybe_update_playlist(
|
||||
ctx, player, playlist
|
||||
|
||||
@@ -338,10 +338,14 @@ class QueueCommands(MixinMeta, metaclass=CompositeMetaClass):
|
||||
title=_("Unable To Shuffle Queue"),
|
||||
description=_("I don't have permission to connect to your channel."),
|
||||
)
|
||||
await lavalink.connect(ctx.author.voice.channel)
|
||||
await lavalink.connect(
|
||||
ctx.author.voice.channel,
|
||||
deafen=await self.config.guild_from_id(ctx.guild.id).auto_deafen(),
|
||||
)
|
||||
player = lavalink.get_player(ctx.guild.id)
|
||||
player.store("connect", datetime.datetime.utcnow())
|
||||
await self.self_deafen(player)
|
||||
player.store("channel", ctx.channel.id)
|
||||
player.store("guild", ctx.guild.id)
|
||||
except AttributeError:
|
||||
ctx.command.reset_cooldown(ctx)
|
||||
return await self.send_embed_msg(
|
||||
|
||||
Reference in New Issue
Block a user