aboutsummaryrefslogtreecommitdiff
path: root/code/cogs
diff options
context:
space:
mode:
Diffstat (limited to 'code/cogs')
-rw-r--r--code/cogs/autoplay.py32
-rw-r--r--code/cogs/clear.py12
-rw-r--r--code/cogs/lyrics.py44
-rw-r--r--code/cogs/nowplaying.py13
-rw-r--r--code/cogs/pause.py13
-rw-r--r--code/cogs/play.py28
-rw-r--r--code/cogs/queue.py16
-rw-r--r--code/cogs/remove.py30
-rw-r--r--code/cogs/repeat.py86
-rw-r--r--code/cogs/resume.py13
-rw-r--r--code/cogs/shuffle.py28
-rw-r--r--code/cogs/skip.py40
-rw-r--r--code/cogs/stop.py11
13 files changed, 90 insertions, 276 deletions
diff --git a/code/cogs/autoplay.py b/code/cogs/autoplay.py
index 4b2f624..5c2ec29 100644
--- a/code/cogs/autoplay.py
+++ b/code/cogs/autoplay.py
@@ -6,7 +6,7 @@ from cogs.music import Music
from typing import Literal
from utils.ai_recommendations import add_song_recommendations
-from utils.config import BOT_COLOR
+from utils.config import create_embed
class Autoplay(commands.Cog):
@@ -23,28 +23,26 @@ class Autoplay(commands.Cog):
if toggle == "OFF":
self.bot.autoplay.remove(interaction.guild.id)
- embed = discord.Embed(
+ embed = create_embed(
title="Autoplay Off",
description=(
"Autoplay has been turned off. I will no longer"
" automatically add new songs to the queue based on AI"
" recommendations."
),
- color=BOT_COLOR,
)
return await interaction.response.send_message(embed=embed)
# Otherwise, toggle must be "ON", so enable autoplaying
if interaction.guild.id in self.bot.autoplay:
- embed = discord.Embed(
+ embed = create_embed(
title="Autoplay Already Enabled",
description=(
"Autoplay is already enabled. If you would like to turn it"
" off, choose the `OFF` option in the"
" </autoplay:1228216490386391052> command."
),
- color=BOT_COLOR,
)
return await interaction.response.send_message(
embed=embed, ephemeral=True
@@ -53,7 +51,7 @@ class Autoplay(commands.Cog):
player = self.bot.lavalink.player_manager.get(interaction.guild.id)
if len(player.queue) < 5:
- embed = discord.Embed(
+ embed = create_embed(
title="Not Enough Context",
description=(
"You must have at least 5 songs in the queue so that I can"
@@ -61,13 +59,6 @@ class Autoplay(commands.Cog):
" to play. Add some more music to the queue, then try"
" again."
),
- color=BOT_COLOR,
- )
- embed.set_footer(
- text=datetime.datetime.now(datetime.timezone.utc).strftime(
- "%Y-%m-%d %H:%M:%S"
- )
- + " UTC"
)
return await interaction.response.send_message(
embed=embed, ephemeral=True
@@ -77,13 +68,12 @@ class Autoplay(commands.Cog):
for song in player.queue[:10]:
inputs[song.title] = song.author
- embed = discord.Embed(
+ embed = create_embed(
title="Getting AI Recommendations",
description=(
"Attempting to generate recommendations based on the current"
" songs in your queue. Just a moment..."
),
- color=BOT_COLOR,
)
await interaction.response.send_message(embed=embed)
@@ -91,7 +81,7 @@ class Autoplay(commands.Cog):
self.bot.openai, self.bot.user, player, 5, inputs
):
self.bot.autoplay.append(interaction.guild.id)
- embed = discord.Embed(
+ embed = create_embed(
title=":infinity: Autoplay Enabled :infinity:",
description=(
"I have added a few similar songs to the queue and will"
@@ -99,12 +89,11 @@ class Autoplay(commands.Cog):
" just sit back and enjoy the music!\n\nEnabled by:"
f" {interaction.user.mention}"
),
- color=BOT_COLOR,
)
await interaction.edit_original_response(embed=embed)
else:
- embed = discord.Embed(
+ embed = create_embed(
title="Autoplay Error",
description=(
"Autoplay is an experimental feature, meaning sometimes it"
@@ -113,13 +102,6 @@ class Autoplay(commands.Cog):
" command again. If the issue persists, fill out a bug"
" report with the </bug:1224840889906499626> command."
),
- color=BOT_COLOR,
- )
- embed.set_footer(
- text=datetime.datetime.now(datetime.timezone.utc).strftime(
- "%Y-%m-%d %H:%M:%S"
- )
- + " UTC"
)
await interaction.edit_original_response(embed=embed)
diff --git a/code/cogs/clear.py b/code/cogs/clear.py
index 0d378ee..8e61b53 100644
--- a/code/cogs/clear.py
+++ b/code/cogs/clear.py
@@ -4,7 +4,7 @@ from discord import app_commands
from discord.ext import commands
from cogs.music import Music
-from utils.config import BOT_COLOR
+from utils.config import create_embed
class Clear(commands.Cog):
@@ -18,19 +18,13 @@ class Clear(commands.Cog):
player = self.bot.lavalink.player_manager.get(interaction.guild.id)
player.queue.clear()
- embed = discord.Embed(
+
+ embed = create_embed(
title="Queue Cleared",
description=(
"The queue has been cleared of all songs!\n\nIssued by:"
f" {interaction.user.mention}"
),
- color=BOT_COLOR,
- )
- embed.set_footer(
- text=datetime.datetime.now(datetime.timezone.utc).strftime(
- "%Y-%m-%d %H:%M:%S"
- )
- + " UTC"
)
await interaction.response.send_message(embed=embed)
diff --git a/code/cogs/lyrics.py b/code/cogs/lyrics.py
index e28d2c2..6e3a1d3 100644
--- a/code/cogs/lyrics.py
+++ b/code/cogs/lyrics.py
@@ -4,7 +4,7 @@ from discord import app_commands
from discord.ext import commands
from cogs.music import Music
-from utils.config import BOT_COLOR
+from utils.config import create_embed
class Lyrics(commands.Cog):
@@ -19,19 +19,12 @@ class Lyrics(commands.Cog):
# If the Genius API client is not setup, send an error message
if not self.bot.genius:
- embed = discord.Embed(
+ embed = create_embed(
title="Lyrics Feature Error",
description=(
"The lyrics feature is currently disabled due to errors"
" with the Genius API."
),
- color=BOT_COLOR,
- )
- embed.set_footer(
- text=datetime.datetime.now(datetime.timezone.utc).strftime(
- "%Y-%m-%d %H:%M:%S"
- )
- + " UTC"
)
return await interaction.response.send_message(
embed=embed, ephemeral=True
@@ -48,20 +41,13 @@ class Lyrics(commands.Cog):
# If no lyrics are found, send an error message
if song is None:
- embed = discord.Embed(
+ embed = create_embed(
title="Lyrics Not Found",
description=(
"Unfortunately, I wasn't able to find any lyrics for the"
" song that is currently playing."
),
- color=BOT_COLOR,
- )
- embed.set_thumbnail(url=player.current.artwork_url)
- embed.set_footer(
- text=datetime.datetime.now(datetime.timezone.utc).strftime(
- "%Y-%m-%d %H:%M:%S"
- )
- + " UTC"
+ thumbnail=player.current.artwork_url,
)
return await interaction.edit_original_response(embed=embed)
@@ -73,7 +59,7 @@ class Lyrics(commands.Cog):
# If the lyrics are too long, send just a link to the lyrics
if len(lyrics) > 2048:
- embed = discord.Embed(
+ embed = create_embed(
title=(
f"Lyrics for {player.current.title} by"
f" {player.current.author}"
@@ -82,31 +68,17 @@ class Lyrics(commands.Cog):
"Song lyrics are too long to display on Discord. [Click"
f" here to view the lyrics on Genius]({song.url})."
),
- color=BOT_COLOR,
- )
- embed.set_thumbnail(url=player.current.artwork_url)
- embed.set_footer(
- text=datetime.datetime.now(datetime.timezone.utc).strftime(
- "%Y-%m-%d %H:%M:%S"
- )
- + " UTC"
+ thumbnail=player.current.artwork_url,
)
return await interaction.edit_original_response(embed=embed)
# If everything is successful, send the lyrics
- embed = discord.Embed(
+ embed = create_embed(
title=(
f"Lyrics for {player.current.title} by {player.current.author}"
),
description=f"Provided from [Genius]({song.url})\n\n" + lyrics,
- color=BOT_COLOR,
- )
- embed.set_thumbnail(url=player.current.artwork_url)
- embed.set_footer(
- text=datetime.datetime.now(datetime.timezone.utc).strftime(
- "%Y-%m-%d %H:%M:%S"
- )
- + " UTC"
+ thumbnail=player.current.artwork_url,
)
await interaction.edit_original_response(embed=embed)
diff --git a/code/cogs/nowplaying.py b/code/cogs/nowplaying.py
index 89d9ee2..1f29c3c 100644
--- a/code/cogs/nowplaying.py
+++ b/code/cogs/nowplaying.py
@@ -5,7 +5,7 @@ from discord.ext import commands
from cogs.music import Music
import lavalink
-from utils.config import BOT_COLOR
+from utils.config import create_embed
class NowPlaying(commands.Cog):
@@ -25,21 +25,14 @@ class NowPlaying(commands.Cog):
time_in = time_in[2:]
total_duration = total_duration[3:]
- embed = discord.Embed(
+ embed = create_embed(
title="Now Playing 🎢",
description=(
f"**[{player.current.title}]({player.current.uri})** by"
f" {player.current.author}\n{f'` {time_in}/{total_duration} `'}\n\nQueued"
f" by: {player.current.requester.mention}"
),
- color=BOT_COLOR,
- )
- embed.set_thumbnail(url=player.current.artwork_url)
- embed.set_footer(
- text=datetime.datetime.now(datetime.timezone.utc).strftime(
- "%Y-%m-%d %H:%M:%S"
- )
- + " UTC"
+ thumbnail=player.current.artwork_url,
)
await interaction.response.send_message(embed=embed)
diff --git a/code/cogs/pause.py b/code/cogs/pause.py
index 2b7f98d..fb55aa4 100644
--- a/code/cogs/pause.py
+++ b/code/cogs/pause.py
@@ -4,7 +4,7 @@ from discord import app_commands
from discord.ext import commands
from cogs.music import Music
-from utils.config import BOT_COLOR
+from utils.config import create_embed
class Pause(commands.Cog):
@@ -18,20 +18,13 @@ class Pause(commands.Cog):
player = self.bot.lavalink.player_manager.get(interaction.guild.id)
await player.set_pause(pause=True)
- embed = discord.Embed(
+ embed = create_embed(
title=f"Music Now Paused ⏸️",
description=(
f"**[{player.current.title}]({player.current.uri})**\n\nQueued"
f" by: {player.current.requester.mention}"
),
- color=BOT_COLOR,
- )
- embed.set_thumbnail(url=player.current.artwork_url)
- embed.set_footer(
- text=datetime.datetime.now(datetime.timezone.utc).strftime(
- "%Y-%m-%d %H:%M:%S"
- )
- + " UTC"
+ thumbnail=player.current.artwork_url,
)
await interaction.response.send_message(embed=embed)
diff --git a/code/cogs/play.py b/code/cogs/play.py
index cc3e893..c836b70 100644
--- a/code/cogs/play.py
+++ b/code/cogs/play.py
@@ -6,7 +6,7 @@ from lavalink import LoadType
import re
from cogs.music import Music, LavalinkVoiceClient
-from utils.config import BOT_COLOR, YOUTUBE_SUPPORT
+from utils.config import YOUTUBE_SUPPORT, create_embed
from utils.custom_sources import (
LoadError,
CustomAudioTrack,
@@ -31,7 +31,7 @@ class Play(commands.Cog):
# Notify users that YouTube links are not allowed if YouTube support is disabled
if "youtube.com" in query or "youtu.be" in query:
if not YOUTUBE_SUPPORT:
- embed = discord.Embed(
+ embed = create_embed(
title="YouTube Not Supported",
description=(
"Unfortunately, YouTube does not allow bots to stream"
@@ -40,7 +40,6 @@ class Play(commands.Cog):
" song and I will automatically find it on a supported"
" platform."
),
- color=BOT_COLOR,
)
return await interaction.response.send_message(
embed=embed, ephemeral=True
@@ -91,54 +90,39 @@ class Play(commands.Cog):
# Create the embed if the results are a playlist
if results.load_type == LoadType.PLAYLIST:
- embed = discord.Embed(
+ embed = create_embed(
title="Songs Queued!",
description=(
f"**{results.playlist_info.name}**\n"
f"` {len(results.tracks)} ` tracks\n\n"
f"Queued by: {interaction.user.mention}"
),
- color=BOT_COLOR,
- )
- embed.set_footer(
- text=datetime.datetime.utcnow().strftime(
- "%Y-%m-%d %H:%M:%S"
- )
- + " UTC"
)
await interaction.response.send_message(embed=embed)
# Otherwise, the result is just a single track, create that embed
else:
# Remove all but first track (most relevant result)
results.tracks = results.tracks[:1]
- embed = discord.Embed(
+ embed = create_embed(
title="Song Queued!",
description=(
f"**{results.tracks[0].title}** by"
f" **{results.tracks[0].author}**\n\nQueued by:"
f" {interaction.user.mention}"
),
- color=BOT_COLOR,
- )
- embed.set_thumbnail(url=results.tracks[0].artwork_url)
- embed.set_footer(
- text=datetime.datetime.utcnow().strftime(
- "%Y-%m-%d %H:%M:%S"
- )
- + " UTC"
+ thumbnail=results.tracks[0].artwork_url,
)
await interaction.response.send_message(embed=embed)
# If there are no results, and no embed
if not results and not embed:
- embed = discord.Embed(
+ embed = create_embed(
title="Nothing Found",
description=(
"I was not able to find or load any songs for that query."
" Please try again and fill out a bug report with"
" </bug:1224840889906499626> if this continues to happen."
),
- color=BOT_COLOR,
)
return await interaction.response.send_message(
embed=embed, ephemeral=True
diff --git a/code/cogs/queue.py b/code/cogs/queue.py
index d11a4a9..faaed60 100644
--- a/code/cogs/queue.py
+++ b/code/cogs/queue.py
@@ -6,7 +6,7 @@ from cogs.music import Music
import math
import lavalink
-from utils.config import BOT_COLOR
+from utils.config import create_embed
class Queue(commands.Cog):
@@ -23,19 +23,12 @@ class Queue(commands.Cog):
player = self.bot.lavalink.player_manager.get(interaction.guild.id)
if not player.queue:
- embed = discord.Embed(
+ embed = create_embed(
title="Nothing Queued",
description=(
"Nothing is currently in the queue, add a song with the"
" </play:1224840890368000172> command."
),
- color=BOT_COLOR,
- )
- embed.set_footer(
- text=datetime.datetime.now(datetime.timezone.utc).strftime(
- "%Y-%m-%d %H:%M:%S"
- )
- + " UTC"
)
return await interaction.response.send_message(
embed=embed, ephemeral=True
@@ -60,14 +53,13 @@ class Queue(commands.Cog):
f" {track.author} `({track_duration})`\n"
)
- embed = discord.Embed(
+ embed = create_embed(
title=f"Queue for {interaction.guild.name}",
description=(
f"**{len(player.queue)} tracks total**\n\n{queue_list}"
),
- color=BOT_COLOR,
+ footer=f"Viewing page {page}/{pages}",
)
- embed.set_footer(text=f"Viewing page {page}/{pages}")
await interaction.response.send_message(embed=embed)
diff --git a/code/cogs/remove.py b/code/cogs/remove.py
index f672ffd..bba07a4 100644
--- a/code/cogs/remove.py
+++ b/code/cogs/remove.py
@@ -4,7 +4,7 @@ from discord import app_commands
from discord.ext import commands
from cogs.music import Music
-from utils.config import BOT_COLOR
+from utils.config import create_embed
class Remove(commands.Cog):
@@ -19,26 +19,15 @@ class Remove(commands.Cog):
player = self.bot.lavalink.player_manager.get(interaction.guild.id)
if not player.queue:
- embed = discord.Embed(
+ embed = create_embed(
title="Nothing Queued",
- description=(
- "Nothing is currently in the queue, so there is nothing"
- " for me to remove."
- ),
- color=BOT_COLOR,
- )
- embed.set_footer(
- text=datetime.datetime.now(datetime.timezone.utc).strftime(
- "%Y-%m-%d %H:%M:%S"
- )
- + " UTC"
+ description="There are no songs in the queue to remove.",
)
return await interaction.response.send_message(embed=embed)
if number > len(player.queue) or number < 1:
return await interaction.response.send_message(
- "The number entered is not a number within the queue - please"
- " try again!",
+ "Number out of range - please try again!",
ephemeral=True,
)
@@ -48,21 +37,14 @@ class Remove(commands.Cog):
removed_artwork = player.queue[index].artwork_url
player.queue.pop(index)
- embed = discord.Embed(
+ embed = create_embed(
title="Song Removed from Queue",
description=(
"**Song Removed -"
f" [{removed_title}]({removed_url})**\n\nIssued by:"
f" {interaction.user.mention}"
),
- color=BOT_COLOR,
- )
- embed.set_thumbnail(url=removed_artwork)
- embed.set_footer(
- text=datetime.datetime.now(datetime.timezone.utc).strftime(
- "%Y-%m-%d %H:%M:%S"
- )
- + " UTC"
+ thumbnail=removed_artwork,
)
await interaction.response.send_message(embed=embed)
diff --git a/code/cogs/repeat.py b/code/cogs/repeat.py
index cf745d5..39aaadb 100644
--- a/code/cogs/repeat.py
+++ b/code/cogs/repeat.py
@@ -4,7 +4,7 @@ from discord import app_commands
from discord.ext import commands
from cogs.music import Music
-from utils.config import BOT_COLOR
+from utils.config import create_embed
class Repeat(commands.GroupCog, name="repeat"):
@@ -18,16 +18,9 @@ class Repeat(commands.GroupCog, name="repeat"):
player = self.bot.lavalink.player_manager.get(interaction.guild.id)
if player.loop == 0:
- embed = discord.Embed(
- title=f"Repeating Already Off",
- description=f"Music repetition is already turned off.",
- color=BOT_COLOR,
- )
- embed.set_footer(
- text=datetime.datetime.now(datetime.timezone.utc).strftime(
- "%Y-%m-%d %H:%M:%S"
- )
- + " UTC"
+ embed = create_embed(
+ title="Repeating Already Off",
+ description="Music repetition is already turned off.",
)
return await interaction.response.send_message(
embed=embed, ephemeral=True
@@ -35,16 +28,9 @@ class Repeat(commands.GroupCog, name="repeat"):
player.loop = 0
- embed = discord.Embed(
- title=f"Repeating Off",
- description=f"Music will no longer be repeated.",
- color=BOT_COLOR,
- )
- embed.set_footer(
- text=datetime.datetime.now(datetime.timezone.utc).strftime(
- "%Y-%m-%d %H:%M:%S"
- )
- + " UTC"
+ embed = create_embed(
+ title="Repeating Off",
+ description="Music will no longer be repeated.",
)
await interaction.response.send_message(embed=embed)
@@ -55,36 +41,21 @@ class Repeat(commands.GroupCog, name="repeat"):
player = self.bot.lavalink.player_manager.get(interaction.guild.id)
if player.loop == 1:
- embed = discord.Embed(
- title=f"Repeating Already On",
- description=f"The current song is already being repeated.",
- color=BOT_COLOR,
- )
- embed.set_footer(
- text=datetime.datetime.now(datetime.timezone.utc).strftime(
- "%Y-%m-%d %H:%M:%S"
- )
- + " UTC"
+ embed = create_embed(
+ title="Repeating Already On",
+ description="The current song is already being repeated.",
)
return await interaction.response.send_message(
embed=embed, ephemeral=True
)
player.loop = 1
-
- embed = discord.Embed(
- title=f"Repeating Current Song πŸ”",
+ embed = create_embed(
+ title="Repeating Current Song πŸ”",
description=(
- f"The song that is currently playing will be repeated until"
- f" the </repeat off:1224840891395608737> command is run"
+ "The song that is currently playing will be repeated until"
+ " the </repeat off:1224840891395608737> command is run"
),
- color=BOT_COLOR,
- )
- embed.set_footer(
- text=datetime.datetime.now(datetime.timezone.utc).strftime(
- "%Y-%m-%d %H:%M:%S"
- )
- + " UTC"
)
await interaction.response.send_message(embed=embed)
@@ -95,36 +66,21 @@ class Repeat(commands.GroupCog, name="repeat"):
player = self.bot.lavalink.player_manager.get(interaction.guild.id)
if player.loop == 2:
- embed = discord.Embed(
- title=f"Repeating Already On",
- description=f"The queue is already being repeated.",
- color=BOT_COLOR,
- )
- embed.set_footer(
- text=datetime.datetime.now(datetime.timezone.utc).strftime(
- "%Y-%m-%d %H:%M:%S"
- )
- + " UTC"
+ embed = create_embed(
+ title="Repeating Already On",
+ description="The queue is already being repeated.",
)
return await interaction.response.send_message(
embed=embed, ephemeral=True
)
player.loop = 2
-
- embed = discord.Embed(
- title=f"Repeating Current Song πŸ”‚",
+ embed = create_embed(
+ title="Repeating Queue πŸ”‚",
description=(
- f"All songs in the queue will continue to repeat until the"
- f" </repeat off:1224840891395608737> command is run."
+ "The queue will continuously repeat until the"
+ " </repeat off:1224840891395608737> command is run."
),
- color=BOT_COLOR,
- )
- embed.set_footer(
- text=datetime.datetime.now(datetime.timezone.utc).strftime(
- "%Y-%m-%d %H:%M:%S"
- )
- + " UTC"
)
await interaction.response.send_message(embed=embed)
diff --git a/code/cogs/resume.py b/code/cogs/resume.py
index fb3f0a3..6297404 100644
--- a/code/cogs/resume.py
+++ b/code/cogs/resume.py
@@ -4,7 +4,7 @@ from discord import app_commands
from discord.ext import commands
from cogs.music import Music
-from utils.config import BOT_COLOR
+from utils.config import create_embed
class Resume(commands.Cog):
@@ -18,20 +18,13 @@ class Resume(commands.Cog):
player = self.bot.lavalink.player_manager.get(interaction.guild.id)
await player.set_pause(pause=False)
- embed = discord.Embed(
+ embed = create_embed(
title=f"Music Now Resumed ⏯️",
description=(
f"**[{player.current.title}]({player.current.uri})**\n\nQueued"
f" by: {player.current.requester.mention}"
),
- color=BOT_COLOR,
- )
- embed.set_thumbnail(url=player.current.artwork_url)
- embed.set_footer(
- text=datetime.datetime.now(datetime.timezone.utc).strftime(
- "%Y-%m-%d %H:%M:%S"
- )
- + " UTC"
+ thumbnail=player.current.artwork_url,
)
await interaction.response.send_message(embed=embed)
diff --git a/code/cogs/shuffle.py b/code/cogs/shuffle.py
index 5c2f381..78213d6 100644
--- a/code/cogs/shuffle.py
+++ b/code/cogs/shuffle.py
@@ -4,7 +4,7 @@ from discord import app_commands
from discord.ext import commands
from cogs.music import Music
-from utils.config import BOT_COLOR
+from utils.config import create_embed
class Shuffle(commands.GroupCog, name="shuffle"):
@@ -19,16 +19,9 @@ class Shuffle(commands.GroupCog, name="shuffle"):
player.shuffle = True
- embed = discord.Embed(
- title=f"Shuffle Enabled πŸ”€",
- description=f"All music will now be shuffled.",
- color=BOT_COLOR,
- )
- embed.set_footer(
- text=datetime.datetime.now(datetime.timezone.utc).strftime(
- "%Y-%m-%d %H:%M:%S"
- )
- + " UTC"
+ embed = create_embed(
+ title="Shuffle Enabled πŸ”€",
+ description="All music will now be shuffled.",
)
await interaction.response.send_message(embed=embed)
@@ -40,16 +33,9 @@ class Shuffle(commands.GroupCog, name="shuffle"):
player.shuffle = False
- embed = discord.Embed(
- title=f"Disabled πŸ”€",
- description=f"Music will no longer be shuffled.",
- color=BOT_COLOR,
- )
- embed.set_footer(
- text=datetime.datetime.now(datetime.timezone.utc).strftime(
- "%Y-%m-%d %H:%M:%S"
- )
- + " UTC"
+ embed = create_embed(
+ title="Shuffle Disabled πŸ”€",
+ description="Music will no longer be shuffled.",
)
await interaction.response.send_message(embed=embed)
diff --git a/code/cogs/skip.py b/code/cogs/skip.py
index c35a203..46a767f 100644
--- a/code/cogs/skip.py
+++ b/code/cogs/skip.py
@@ -5,7 +5,7 @@ from discord.ext import commands
from cogs.music import Music
import asyncio
-from utils.config import BOT_COLOR
+from utils.config import create_embed
from utils.custom_sources import LoadError
@@ -22,22 +22,25 @@ class Skip(commands.Cog):
"Skips the song that is currently playing"
player = self.bot.lavalink.player_manager.get(interaction.guild.id)
- embed = discord.Embed(color=BOT_COLOR)
-
if number != 1:
if number < 1:
- embed.title = "Invalid Number"
- embed.description = "The number option cannot be less than 1"
+ embed = create_embed(
+ title="Invalid Number",
+ description="The number option cannot be less than 1",
+ )
return await interaction.response.send_message(
embed=embed, ephemeral=True
)
elif number > len(player.queue):
- embed.title = "Number too Large"
- embed.description = (
- "The number you entered is larger than the number of songs"
- " in queue. If you want to stop playing music entirely,"
- " try the </stop:1224840890866991305> command."
+ embed = create_embed(
+ title="Number too Large",
+ description=(
+ "The number you entered is larger than the number of"
+ " songs in queue. If you want to stop playing music"
+ " entirely, try the </stop:1224840890866991305>"
+ " command."
+ ),
)
return await interaction.response.send_message(
embed=embed, ephemeral=True
@@ -53,14 +56,13 @@ class Skip(commands.Cog):
# If the song is on repeat, catch the IndexError and get the current song
# Otherwise, pass
if player.loop == 1:
- embed = discord.Embed(
+ embed = create_embed(
title="Song on Repeat",
description=(
"There is nothing in queue, but the current song is on"
" repeat. Use </stop:1224840890866991305> to stop"
" playing music."
),
- color=BOT_COLOR,
)
return await interaction.response.send_message(
embed=embed, ephemeral=True
@@ -77,34 +79,26 @@ class Skip(commands.Cog):
await player.skip()
if not player.current:
- embed = discord.Embed(
+ embed = create_embed(
title="End of Queue",
description=(
"All songs in queue have been played. Thank you for using"
f" me :wave:\n\nIssued by: {interaction.user.mention}"
),
- color=BOT_COLOR,
)
return await interaction.response.send_message(embed=embed)
# It takes a sec for the new track to be grabbed and played
# So just wait a sec before sending the message
await asyncio.sleep(0.5)
- embed = discord.Embed(
+ embed = create_embed(
title="Track Skipped",
description=(
f"**Now Playing: [{next_song.title}]({next_song.uri})** by"
f" {next_song.author}\n\nQueued by:"
f" {next_song.requester.mention}"
),
- color=BOT_COLOR,
- )
- embed.set_thumbnail(url=next_song.artwork_url)
- embed.set_footer(
- text=datetime.datetime.now(datetime.timezone.utc).strftime(
- "%Y-%m-%d %H:%M:%S"
- )
- + " UTC"
+ thumbnail=next_song.artwork_url,
)
await interaction.response.send_message(embed=embed)
diff --git a/code/cogs/stop.py b/code/cogs/stop.py
index 3992391..5d1f148 100644
--- a/code/cogs/stop.py
+++ b/code/cogs/stop.py
@@ -4,7 +4,7 @@ from discord import app_commands
from discord.ext import commands
from cogs.music import Music
-from utils.config import BOT_COLOR
+from utils.config import create_embed
class Stop(commands.Cog):
@@ -25,19 +25,12 @@ class Stop(commands.Cog):
await player.stop()
await interaction.guild.voice_client.disconnect(force=True)
- embed = discord.Embed(
+ embed = create_embed(
title="Queue Cleared and Music Stopped",
description=(
"Thank you for using me :wave:\n\nIssued by:"
f" {interaction.user.mention}"
),
- color=BOT_COLOR,
- )
- embed.set_footer(
- text=datetime.datetime.now(datetime.timezone.utc).strftime(
- "%Y-%m-%d %H:%M:%S"
- )
- + " UTC"
)
await interaction.response.send_message(embed=embed)