Various bug fixes
This commit is contained in:
parent
3fca071c1d
commit
f4512fc7e9
@ -36,7 +36,7 @@ async def message_info(ctx: CommandContext):
|
||||
original_sender = None
|
||||
|
||||
embed = discord.Embed()
|
||||
embed.timestamp = discord.utils.snowflake_time(str(mid))
|
||||
embed.timestamp = discord.utils.snowflake_time(mid)
|
||||
embed.colour = discord.Colour.blue()
|
||||
|
||||
if message.system_name:
|
||||
@ -55,8 +55,7 @@ async def message_info(ctx: CommandContext):
|
||||
embed.add_field(name="Sent by", value=sender_name)
|
||||
|
||||
message_content = await get_message_contents(ctx.client, message.channel, message.mid)
|
||||
if message_content:
|
||||
embed.description = message_content
|
||||
embed.description = message_content or "(unknown, message deleted)"
|
||||
|
||||
embed.set_author(name=message.name, icon_url=message.avatar_url or discord.Embed.Empty)
|
||||
|
||||
|
@ -88,4 +88,4 @@ async def export(ctx: CommandContext):
|
||||
}
|
||||
|
||||
f = io.BytesIO(json.dumps(data).encode("utf-8"))
|
||||
await ctx.client.send_file(ctx.message.channel, f, filename="system.json")
|
||||
await ctx.message.channel.send(content="Here you go!", file=discord.File(fp=f, filename="system.json"))
|
||||
|
@ -82,29 +82,31 @@ async def system_card(conn, client: discord.Client, system: System) -> discord.E
|
||||
value=system.description, inline=False)
|
||||
|
||||
# Get names of all members
|
||||
member_texts = []
|
||||
for member in await system.get_members(conn):
|
||||
member_texts.append("{} (`{}`)".format(escape(member.name), member.hid))
|
||||
all_members = await system.get_members(conn)
|
||||
if all_members:
|
||||
member_texts = []
|
||||
for member in all_members:
|
||||
member_texts.append("{} (`{}`)".format(escape(member.name), member.hid))
|
||||
|
||||
# Interim solution for pagination of large systems
|
||||
# Previously a lot of systems would hit the 1024 character limit and thus break the message
|
||||
# This splits large system lists into multiple embed fields
|
||||
# The 6000 character total limit will still apply here but this sort of pushes the problem until I find a better fix
|
||||
pages = [""]
|
||||
for member in member_texts:
|
||||
last_page = pages[-1]
|
||||
new_page = last_page + "\n" + member
|
||||
# Interim solution for pagination of large systems
|
||||
# Previously a lot of systems would hit the 1024 character limit and thus break the message
|
||||
# This splits large system lists into multiple embed fields
|
||||
# The 6000 character total limit will still apply here but this sort of pushes the problem until I find a better fix
|
||||
pages = [""]
|
||||
for member in member_texts:
|
||||
last_page = pages[-1]
|
||||
new_page = last_page + "\n" + member
|
||||
|
||||
if len(new_page) >= 1024:
|
||||
pages.append(member)
|
||||
else:
|
||||
pages[-1] = new_page
|
||||
if len(new_page) >= 1024:
|
||||
pages.append(member)
|
||||
else:
|
||||
pages[-1] = new_page
|
||||
|
||||
for index, page in enumerate(pages):
|
||||
field_name = "Members"
|
||||
if index >= 1:
|
||||
field_name = "Members (part {})".format(index + 1)
|
||||
card.add_field(name=field_name, value=page, inline=False)
|
||||
for index, page in enumerate(pages):
|
||||
field_name = "Members"
|
||||
if index >= 1:
|
||||
field_name = "Members (part {})".format(index + 1)
|
||||
card.add_field(name=field_name, value=page, inline=False)
|
||||
|
||||
card.set_footer(text="System ID: {}".format(system.hid))
|
||||
return card
|
||||
|
@ -107,7 +107,7 @@ async def do_proxy_message(conn, original_message: discord.Message, proxy_member
|
||||
try:
|
||||
sent_message = await webhook.send(
|
||||
content=inner_text,
|
||||
username=proxy_member.name,
|
||||
username="{} {}".format(proxy_member.name, proxy_member.tag),
|
||||
avatar_url=proxy_member.avatar_url,
|
||||
file=await make_attachment_file(original_message),
|
||||
wait=True
|
||||
|
Loading…
Reference in New Issue
Block a user