mirror of
https://github.com/wlinator/luminara.git
synced 2024-10-02 18:23:12 +00:00
Refactor boost module to use new configuration structure
This commit is contained in:
parent
bbec1a2622
commit
ebd1f95eba
4 changed files with 33 additions and 32 deletions
|
@ -1,4 +1,6 @@
|
|||
{
|
||||
"boost_default_title": "New Booster",
|
||||
"boost_default_description": "Thanks for boosting, **{0}**!!",
|
||||
"lumi_exception_generic": "An error occurred.",
|
||||
"lumi_exception_blacklisted": "User is blacklisted",
|
||||
"admin_award_description": "awarded **${0}** to {1}.",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from discord.ext.commands import Cog
|
||||
from loguru import logger
|
||||
|
||||
import lib.embeds.boost
|
||||
from modules.config import c_boost
|
||||
from lib.embeds.greet import Greet
|
||||
from services.blacklist_service import BlacklistUserService
|
||||
from services.config_service import GuildConfig
|
||||
|
@ -48,7 +48,7 @@ class EventHandler(Cog):
|
|||
if not config.boost_channel_id:
|
||||
return
|
||||
|
||||
embed = lib.embeds.boost.Boost.message(
|
||||
embed = c_boost.create_boost_embed(
|
||||
member,
|
||||
config.boost_message,
|
||||
config.boost_image_url,
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
import discord
|
||||
|
||||
import lib.formatter
|
||||
from lib.constants import CONST
|
||||
|
||||
|
||||
class Boost:
|
||||
@staticmethod
|
||||
def message(member, template=None, image_url=None):
|
||||
embed = discord.Embed(
|
||||
color=discord.Color.nitro_pink(),
|
||||
title="New Booster",
|
||||
description=f"Thanks for boosting, **{member.name}**!!",
|
||||
)
|
||||
|
||||
if template:
|
||||
# REPLACE
|
||||
embed.description = lib.formatter.template(template, member.name)
|
||||
|
||||
embed.set_author(name=member.name, icon_url=member.display_avatar)
|
||||
embed.set_image(url=image_url if image_url else CONST.BOOST_ICON)
|
||||
embed.set_footer(
|
||||
text=f"Total server boosts: {member.guild.premium_subscription_count}",
|
||||
icon_url=CONST.EXCLAIM_ICON,
|
||||
)
|
||||
|
||||
return embed
|
|
@ -3,7 +3,7 @@ from lib.embed_builder import EmbedBuilder
|
|||
from lib.constants import CONST
|
||||
from services.config_service import GuildConfig
|
||||
from lib.exceptions.LumiExceptions import LumiException
|
||||
from lib.embeds.boost import Boost
|
||||
import lib.formatter
|
||||
|
||||
|
||||
async def set_boost_channel(ctx, channel: discord.TextChannel):
|
||||
|
@ -61,7 +61,7 @@ async def set_boost_template(ctx, text: str):
|
|||
|
||||
await ctx.respond(embed=embed)
|
||||
|
||||
example_embed = Boost.message(ctx.author, text, guild_config.boost_image_url)
|
||||
example_embed = create_boost_embed(ctx.author, text, guild_config.boost_image_url)
|
||||
return await ctx.send(embed=example_embed, content=ctx.author.mention)
|
||||
|
||||
|
||||
|
@ -94,5 +94,31 @@ async def set_boost_image(ctx, image_url: str | None):
|
|||
|
||||
await ctx.respond(embed=embed)
|
||||
|
||||
example_embed = Boost.message(ctx.author, guild_config.boost_message, image_url)
|
||||
example_embed = create_boost_embed(
|
||||
ctx.author,
|
||||
guild_config.boost_message,
|
||||
image_url,
|
||||
)
|
||||
return await ctx.send(embed=example_embed, content=ctx.author.mention)
|
||||
|
||||
|
||||
async def create_boost_embed(
|
||||
member: discord.Member,
|
||||
template: str | None = None,
|
||||
image_url: str | None = None,
|
||||
):
|
||||
embed = discord.Embed(
|
||||
color=discord.Color.nitro_pink(),
|
||||
title=CONST.STRINGS["boost_default_title"],
|
||||
description=CONST.STRINGS["boost_default_description"].format(member.name),
|
||||
)
|
||||
|
||||
if template:
|
||||
embed.description = lib.formatter.template(template, member.name)
|
||||
|
||||
embed.set_author(name=member.name, icon_url=member.display_avatar)
|
||||
embed.set_image(url=image_url or CONST.BOOST_ICON)
|
||||
embed.set_footer(
|
||||
text=f"Total server boosts: {member.guild.premium_subscription_count}",
|
||||
icon_url=CONST.EXCLAIM_ICON,
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue