diff --git a/core/constants.py b/core/constants.py index c251001..581e8de 100644 --- a/core/constants.py +++ b/core/constants.py @@ -8,6 +8,7 @@ PRIMARY_COLOR = 0xE3621E SECONDARY_COLOR = 0x292B3E +CYAN_COLOR = 0x1E9FE3 UPVOTE_EMOTE_ID = 877668616810692608 DOWNVOTE_EMOTE_ID = 877668628261126144 diff --git a/extensions/feedback.py b/extensions/feedback.py index c7aaed8..0624d42 100644 --- a/extensions/feedback.py +++ b/extensions/feedback.py @@ -6,7 +6,7 @@ from discord import app_commands from discord.ext import commands -from core.bot import Substiify +import core logger = logging.getLogger(__name__) @@ -29,7 +29,7 @@ class FeedbackOutcome(Enum): class Feedback(commands.Cog): COG_EMOJI = "📝" - def __init__(self, bot: Substiify): + def __init__(self, bot: core.Substiify): self.bot = bot @commands.Cog.listener() @@ -151,7 +151,7 @@ async def on_submit(self, interaction: discord.Interaction): embed = discord.Embed( title=f"New {self.feedback_type.value} submission", description=f"```{self.feedback.value}```", - color=0x1E9FE3, + color=core.constants.CYAN_COLOR, ) embed.set_footer(text=interaction.user, icon_url=interaction.user.avatar) message = await channel.send(embed=embed) @@ -178,5 +178,5 @@ async def on_error(self, interaction: discord.Interaction, error: Exception) -> logger.error(type(error), error, error.__traceback__) -async def setup(bot: Substiify): +async def setup(bot: core.Substiify): await bot.add_cog(Feedback(bot)) diff --git a/extensions/free_games.py b/extensions/free_games.py index a2e0ff4..633c04c 100644 --- a/extensions/free_games.py +++ b/extensions/free_games.py @@ -93,13 +93,13 @@ async def epic(self, ctx: commands.Context): logger.error(f"Error while creating 'Game' object: {ex}") if not current_free_games: - embed = discord.Embed(color=0x000000) + embed = discord.Embed(color=discord.Colour.dark_embed()) embed.description = "Could not find any currently free games" await ctx.send(embed=embed) for game in current_free_games: try: - embed = discord.Embed(title=game.title, url=game.epic_store_link, color=0x000000) + embed = discord.Embed(title=game.title, url=game.epic_store_link, color=discord.Colour.dark_embed()) embed.set_thumbnail(url=f"{EPIC_GAMES_LOGO_URL}") available_string = ( f"started , ends " diff --git a/extensions/fun.py b/extensions/fun.py index ed1b4f5..45eee8d 100644 --- a/extensions/fun.py +++ b/extensions/fun.py @@ -5,7 +5,7 @@ import discord from discord.ext import commands -from core.bot import Substiify +import core logger = logging.getLogger(__name__) @@ -13,7 +13,7 @@ class Fun(commands.Cog): COG_EMOJI = "🎱" - def __init__(self, bot: Substiify): + def __init__(self, bot: core.Substiify): self.bot = bot @commands.command(name="teams", aliases=["team"]) @@ -35,7 +35,7 @@ async def teams(self, ctx: commands.Context, *, players: str = None): team_1 = players_list[: len(players_list) // 2] team_2 = players_list[len(players_list) // 2 :] - embed = discord.Embed(title="Teams", color=0x00FFFF) + embed = discord.Embed(title="Teams", color=discord.Colour.dark_embed()) embed.add_field(name="Team 1", value="\n".join([f"{member} " for member in team_1])) embed.add_field(name="Team 2", value="\n".join([f"{member} " for member in team_2])) if ctx.author.voice and players: @@ -76,5 +76,5 @@ async def eightball(self, ctx: commands.Context, *, question: str): await ctx.send(embed=embed) -async def setup(bot: Substiify): +async def setup(bot: core.Substiify): await bot.add_cog(Fun(bot)) diff --git a/extensions/karma.py b/extensions/karma.py index 34109a8..50370ed 100644 --- a/extensions/karma.py +++ b/extensions/karma.py @@ -53,10 +53,10 @@ async def votes(self, ctx: commands.Context): Shows if votes are enabled in the current channel """ if ctx.channel.id in self.vote_channels: - embed = discord.Embed(color=0x23B40C) + embed = discord.Embed(color=discord.Color.green()) embed.description = f"Votes are **ALREADY enabled** in {ctx.channel.mention}!" else: - embed = discord.Embed(color=0xF66045) + embed = discord.Embed(color=discord.Color.red()) embed.description = f"Votes are **NOT enabled** in {ctx.channel.mention}!" await ctx.reply(embed=embed) @@ -69,7 +69,7 @@ async def list_votes(self, ctx: commands.Context): stmt = "SELECT * FROM discord_channel WHERE discord_server_id = $1 AND upvote = True" upvote_channels = await self.bot.db.fetch(stmt, ctx.guild.id) channels_string = "\n".join([f"{x['discord_channel_id']} ({x['channel_name']})" for x in upvote_channels]) - embed = discord.Embed(color=0x23B40C) + embed = discord.Embed(color=core.constants.PRIMARY_COLOR) if not channels_string: embed.description = "No votes channels found." return await ctx.send(embed=embed) @@ -93,17 +93,18 @@ async def start(self, ctx: commands.Context, channel: discord.abc.GuildChannel = stmt = "SELECT * FROM discord_channel WHERE discord_channel_id = $1 AND upvote = True" votes_enabled = await self.bot.db.fetch(stmt, channel.id) logger.info(f"Votes enabled: {votes_enabled}") - if not votes_enabled: - stmt = """INSERT INTO discord_channel (discord_channel_id, channel_name, discord_server_id, parent_discord_channel_id, upvote) - VALUES ($1, $2, $3, $4, $5) ON CONFLICT (discord_channel_id) DO UPDATE SET upvote = $5""" - await self.bot.db.execute(stmt, channel.id, channel.name, channel.guild.id, None, True) - else: - embed = discord.Embed(description=f"Votes are **already active** in {ctx.channel.mention}!", color=0x23B40C) + + embed = discord.Embed(color=discord.Colour.green()) + if votes_enabled: + embed.description = f"Votes are **already active** in {ctx.channel.mention}!" return await ctx.send(embed=embed) - embed = discord.Embed(description=f"Votes **enabled** in {channel.mention}!", color=0x23B40C) + + stmt = """INSERT INTO discord_channel (discord_channel_id, channel_name, discord_server_id, parent_discord_channel_id, upvote) + VALUES ($1, $2, $3, $4, $5) ON CONFLICT (discord_channel_id) DO UPDATE SET upvote = $5""" + await self.bot.db.execute(stmt, channel.id, channel.name, channel.guild.id, None, True) + + embed.description = f"Votes **enabled** in {channel.mention}!" await ctx.send(embed=embed) - if not ctx.interaction: - await ctx.message.delete() @votes.command() @commands.check_any(commands.has_permissions(manage_channels=True), commands.is_owner()) @@ -120,9 +121,11 @@ async def stop(self, ctx: commands.Context, channel: discord.TextChannel = None) if channel.id in self.vote_channels: self.vote_channels.remove(channel.id) - await ctx.send(embed=discord.Embed(description=f"Votes has been stopped in {channel.mention}!", color=0xF66045)) - if not ctx.interaction: - await ctx.message.delete() + embed = discord.Embed( + description=f"Votes has been stopped in {channel.mention}!", + color=discord.Colour.red(), + ) + await ctx.send(embed=embed) @commands.group( aliases=["k"], @@ -141,7 +144,8 @@ async def karma(self, ctx: commands.Context, user: discord.User = None): user = ctx.author if user.bot: - return await ctx.reply(embed=discord.Embed(description="Bots don't have karma!", color=0xF66045)) + embed = discord.Embed(description="Bots don't have karma!", color=discord.Colour.red()) + return await ctx.reply(embed=embed) user_karma = await self._get_user_karma(user.id, ctx.guild.id) user_karma = 0 if user_karma is None else user_karma @@ -152,7 +156,7 @@ async def karma(self, ctx: commands.Context, user: discord.User = None): @karma.error async def karma_error(self, ctx: commands.Context, error): if isinstance(error, commands.BadArgument): - embed = discord.Embed(color=0xF66045, description=error) + embed = discord.Embed(description=error, color=discord.Colour.red()) await ctx.send(embed=embed) @commands.cooldown(3, 10) @@ -185,7 +189,7 @@ async def karma_donate(self, ctx: commands.Context, *args): ) return await ctx.reply("Could not find a user or amount in the provided arguments.") - embed = discord.Embed(color=0xF66045) + embed = discord.Embed(color=discord.Colour.red()) if user.bot: embed.description = "You can't donate to bots!" return await ctx.send(embed=embed) @@ -211,7 +215,7 @@ async def karma_donate(self, ctx: commands.Context, *args): UPDATE_KARMA_QUERY, [(user.id, ctx.guild.id, amount), (ctx.author.id, ctx.guild.id, -amount)] ) - embed = discord.Embed(color=0x23B40C) + embed = discord.Embed(color=discord.Colour.green()) embed.description = f"{ctx.author.mention} has donated {amount} karma to {user.mention}!" await ctx.send(embed=embed) @@ -238,7 +242,7 @@ def pred(m: discord.Member) -> bool: @karma_donate.error async def karma_donate_error(self, ctx: commands.Context, error): - embed = discord.Embed(color=0xF66045) + embed = discord.Embed(color=discord.Colour.red()) if isinstance(error, NotEnoughArguments): embed.description = "You didn't specify an `amount` or a `user` to donate to!" elif isinstance(error, commands.BadArgument): @@ -660,7 +664,7 @@ async def kasino_close_error(self, ctx: commands.Context, error): if isinstance(error, commands.errors.MissingRequiredArgument): msg = f"You didn't provide a required argument!\nCorrect usage is `{ctx.prefix}kasino close `" msg += "\nUse option `3` to close and abort the kasino (no winner)." - embed = discord.Embed(description=msg, color=0xF66045) + embed = discord.Embed(description=msg, color=discord.Colour.red()) await ctx.send(embed=embed) elif isinstance(error, commands.errors.BadArgument): await ctx.send(f"Bad argument: {error}") diff --git a/extensions/music.py b/extensions/music.py index 8c3031c..6c686cd 100644 --- a/extensions/music.py +++ b/extensions/music.py @@ -6,19 +6,18 @@ from discord import ButtonStyle, Interaction, ui from discord.ext import commands +import core import utils -from core import config -from core.bot import Substiify logger = logging.getLogger(__name__) -EMBED_COLOR = 0x292B3E +EMBED_COLOR = core.constants.CYAN_COLOR class Music(commands.Cog): COG_EMOJI = "🎵" - def __init__(self, bot: Substiify): + def __init__(self, bot: core.Substiify): self.bot = bot async def cog_command_error(self, ctx, error): @@ -421,8 +420,8 @@ def __init__(self): super().__init__("No playing agent is available at the moment. Please try again later or contact support.") -async def setup(bot: Substiify): - if all([config.LAVALINK_NODE_URL, config.LAVALINK_PASSWORD]): +async def setup(bot: core.Substiify): + if all([core.config.LAVALINK_NODE_URL, core.config.LAVALINK_PASSWORD]): await bot.add_cog(Music(bot)) else: logger.warning("Lavalink is not configured. Skipping Music cog.") diff --git a/extensions/owner.py b/extensions/owner.py index f2ac7ad..9ffc101 100644 --- a/extensions/owner.py +++ b/extensions/owner.py @@ -42,7 +42,7 @@ async def shutdown(self, ctx: commands.Context): """ Shuts down the bot. Made this in case something goes wrong. """ - embed = discord.Embed(description="Shutting down...", color=0xF66045) + embed = discord.Embed(description="Shutting down...", color=discord.Colour.red()) await ctx.send(embed=embed) await self.bot.close() diff --git a/extensions/util.py b/extensions/util.py index 6efd031..a5dbb07 100644 --- a/extensions/util.py +++ b/extensions/util.py @@ -217,7 +217,11 @@ def convert(self, time): return time_val * time_dict[unit] def create_giveaway_embed(self, author: discord.Member, prize): - embed = discord.Embed(title=":tada: Giveaway :tada:", description=f"Win **{prize}**!", color=0x00FFFF) + embed = discord.Embed( + title=":tada: Giveaway :tada:", + description=f"Win **{prize}**!", + color=core.constants.CYAN_COLOR, + ) host = author.mention if isinstance(author, (discord.Member, discord.User)) else author embed.add_field(name="Hosted By:", value=host) return embed @@ -243,7 +247,11 @@ async def avatar(self, ctx: commands.Context, member: discord.Member | discord.U """ member = member or ctx.author current_avatar = member.display_avatar - embed = discord.Embed(title=f"{str(member.display_name)}'s avatar", url=current_avatar.url, color=0x1E9FE3) + embed = discord.Embed( + title=f"{member.display_name}'s avatar", + url=current_avatar.url, + color=core.constants.CYAN_COLOR, + ) embed.set_image(url=current_avatar.url) await ctx.send(embed=embed)