-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix missing keys, refactor out main component
- Loading branch information
Showing
8 changed files
with
96 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { DiscordHeader, DiscordMessages as DiscordMessagesComponent } from '@derockdev/discord-components-react'; | ||
import { ChannelType } from 'discord.js'; | ||
import React, { Suspense } from 'react'; | ||
import type { RenderMessageContext } from '.'; | ||
import MessageContent, { RenderType } from './renderers/content'; | ||
import DiscordMessage from './renderers/message'; | ||
|
||
/** | ||
* The core transcript component. | ||
* Expects window.$discordMessage.profiles to be set for profile information. | ||
* | ||
* @param props Messages, channel details, callbacks, etc. | ||
* @returns | ||
*/ | ||
export default async function DiscordMessages({ messages, channel, callbacks, ...options }: RenderMessageContext) { | ||
return ( | ||
<DiscordMessagesComponent style={{ minHeight: '100vh' }}> | ||
{/* header */} | ||
<DiscordHeader | ||
guild={channel.isDMBased() ? 'Direct Messages' : channel.guild.name} | ||
channel={ | ||
channel.isDMBased() | ||
? channel.type === ChannelType.DM | ||
? channel.recipient?.tag ?? 'Unknown Recipient' | ||
: 'Unknown Recipient' | ||
: channel.name | ||
} | ||
icon={channel.isDMBased() ? undefined : channel.guild.iconURL({ size: 128 }) ?? undefined} | ||
> | ||
{channel.isThread() ? ( | ||
`Thread channel in ${channel.parent?.name ?? 'Unknown Channel'}` | ||
) : channel.isDMBased() ? ( | ||
`Direct Messages` | ||
) : channel.isVoiceBased() ? ( | ||
`Voice Text Channel for ${channel.name}` | ||
) : channel.type === ChannelType.GuildCategory ? ( | ||
`Category Channel` | ||
) : 'topic' in channel && channel.topic ? ( | ||
<MessageContent | ||
content={channel.topic} | ||
context={{ messages, channel, callbacks, type: RenderType.REPLY, ...options }} | ||
/> | ||
) : ( | ||
`This is the start of #${channel.name} channel.` | ||
)} | ||
</DiscordHeader> | ||
|
||
{/* body */} | ||
<Suspense> | ||
{messages.map((message) => ( | ||
<DiscordMessage message={message} context={{ messages, channel, callbacks, ...options }} key={message.id} /> | ||
))} | ||
</Suspense> | ||
|
||
{/* footer */} | ||
<div style={{ textAlign: 'center', width: '100%' }}> | ||
{options.footerText | ||
? options.footerText | ||
.replaceAll('{number}', messages.length.toString()) | ||
.replace('{s}', messages.length > 1 ? 's' : '') | ||
: `Exported ${messages.length} message${messages.length > 1 ? 's' : ''}.`}{' '} | ||
{options.poweredBy ? ( | ||
<span style={{ textAlign: 'center' }}> | ||
Powered by{' '} | ||
<a href="https://github.com/ItzDerock/discord-html-transcripts" style={{ color: 'lightblue' }}> | ||
discord-html-transcripts | ||
</a> | ||
. | ||
</span> | ||
) : null} | ||
</div> | ||
</DiscordMessagesComponent> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters