forked from cswimr/SeaCogs
fix(aurora): updated message_factory for addrole support
This commit is contained in:
parent
cd514d0535
commit
38b0580228
1 changed files with 10 additions and 8 deletions
|
@ -2,16 +2,12 @@
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
from discord import (Color, Embed, Guild, Interaction, InteractionMessage,
|
from discord import Color, Embed, Guild, Interaction, InteractionMessage, Member, Role, User
|
||||||
Member, Role, User)
|
|
||||||
from redbot.core import commands
|
from redbot.core import commands
|
||||||
from redbot.core.utils.chat_formatting import (bold, box, error,
|
from redbot.core.utils.chat_formatting import bold, box, error, humanize_timedelta, warning
|
||||||
humanize_timedelta, warning)
|
|
||||||
|
|
||||||
from aurora.utilities.config import config
|
from aurora.utilities.config import config
|
||||||
from aurora.utilities.utils import (fetch_channel_dict, fetch_user_dict,
|
from aurora.utilities.utils import fetch_channel_dict, fetch_user_dict, get_bool_emoji, get_next_case_number, get_pagesize_str
|
||||||
get_bool_emoji, get_next_case_number,
|
|
||||||
get_pagesize_str)
|
|
||||||
|
|
||||||
|
|
||||||
async def message_factory(
|
async def message_factory(
|
||||||
|
@ -50,6 +46,8 @@ async def message_factory(
|
||||||
else:
|
else:
|
||||||
guild_name = guild.name
|
guild_name = guild.name
|
||||||
|
|
||||||
|
title = moderation_type
|
||||||
|
|
||||||
if moderation_type in ["tempbanned", "muted"] and duration:
|
if moderation_type in ["tempbanned", "muted"] and duration:
|
||||||
embed_duration = f" for {humanize_timedelta(timedelta=duration)}"
|
embed_duration = f" for {humanize_timedelta(timedelta=duration)}"
|
||||||
else:
|
else:
|
||||||
|
@ -59,13 +57,17 @@ async def message_factory(
|
||||||
embed_desc = "received a"
|
embed_desc = "received a"
|
||||||
elif moderation_type == "addrole":
|
elif moderation_type == "addrole":
|
||||||
embed_desc = f"received the {role.name} role"
|
embed_desc = f"received the {role.name} role"
|
||||||
|
title = "Role Added"
|
||||||
|
moderation_type = ""
|
||||||
elif moderation_type == "removerole":
|
elif moderation_type == "removerole":
|
||||||
embed_desc = f"lost the {role.name} role"
|
embed_desc = f"lost the {role.name} role"
|
||||||
|
title = "Role Removed"
|
||||||
|
moderation_type = ""
|
||||||
else:
|
else:
|
||||||
embed_desc = "been"
|
embed_desc = "been"
|
||||||
|
|
||||||
embed = Embed(
|
embed = Embed(
|
||||||
title=str.title(moderation_type),
|
title=str.title(title),
|
||||||
description=f"You have {embed_desc} {moderation_type}{embed_duration} in {guild_name}.",
|
description=f"You have {embed_desc} {moderation_type}{embed_duration} in {guild_name}.",
|
||||||
color=color,
|
color=color,
|
||||||
timestamp=datetime.now(),
|
timestamp=datetime.now(),
|
||||||
|
|
Loading…
Reference in a new issue