mirror of
https://github.com/wlinator/luminara.git
synced 2024-10-02 18:03:12 +00:00
First boost test push
This commit is contained in:
parent
6bed766b68
commit
94e1a7c288
5 changed files with 103 additions and 1 deletions
BIN
art/racu_boost.png
Normal file
BIN
art/racu_boost.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
|
@ -13,6 +13,7 @@
|
|||
"streak_silver": "https://gitlab.com/wlinator/Racu/-/raw/main/art/racu_streak_silver.png?_=1",
|
||||
"streak_gold": "https://gitlab.com/wlinator/Racu/-/raw/main/art/racu_streak_gold.png?_=1",
|
||||
"money_bag": "https://gitlab.com/wlinator/Racu/-/raw/main/art/racu_money_bag.png?_=1",
|
||||
"money_coins": "https://gitlab.com/wlinator/Racu/-/raw/main/art/racu_money_coins.png?_=1"
|
||||
"money_coins": "https://gitlab.com/wlinator/Racu/-/raw/main/art/racu_money_coins.png?_=1",
|
||||
"boost": "https://gitlab.com/wlinator/Racu/-/raw/main/art/racu_boost.png"
|
||||
}
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
# noinspection PyInterpreter
|
||||
import logging
|
||||
|
||||
from discord.ext.commands import Cog
|
||||
|
@ -26,6 +27,13 @@ class EventHandler(Cog):
|
|||
except Exception as e:
|
||||
_logs.info(f"[GreetingHandler] Message not sent in '{member.guild.name}'. Channel ID may be invalid. {e}")
|
||||
|
||||
# @Cog.listener()
|
||||
# async def on_member_update(self, before, after):
|
||||
# config = GuildConfig(after.guild.id)
|
||||
#
|
||||
# if not config.boost_channel_id:
|
||||
# return
|
||||
|
||||
@Cog.listener()
|
||||
async def on_command_completion(self, ctx) -> None:
|
||||
log_msg = '[CommandHandler] %s executed .%s | PREFIX' % (ctx.author.name, ctx.command.qualified_name)
|
||||
|
|
27
lib/embeds/boost.py
Normal file
27
lib/embeds/boost.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
import discord
|
||||
|
||||
from config.parser import JsonCache
|
||||
import lib.formatter
|
||||
|
||||
resources = JsonCache.read_json("art")
|
||||
exclam_icon = resources["icons"]["exclam"]
|
||||
boost_icon = resources["icons"]["boost"]
|
||||
|
||||
|
||||
class Boost:
|
||||
@staticmethod
|
||||
def message(member, template=None):
|
||||
embed = discord.Embed(
|
||||
color=discord.Color.embed_background(),
|
||||
description=f"_ _\nThanks for boosting, **{member.name}**!!"
|
||||
)
|
||||
|
||||
if template:
|
||||
# REPLACE
|
||||
embed.description = lib.formatter.template(template, member.name)
|
||||
|
||||
embed.set_thumbnail(url=boost_icon)
|
||||
embed.set_footer(text=f"Total server boosts: {member.guild.premium_subscription_count}",
|
||||
icon_url=exclam_icon)
|
||||
|
||||
return embed
|
|
@ -7,6 +7,7 @@ from discord.ext import commands, bridge
|
|||
from config.parser import JsonCache
|
||||
from lib import formatter
|
||||
from lib.embeds.greet import Greet
|
||||
from lib.embeds.boost import Boost
|
||||
from modules.config import config, set_prefix, xp_reward
|
||||
from services.GuildConfig import GuildConfig
|
||||
|
||||
|
@ -88,6 +89,7 @@ class Config(commands.Cog):
|
|||
command_config = config.create_subgroup(name="commands")
|
||||
intro_config = config.create_subgroup(name="intros")
|
||||
welcome_config = config.create_subgroup(name="greetings")
|
||||
boost_config = config.create_subgroup(name="boosts")
|
||||
level_config = config.create_subgroup(name="levels")
|
||||
|
||||
@birthday_config.command(
|
||||
|
@ -273,6 +275,70 @@ class Config(commands.Cog):
|
|||
embed = Greet.message(ctx.author, text)
|
||||
return await ctx.send(embed=embed, content=ctx.author.mention)
|
||||
|
||||
@boost_config.command(
|
||||
name="channel",
|
||||
description="Set the boost announcements channel."
|
||||
)
|
||||
async def config_boosts_channel(self, ctx, *, channel: discord.TextChannel):
|
||||
guild_config = GuildConfig(ctx.guild.id)
|
||||
guild_config.boost_channel_id = channel.id
|
||||
guild_config.push()
|
||||
|
||||
embed = discord.Embed(
|
||||
color=discord.Color.orange(),
|
||||
description=f"✅ | I will announce server boosts in {channel.mention}."
|
||||
)
|
||||
guild_icon = ctx.guild.icon if ctx.guild.icon else "https://i.imgur.com/79XfsbS.png"
|
||||
embed.set_author(name="Server Configuration", icon_url=guild_icon)
|
||||
|
||||
return await ctx.respond(embed=embed)
|
||||
|
||||
@boost_config.command(
|
||||
name="disable",
|
||||
description="Disable boost announcements in this server."
|
||||
)
|
||||
async def config_boosts_disable(self, ctx):
|
||||
guild_config = GuildConfig(ctx.guild.id)
|
||||
|
||||
embed = discord.Embed(
|
||||
color=discord.Color.orange(),
|
||||
)
|
||||
guild_icon = ctx.guild.icon if ctx.guild.icon else "https://i.imgur.com/79XfsbS.png"
|
||||
embed.set_author(name="Server Configuration", icon_url=guild_icon)
|
||||
|
||||
if not guild_config.boost_channel_id:
|
||||
embed.description = "👍 | Boost announcements were already disabled."
|
||||
return await ctx.respond(embed=embed)
|
||||
|
||||
else:
|
||||
guild_config.boost_channel_id = None
|
||||
guild_config.boost_message = None
|
||||
guild_config.push()
|
||||
embed.description = "✅ | Boost announcements are successfully disabled."
|
||||
return await ctx.respond(embed=embed)
|
||||
|
||||
@boost_config.command(
|
||||
name="template",
|
||||
description="Make a custom boost announcement template."
|
||||
)
|
||||
async def config_boosts_template(self, ctx, *, text: discord.Option(str, max_length=2000)):
|
||||
guild_config = GuildConfig(ctx.guild.id)
|
||||
guild_config.boost_message = text
|
||||
guild_config.push()
|
||||
|
||||
embed = discord.Embed(
|
||||
color=discord.Color.orange(),
|
||||
description=f"✅ | The booster template was successfully updated."
|
||||
)
|
||||
guild_icon = ctx.guild.icon if ctx.guild.icon else "https://i.imgur.com/79XfsbS.png"
|
||||
embed.add_field(name="Template", value=text, inline=False)
|
||||
embed.add_field(name="Example", value="An example will be sent in a separate message.", inline=False)
|
||||
embed.set_author(name="Server Configuration", icon_url=guild_icon)
|
||||
await ctx.respond(embed=embed)
|
||||
|
||||
embed = Boost.message(ctx.author, text)
|
||||
return await ctx.send(embed=embed, content=ctx.author.mention)
|
||||
|
||||
@level_config.command(
|
||||
name="channel",
|
||||
description="Set the level announcements channel."
|
||||
|
|
Loading…
Reference in a new issue