Branding, closes #146
See merge request stark-industries/jarvis/jarvis-bot!74
This commit is contained in:
commit
4660bab812
7 changed files with 54 additions and 4 deletions
37
jarvis/branding.py
Normal file
37
jarvis/branding.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
"""JARVIS brandings."""
|
||||
PRIMARY_COLOR = "#3498db"
|
||||
HARD_ACTION = "#ff0000"
|
||||
MODERATE_ACTION = "#ff9900"
|
||||
SOFT_ACTION = "#ffff00"
|
||||
GOOD_ACTION = "#00ff00"
|
||||
|
||||
COMMAND_TYPES = {
|
||||
"HARD": ["ban", "lockdown"],
|
||||
"MODERATE": ["kick", "mute", "lock"],
|
||||
"SOFT": ["warning"],
|
||||
"GOOD": ["unban", "unmute"],
|
||||
}
|
||||
|
||||
CUSTOM_COMMANDS = {}
|
||||
|
||||
|
||||
def get_command_color(command: str) -> str:
|
||||
"""
|
||||
Get a command's color.
|
||||
|
||||
Args:
|
||||
command: Command name
|
||||
|
||||
Returns:
|
||||
Hex color string
|
||||
"""
|
||||
if command in COMMAND_TYPES["HARD"]:
|
||||
return HARD_ACTION
|
||||
elif command in COMMAND_TYPES["MODERATE"]:
|
||||
return MODERATE_ACTION
|
||||
elif command in COMMAND_TYPES["SOFT"]:
|
||||
return SOFT_ACTION
|
||||
elif command in COMMAND_TYPES["GOOD"]:
|
||||
return GOOD_ACTION
|
||||
else:
|
||||
return CUSTOM_COMMANDS.get(command, PRIMARY_COLOR)
|
|
@ -336,7 +336,6 @@ class Jarvis(StatsClient):
|
|||
title="User Verified",
|
||||
description=f"{after.mention} was verified",
|
||||
fields=fields,
|
||||
color="#fc9e3f",
|
||||
)
|
||||
embed.set_author(name=after.display_name, icon_url=after.display_avatar.url)
|
||||
embed.set_footer(text=f"{after.username}#{after.discriminator} | {after.id}")
|
||||
|
@ -368,7 +367,6 @@ class Jarvis(StatsClient):
|
|||
title="User Roles Changed",
|
||||
description=f"{after.mention} had roles changed",
|
||||
fields=fields,
|
||||
color="#fc9e3f",
|
||||
)
|
||||
embed.set_author(name=after.display_name, icon_url=after.display_avatar.url)
|
||||
embed.set_footer(text=f"{after.username}#{after.discriminator} | {after.id}")
|
||||
|
|
|
@ -17,6 +17,7 @@ from naff.models.naff.application_commands import (
|
|||
)
|
||||
from naff.models.naff.command import check
|
||||
|
||||
from jarvis.branding import get_command_color
|
||||
from jarvis.utils import build_embed
|
||||
from jarvis.utils.cogs import ModcaseCog
|
||||
from jarvis.utils.permissions import admin_or_permissions
|
||||
|
@ -54,6 +55,7 @@ class BanCog(ModcaseCog):
|
|||
title="User Banned",
|
||||
description=f"Reason: {reason}",
|
||||
fields=fields,
|
||||
color=get_command_color("ban"),
|
||||
)
|
||||
|
||||
embed.set_author(
|
||||
|
@ -82,6 +84,7 @@ class BanCog(ModcaseCog):
|
|||
title="User Unbanned",
|
||||
description=f"<@{user.id}> was unbanned",
|
||||
fields=[EmbedField(name="Reason", value=reason)],
|
||||
color=get_command_color("unban"),
|
||||
)
|
||||
embed.set_author(
|
||||
name=user.username,
|
||||
|
@ -158,6 +161,7 @@ class BanCog(ModcaseCog):
|
|||
title=f"You have been banned from {ctx.guild.name}",
|
||||
description=f"Reason: {reason}",
|
||||
fields=fields,
|
||||
color=get_command_color("ban"),
|
||||
)
|
||||
|
||||
user_embed.set_author(
|
||||
|
@ -366,6 +370,7 @@ class BanCog(ModcaseCog):
|
|||
title=title,
|
||||
description=f"No {'in' if not active else ''}active bans",
|
||||
fields=[],
|
||||
color=get_command_color("bans_list"),
|
||||
)
|
||||
embed.set_thumbnail(url=ctx.guild.icon.url)
|
||||
pages.append(embed)
|
||||
|
|
|
@ -10,6 +10,7 @@ from naff.models.naff.application_commands import (
|
|||
)
|
||||
from naff.models.naff.command import check
|
||||
|
||||
from jarvis.branding import get_command_color
|
||||
from jarvis.utils import build_embed
|
||||
from jarvis.utils.cogs import ModcaseCog
|
||||
from jarvis.utils.permissions import admin_or_permissions
|
||||
|
@ -43,6 +44,7 @@ class KickCog(ModcaseCog):
|
|||
title=f"You have been kicked from {guild_name}",
|
||||
description=f"Reason: {reason}",
|
||||
fields=[],
|
||||
color=get_command_color("kick"),
|
||||
)
|
||||
|
||||
embed.set_author(
|
||||
|
|
|
@ -20,6 +20,7 @@ from naff.models.naff.application_commands import (
|
|||
)
|
||||
from naff.models.naff.command import check
|
||||
|
||||
from jarvis.branding import get_command_color
|
||||
from jarvis.utils import build_embed
|
||||
from jarvis.utils.cogs import ModcaseCog
|
||||
from jarvis.utils.permissions import admin_or_permissions
|
||||
|
@ -50,6 +51,7 @@ class MuteCog(ModcaseCog):
|
|||
EmbedField(name="Reason", value=reason),
|
||||
EmbedField(name="Until", value=f"<t:{ts}:F> <t:{ts}:R>"),
|
||||
],
|
||||
color=get_command_color("mute"),
|
||||
)
|
||||
embed.set_author(name=user.display_name, icon_url=user.display_avatar.url)
|
||||
embed.set_thumbnail(url=user.display_avatar.url)
|
||||
|
@ -211,6 +213,7 @@ class MuteCog(ModcaseCog):
|
|||
title="User Unmuted",
|
||||
description=f"{user.mention} has been unmuted",
|
||||
fields=[],
|
||||
color=get_command_color("unmute"),
|
||||
)
|
||||
embed.set_author(name=user.display_name, icon_url=user.display_avatar.url)
|
||||
embed.set_thumbnail(url=user.display_avatar.url)
|
||||
|
|
|
@ -7,6 +7,7 @@ from naff.models.discord.embed import Embed, EmbedField
|
|||
from naff.models.discord.guild import AuditLogEntry
|
||||
from naff.models.discord.user import Member
|
||||
|
||||
from jarvis.branding import PRIMARY_COLOR
|
||||
from jarvis.config import JarvisConfig
|
||||
|
||||
|
||||
|
@ -14,7 +15,7 @@ def build_embed(
|
|||
title: str,
|
||||
description: str,
|
||||
fields: list,
|
||||
color: str = "#FF0000",
|
||||
color: str = PRIMARY_COLOR,
|
||||
timestamp: datetime = None,
|
||||
**kwargs: dict,
|
||||
) -> Embed:
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
from naff.models.discord.embed import Embed, EmbedField
|
||||
from naff.models.discord.user import Member
|
||||
|
||||
from jarvis.branding import get_command_color
|
||||
from jarvis.utils import build_embed
|
||||
|
||||
|
||||
|
@ -15,7 +16,10 @@ def warning_embed(user: Member, reason: str) -> Embed:
|
|||
"""
|
||||
fields = (EmbedField(name="Reason", value=reason, inline=False),)
|
||||
embed = build_embed(
|
||||
title="Warning", description=f"{user.mention} has been warned", fields=fields
|
||||
title="Warning",
|
||||
description=f"{user.mention} has been warned",
|
||||
fields=fields,
|
||||
color=get_command_color("warning"),
|
||||
)
|
||||
embed.set_author(name=user.display_name, icon_url=user.display_avatar.url)
|
||||
embed.set_footer(text=f"{user.username}#{user.discriminator} | {user.id}")
|
||||
|
|
Loading…
Add table
Reference in a new issue