forked from blizzthewolf/SeaCogs
misc(aurora): removed ``` from all of the files that had it, replaced with redbot.core.utils.chat_formatting.box()
This commit is contained in:
parent
038c9413ce
commit
539052eb00
5 changed files with 17 additions and 13 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
.cache
|
|
@ -18,6 +18,7 @@ from discord.ext import tasks
|
|||
from pytimeparse2 import disable_dateutil, parse
|
||||
from redbot.core import app_commands, checks, commands, data_manager
|
||||
from redbot.core.app_commands import Choice
|
||||
from redbot.core.utils.chat_formatting import box
|
||||
|
||||
from .importers.galacticbot import ImportGalacticBotView
|
||||
from .importers.aurora import ImportAuroraView
|
||||
|
@ -601,7 +602,7 @@ class Aurora(commands.Cog):
|
|||
|
||||
os.remove(filename)
|
||||
except json.JSONDecodeError as e:
|
||||
await interaction.followup.send(content=f"An error occured while exporting the moderation history.\nError:\n```{e}```", ephemeral=ephemeral)
|
||||
await interaction.followup.send(content=f"An error occured while exporting the moderation history.\nError:\n" + box(e, 'py'), ephemeral=ephemeral)
|
||||
cursor.close()
|
||||
database.close()
|
||||
return
|
||||
|
@ -825,7 +826,7 @@ class Aurora(commands.Cog):
|
|||
|
||||
os.remove(filename)
|
||||
return
|
||||
await interaction.response.send_message(content=f"```json\n{json.dumps(case_dict, indent=2)}```", ephemeral=ephemeral)
|
||||
await interaction.response.send_message(content=box({json.dumps(case_dict, indent=2)}), ephemeral=ephemeral)
|
||||
return
|
||||
if changes:
|
||||
embed = await embed_factory('changes', await self.bot.get_embed_color(None), interaction=interaction, case_dict=case_dict)
|
||||
|
|
|
@ -4,6 +4,7 @@ from typing import Dict
|
|||
|
||||
from discord import ButtonStyle, Interaction, Message, ui
|
||||
from redbot.core import commands
|
||||
from redbot.core.utils.chat_formatting import box
|
||||
|
||||
from ..utilities.database import connect, create_guild_table, mysql_log
|
||||
|
||||
|
@ -100,7 +101,7 @@ class ImportAuroraView(ui.View):
|
|||
await interaction.edit_original_response(content="Import complete.")
|
||||
if failed_cases:
|
||||
await interaction.edit_original_response(
|
||||
content=f"Import complete.\n*Failed to import the following cases:*\n```{failed_cases}```"
|
||||
content=f"Import complete.\n*Failed to import the following cases:*\n" + box(failed_cases)
|
||||
)
|
||||
|
||||
@ui.button(label="No", style=ButtonStyle.danger)
|
||||
|
|
|
@ -3,6 +3,7 @@ from datetime import timedelta
|
|||
|
||||
from discord import ButtonStyle, Interaction, Message, ui
|
||||
from redbot.core import commands
|
||||
from redbot.core.utils.chat_formatting import box
|
||||
|
||||
from ..utilities.database import connect, create_guild_table, mysql_log
|
||||
|
||||
|
@ -136,7 +137,7 @@ class ImportGalacticBotView(ui.View):
|
|||
|
||||
await interaction.edit_original_response(content="Import complete.")
|
||||
if failed_cases:
|
||||
await interaction.edit_original_response(content=f"Import complete.\n*Failed to import the following cases:*\n```{failed_cases}```")
|
||||
await interaction.edit_original_response(content=f"Import complete.\n*Failed to import the following cases:*\n" + box(failed_cases))
|
||||
|
||||
@ui.button(label="No", style=ButtonStyle.danger)
|
||||
async def import_button_n(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
|
||||
|
|
|
@ -5,6 +5,7 @@ from datetime import datetime, timedelta
|
|||
|
||||
import humanize
|
||||
from discord import Color, Embed, Guild, Interaction, InteractionMessage, User, Member
|
||||
from redbot.core.utils.chat_formatting import box
|
||||
|
||||
from .config import config
|
||||
from .utils import fetch_channel_dict, fetch_user_dict, get_next_case_number
|
||||
|
@ -35,7 +36,6 @@ async def embed_factory(embed_type: str, color: Color, /, interaction: Interact
|
|||
Required arguments for 'case', 'changes', and `evidenceformat`:
|
||||
- interaction
|
||||
- case_dict"""
|
||||
codeblock = '```'
|
||||
if embed_type == 'message':
|
||||
|
||||
if moderation_type in ["kicked", "banned", "tempbanned", "unbanned"]:
|
||||
|
@ -97,12 +97,12 @@ async def embed_factory(embed_type: str, color: Color, /, interaction: Interact
|
|||
if case_dict['metadata']['imported_from']:
|
||||
embed.description += f"\n**Imported From:** {case_dict['metadata']['imported_from']}"
|
||||
|
||||
embed.add_field(name='Reason', value=f"{codeblock}{case_dict['reason']}{codeblock}", inline=False)
|
||||
embed.add_field(name='Reason', value=box(case_dict['reason']), inline=False)
|
||||
|
||||
if case_dict['resolved'] == 1:
|
||||
resolved_user = await fetch_user_dict(interaction, case_dict['resolved_by'])
|
||||
resolved_name = f"`{resolved_user['name']}`" if resolved_user['discriminator'] == "0" else f"`{resolved_user['name']}#{resolved_user['discriminator']}`"
|
||||
embed.add_field(name='Resolve Reason', value=f"Resolved by {resolved_name} ({resolved_user['id']}) for:\n{codeblock}{case_dict['resolve_reason']}{codeblock}", inline=False)
|
||||
embed.add_field(name='Resolve Reason', value=f"Resolved by {resolved_name} ({resolved_user['id']}) for:\n{box}{case_dict['resolve_reason']}", inline=False)
|
||||
|
||||
return embed
|
||||
|
||||
|
@ -147,16 +147,16 @@ async def embed_factory(embed_type: str, color: Color, /, interaction: Interact
|
|||
moderator_user = await fetch_user_dict(interaction, case_dict['moderator_id'])
|
||||
moderator_name = moderator_user['name'] if moderator_user['discriminator'] == "0" else f"{moderator_user['name']}#{moderator_user['discriminator']}"
|
||||
|
||||
content = f"{codeblock}prolog\nCase: {case_dict['moderation_id']:,} ({str.title(case_dict['moderation_type'])})\nTarget: {target_name} ({target_user['id']})\nModerator: {moderator_name} ({moderator_user['id']})"
|
||||
content = f"Case: {case_dict['moderation_id']:,} ({str.title(case_dict['moderation_type'])})\nTarget: {target_name} ({target_user['id']})\nModerator: {moderator_name} ({moderator_user['id']})"
|
||||
|
||||
if case_dict['duration'] != 'NULL':
|
||||
hours, minutes, seconds = map(int, case_dict['duration'].split(':'))
|
||||
td = timedelta(hours=hours, minutes=minutes, seconds=seconds)
|
||||
content += f"\nDuration: {humanize.precisedelta(td)}"
|
||||
|
||||
content += f"\nReason: {case_dict['reason']}{codeblock}"
|
||||
content += f"\nReason: {case_dict['reason']}"
|
||||
|
||||
return content
|
||||
return box(content, 'prolog')
|
||||
|
||||
if embed_type == 'log':
|
||||
if resolved:
|
||||
|
@ -182,11 +182,11 @@ async def embed_factory(embed_type: str, color: Color, /, interaction: Interact
|
|||
duration_embed = f"{humanize.precisedelta(td)} | <t:{case_dict['end_timestamp']}:R>" if case_dict["expired"] == '0' else str(humanize.precisedelta(td))
|
||||
embed.description = embed.description + f"\n**Duration:** {duration_embed}\n**Expired:** {bool(case_dict['expired'])}"
|
||||
|
||||
embed.add_field(name='Reason', value=f"{codeblock}{case_dict['reason']}{codeblock}", inline=False)
|
||||
embed.add_field(name='Reason', value=box(case_dict['reason']), inline=False)
|
||||
|
||||
resolved_user = await fetch_user_dict(interaction, case_dict['resolved_by'])
|
||||
resolved_name = resolved_user['name'] if resolved_user['discriminator'] == "0" else f"{resolved_user['name']}#{resolved_user['discriminator']}"
|
||||
embed.add_field(name='Resolve Reason', value=f"Resolved by {resolved_name} ({resolved_user['id']}) for:\n{codeblock}{case_dict['resolve_reason']}{codeblock}", inline=False)
|
||||
embed.add_field(name='Resolve Reason', value=f"Resolved by {resolved_name} ({resolved_user['id']}) for:\n" + box(case_dict['resolve_reason']), inline=False)
|
||||
else:
|
||||
if case_dict['target_type'] == 'USER':
|
||||
target_user = await fetch_user_dict(interaction, case_dict['target_id'])
|
||||
|
@ -208,7 +208,7 @@ async def embed_factory(embed_type: str, color: Color, /, interaction: Interact
|
|||
td = timedelta(**{unit: int(val) for unit, val in zip(["hours", "minutes", "seconds"], case_dict["duration"].split(":"))})
|
||||
embed.description = embed.description + f"\n**Duration:** {humanize.precisedelta(td)} | <t:{case_dict['end_timestamp']}:R>"
|
||||
|
||||
embed.add_field(name='Reason', value=f"{codeblock}{case_dict['reason']}{codeblock}", inline=False)
|
||||
embed.add_field(name='Reason', value=box(case_dict['reason']), inline=False)
|
||||
return embed
|
||||
|
||||
raise(TypeError("'type' argument is invalid!"))
|
||||
|
|
Loading…
Reference in a new issue