Code Monkey home page Code Monkey logo

discord-html-transcripts's Issues

Unexpected Token

When running the Bot, it errors that there is an unexpected token. I've reinstalled the package and still the same.

image

html format error

Discussed in #61

Originally posted by cyb3rgh05t August 14, 2022
Hi,

i have a little issue that i am not able te resolve, maybe you can help me?

Testing my bot over Visual Studio Code, transcript attachement show up like this:
image
this is the correct format.

but if i dockerize my bot, the transcript attachement show up like this:
image

do you know what i can do to fix the format?

Thanks

Custom filenames won't work

const attachment = await discordTranscripts.createTranscript(interaction.channel, {
        limit: -1,
        returnType: 'attachment',
        fileName: `${ticketData.TicketID}-transcript-${ticketUser.user.tag}.html`,
        poweredBy: true
});

Even though after adding like this its generating filename as default i.e trascript-(channel_id)

Suggestion

Currently couple of vital things are missing and I would love to see these being implemented!

  • Quotes and Block Quotes
  • Rendering of custom emojis in embed titles

Add URL property to can get the URL of the transcript

I like to get the URL of the transcript but i cannot because the property URL of Discord Attachments doesn't work and give me undefined so can you add this property and so if this is posible how can i do?
Thanks

Crash when Reference Message is deleted.

When having a message, which is replying to a deleted message, the bot throws an TypeError.

C:\Users\USER\Desktop\Quantum\Quantum Bots\transscript\node_modules\discord-html-transcripts\src\exporthtml.js:62
            const author = referencedMessage.author ?? static.DummyUser;
                                             ^

TypeError: Cannot read properties of undefined (reading 'author')
    at generateTranscript (C:\Users\USER\Desktop\Quantum\Quantum Bots\transscript\node_modules\discord-html-transcripts\src\exporthtml.js:62:46)
    at Object.module.exports.createTranscript (C:\Users\USER\Desktop\Quantum\Quantum Bots\transscript\node_modules\discord-html-transcripts\src\index.js:68:12)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Client.<anonymous> (C:\Users\USER\Desktop\Quantum\Quantum Bots\transscript\main.js:23:28)

Suggestion and bug report

Hi, my suggestion is to format the date and time to local zone.

And the bug is if the user input a lot of text, the text exceds the page width.

image

a

a

Error: Could not parse CSS stylesheet

Error: Could not parse CSS stylesheet at exports.createStylesheet (/application/node_modules/jsdom/lib/jsdom/living/helpers/stylesheets.js:34:21) at HTMLStyleElementImpl._updateAStyleBlock (/application/node_modules/jsdom/lib/jsdom/living/nodes/HTMLStyleElement-impl.js:68:5) at HTMLStyleElementImpl._childTextContentChangeSteps (/application/node_modules/jsdom/lib/jsdom/living/nodes/HTMLStyleElement-impl.js:36:12) at TextImpl.replaceData (/application/node_modules/jsdom/lib/jsdom/living/nodes/CharacterData-impl.js:108:23) at TextImpl.set data [as data] (/application/node_modules/jsdom/lib/jsdom/living/nodes/CharacterData-impl.js:26:10) at JSDOMParse5Adapter.insertText (/application/node_modules/jsdom/lib/jsdom/browser/parser/html.js:142:22) at Parser._insertCharacters (/application/node_modules/jsdom/node_modules/parse5/lib/parser/index.js:600:30) at Object.insertCharacters (/application/node_modules/jsdom/node_modules/parse5/lib/parser/index.js:1062:7) at Parser._processToken (/application/node_modules/jsdom/node_modules/parse5/lib/parser/index.js:657:55) at Parser._processInputToken (/application/node_modules/jsdom/node_modules/parse5/lib/parser/index.js:684:18) at Parser._runParsingLoop (/application/node_modules/jsdom/node_modules/parse5/lib/parser/index.js:440:18) at Parser.parse (/application/node_modules/jsdom/node_modules/parse5/lib/parser/index.js:344:14) at Object.parse (/application/node_modules/jsdom/node_modules/parse5/lib/index.js:10:19) at parseIntoDocument (/application/node_modules/jsdom/lib/jsdom/browser/parser/html.js:202:17) at parseIntoDocument (/application/node_modules/jsdom/lib/jsdom/browser/parser/index.js:31:10) at new JSDOM (/application/node_modules/jsdom/lib/api.js:42:5)

This error occurs after trying to generate a transcript, the transcript is generated normally, but then this error occurs.

Accents look bad

Hello!

I have a spanish server and the accents look like this:
6LLYZL9

error

Hello, I have had this problem for a long time and I have not been able to solve it, does anyone know how I can solve this error?

image

Error: Cannot find module '../build/Release/canvas.node'

When I try to install the package, I get this error

Error: Cannot find module '../build/Release/canvas.node'
Require stack:
- C:\Users\user\node_modules\canvas\lib\bindings.js
- C:\Users\user\node_modules\canvas\lib\canvas.js
- C:\Users\user\node_modules\canvas\index.js
- C:\Users\user\node_modules\discord-html-transcripts\node_modules\jsdom\lib\jsdom\utils.js
- C:\Users\user\node_modules\discord-html-transcripts\node_modules\jsdom\lib\jsdom\living\events\MouseEvent-impl.js
- C:\Users\user\node_modules\discord-html-transcripts\node_modules\jsdom\lib\jsdom\living\generated\MouseEvent.js
- C:\Users\user\node_modules\discord-html-transcripts\node_modules\jsdom\lib\jsdom\living\events\EventTarget-impl.js
- C:\Users\user\node_modules\discord-html-transcripts\node_modules\jsdom\lib\jsdom\living\aborting\AbortSignal-impl.js
- C:\Users\user\node_modules\discord-html-transcripts\node_modules\jsdom\lib\jsdom\living\generated\AbortSignal.js
- C:\Users\user\node_modules\discord-html-transcripts\node_modules\jsdom\lib\jsdom\living\generated\AddEventListenerOptions.js
- C:\Users\user\node_modules\discord-html-transcripts\node_modules\jsdom\lib\jsdom\living\generated\EventTarget.js
- C:\Users\user\node_modules\discord-html-transcripts\node_modules\jsdom\lib\jsdom\living\interfaces.js
- C:\Users\user\node_modules\discord-html-transcripts\node_modules\jsdom\lib\jsdom\browser\Window.js
- C:\Users\user\node_modules\discord-html-transcripts\node_modules\jsdom\lib\api.js
- C:\Users\user\node_modules\discord-html-transcripts\dist\exporthtml.js
- C:\Users\user\node_modules\discord-html-transcripts\dist\index.js
- C:\Users\user\Desktop\Projects\Discord Bots\Fade Hosting\Events\Interaction\buttons.js
- C:\Users\user\node_modules\wokcommands\dist\FeatureHandler.js
- C:\Users\user\node_modules\wokcommands\dist\index.js
- C:\Users\user\Desktop\Projects\Discord Bots\Fade Hosting\index.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:946:15)
    at Module._load (node:internal/modules/cjs/loader:787:27)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (C:\Users\user\node_modules\canvas\lib\bindings.js:3:18)
    at Module._compile (node:internal/modules/cjs/loader:1112:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1166:10)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Module._load (node:internal/modules/cjs/loader:834:12)
    at Module.require (node:internal/modules/cjs/loader:1012:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\user\\node_modules\\canvas\\lib\\bindings.js',
    'C:\\Users\\user\\node_modules\\canvas\\lib\\canvas.js',
    'C:\\Users\\user\\node_modules\\canvas\\index.js',
    'C:\\Users\\user\\node_modules\\discord-html-transcripts\\node_modules\\jsdom\\lib\\jsdom\\utils.js',
    'C:\\Users\\user\\node_modules\\discord-html-transcripts\\node_modules\\jsdom\\lib\\jsdom\\living\\events\\MouseEvent-impl.js',
    'C:\\Users\\user\\node_modules\\discord-html-transcripts\\node_modules\\jsdom\\lib\\jsdom\\living\\generated\\MouseEvent.js',
    'C:\\Users\\user\\node_modules\\discord-html-transcripts\\node_modules\\jsdom\\lib\\jsdom\\living\\events\\EventTarget-impl.js',
    'C:\\Users\\user\\node_modules\\discord-html-transcripts\\node_modules\\jsdom\\lib\\jsdom\\living\\aborting\\AbortSignal-impl.js',
    'C:\\Users\\user\\node_modules\\discord-html-transcripts\\node_modules\\jsdom\\lib\\jsdom\\living\\generated\\AbortSignal.js',
    'C:\\Users\\user\\node_modules\\discord-html-transcripts\\node_modules\\jsdom\\lib\\jsdom\\living\\generated\\AddEventListenerOptions.js',
    'C:\\Users\\user\\node_modules\\discord-html-transcripts\\node_modules\\jsdom\\lib\\jsdom\\living\\generated\\EventTarget.js',
    'C:\\Users\\user\\node_modules\\discord-html-transcripts\\node_modules\\jsdom\\lib\\jsdom\\living\\interfaces.js',
    'C:\\Users\\user\\node_modules\\discord-html-transcripts\\node_modules\\jsdom\\lib\\jsdom\\browser\\Window.js',
    'C:\\Users\\user\\node_modules\\discord-html-transcripts\\node_modules\\jsdom\\lib\\api.js',
    'C:\\Users\\user\\node_modules\\discord-html-transcripts\\dist\\exporthtml.js',
    'C:\\Users\\user\\node_modules\\discord-html-transcripts\\dist\\index.js',
    'C:\\Users\\user\\Desktop\\Projects\\Discord Bots\\Fade Hosting\\Events\\Interaction\\buttons.js',
    'C:\\Users\\user\\node_modules\\wokcommands\\dist\\FeatureHandler.js',
    'C:\\Users\\user\\node_modules\\wokcommands\\dist\\index.js',
    'C:\\Users\\user\\Desktop\\Projects\\Discord Bots\\Fade Hosting\\index.js'
  ]
}

Suggestion & bug report

Hello! I would like to recommend that you add buttons to the transcripts as well! And I noticed that when a user sends a link it doesn't appear blue like on Discord...

Question

Hello, one question, is it possible to generate a transcript of the messages? And if you can, how would it be?

feat: guild fav-icon

Discussed in #70

Originally posted by AKT0106 September 22, 2022
use guild icon for fav icon.
very small feature but improving (i guess)

Not all messages are recovered

I just used the module for the first time and when I open the file, only 24 messages are displayed on a total of 1184.

This problem appears only with version 2.5.6 of the module.
Older versions like 2.5.5 work fine.

discord.js: v13.7.0

saveImages: true puts images at the bottom of the transcript.

When using the saveImages: true "setting", the images get saved to the bottom of the transcript regardless of when they were sent.

(Copied your response from the discord.)

issue comes from the fact that fetching an image takes time, and the package doesnt handle that properly
it adds the message as soon as it gets processed. For any normal message this will take the same amount of time for each message; and therefore will follow the order of the input
but images add a ton of processing time since you need to download the image
so all the nromal messages finish processing and get appended
the image though doesnt get appended until later since thats when it finishes downloading

Fetching Messages

fetching system fetch only 100 messages even if i put limit: -1 or remove it it still fetch only 100 messages and not all channel's messages
idk why

image

Embed Mentions

Hi i noticed that you package dont format mentions in embeds.
Do you have a intention do add that?

feat: Add option to save images when creating a transcript.

What I'm thinking is:

  1. If some option (let's say downloadImages)
  2. any attachment ending in png, jpeg, jpg, etc will be downloaded
  3. Using new Buffer(data).toString('base64'), the images will be converted to a base64 string.
  4. Image src will be data:image/<filetype>;base64, <base64>

Why do this?
Transcripts are usually used when a channel is about to be deleted (ticket close, etc), and when that happens all the attachments in the channel get purged from Discord's servers. After their cdn cache expires, the image will be gone forever, and the transcript images will be gone too.

if i get time ill work on implementing this.

Problem with some style syntaxes in markdown

Hello, I've noticed that some syntaxes in markdown don't work, like the italic style made with an underscore instead of an asterisk, and the spoiler style

There are problems with language support, an example in TypeScript:
But here I noticed that if I remove nohighlight from the class of the div element, the syntax appear.

The markdown hyperlinks doesn't show in html:

I rewrotted a function for this:

/**
 * Convert markdown hyperlinks to html hyperlinks
 * @param {string} text The text to convert to html `a` tag
 * @returns {string} The converted text
 * Base was found here: https://gist.github.com/alordiel/ed8587044be07e408f5f93b3124836b3
 */
function markdownHLToHtmlHL(text) {
  // Replace carriage return, line feed by classic line break in html
  text = text.replace(/(?:\r\n|\r|\n)/g, '<br />');

  // Check for links
  const elements = text.match(/\[.*?\)/g);
  // If no links, return base text
  if (elements.length === 0) return text;
  else {
    for (const element of elements) {
      // Get the content of the hyperlink
      const content = element.match(/\[(.*?)\]/)[1];
      // Get the link of the hyperlink
      const url = element.match(/\((.*?)\)/)[1];

      text = text.replace(
        element,
        `<a href="${url}" target="_blank">${content}</a>`
      );
    }
  }
  return text;
}

If I can make a suggestion, for the syntax styling, this theme of highlight.js is the same that discord uses.

I would have gladly made a pull request, unfortunately, it's beyond my capabilities ๐Ÿ˜“

`createTranscript()` always retrieves 100 messages

This is pretty simple once you look at it.

As one can see, we may pass a limit here in the options:

export async function createTranscript<T extends ExportReturnType = ExportReturnType.Attachment>(
channel: TextBasedChannel,
options: CreateTranscriptOptions<T> = {}
): Promise<ObjectType<T>> {

However, that does not matter as further down the line, the constant options is declared again in the while loop:

while (true) {
// create fetch options
const options = { limit: 100, before: lastMessageId };
if (!lastMessageId) delete options.before;
// fetch messages
const messages = await channel.messages.fetch(options);
// add the messages to the array
allMessages.push(...messages.values());
lastMessageId = messages.last()?.id;
// if there are no more messages, break
if (messages.size < 100) break;
// if the limit has been reached, break
if (allMessages.length >= (options.limit ?? Infinity)) break;
}

The limit is hardcoded to the magic number 100 here. That overwrites any user input and always fetches a maximum of 100 messages. To be pedantic, passing a limit of 70, for example, would fetch 100 messages in a channel with such an available quantity.


I'd just like to add that the README.md stated usage of -1, but I'm not sure if this should recursively fetch all messages in the channel or default to the maximum allowed amount - seems unclear. When looking in the source code, Infinity is referenced, so it seems to be the former - it would be appreciated if this specificness was documented!

BUG: Incomplete message list.

The bug is still present but the bot already puts a lot more messages than before.
I made the examples and I don't find where the problem can come from because as I already said, the old version works very well.

When the bot connects to discord, it sends the file instantly whereas if I use an old version, it takes a little longer because it exports the list of all messages correctly.

I put you the code I use:

require('dotenv/config');
const { Client, Intents } = require('discord.js');
const discordTranscripts = require('discord-html-transcripts');

const discord = new Client({
  intents: [
    Intents.FLAGS.GUILDS,
    Intents.FLAGS.GUILD_PRESENCES,
    Intents.FLAGS.GUILD_INTEGRATIONS,
    Intents.FLAGS.DIRECT_MESSAGES,
    Intents.FLAGS.DIRECT_MESSAGES
  ]
});

discord.login(process.env.DISCORD_Token);

discord.on('ready', async () => {
  console.log(discord.user.tag);

  const channel = discord.channels.cache.get('963640501028929556');

  const attachment = await discordTranscripts.createTranscript(channel, {
    limit: -1,
    returnType: 'attachment',
    fileName: 'transcript.html',
    minify: false,
    saveImages: false,
    useCDN: false
  });

  channel.send({
    files: [attachment]
  });
});

[Bug] Sending weird jpg file.

No idea why but the library has been working perfectly fine for me, but after I tried to shift from manual button interaction transcripts to more like a automatic transcript thingy, the filename/file is showing up as a jpg even tho i've explicitly set it to save it as transcript.html within the code.
image
image

V14 Bug

i programming a bot in TS and when i use the function createTranscript the command fails, i checked yet if the channel is TextChannel but doesn't work.

Save images not actually saving images

Hi, I don't know if this is a suggestion, but could you please add an option so that this doesn't happen?

image

Or could it be fixed if when the user does not see the channel, the image is still saved, I do not know if it is possible, please. :( Because when I use, for example, /close on my server, that always happens to me.

Question

Do you have an idea why sometimes when saving the transcript it is not saved simply when executing !transcript it does not send the file to the channel where it should be, everything is correct I do not understand what is happening.

And sometimes it does not save all the messages that are in that channel

image

Function error

It seems when doing the command it returns an error TypeError: inputChannel.isThread is not a function, I'm unsure on what this error specifies or means.
image

Feature Request - Upload / Save

Upload / Save

An option to either save a transcript locally or upload it to a webserver & get url to send to user/staff rather then a html file.

V14 Just doesn't work for me

discordTranscripts.createTranscript(channel, {returnType: 'buffer', saveImages: true})

with these options I get the error of (the line 35 is the code above^)

TypeError: Cannot read properties of undefined (reading 'createTranscript') [1] at Object.execute (C:\Users\arthur\WebstormProjects\typescriptbot\build\events\closeTicketCollector.js:35:71) [1] at processTicksAndRejections (node:internal/process/task_queues:96:5) [1] Emitted 'error' event on ExtendedClient instance at: [1] at emitUnhandledRejectionOrErr (node:events:251:10) [1] at processTicksAndRejections (node:internal/process/task_queues:85:21)

I tried every option imaginable and none of them work, v13 works fine for me. It's just v14 not working

New bug founded in V14

i wrote a issue a week ago about a bug in v14, i use the same code for the new version (2.5.8) and a new error appears.
image

image

Deleted channel mentions causes it to error

If one of the messages included a mention for a deleted/invalid channel it would make it error, here's an example of the error

rawError: { message: 'Unknown Channel', code: 10003 },
   code: 10003,
   status: 404,
   method: 'GET',
   url: 'https://discord.com/api/v10/channels/997048704513085500',
   requestBody: { files: undefined, json: undefined }
 } Promise {
   <rejected> DiscordAPIError[10003]: Unknown Channel
       at SequentialHandler.runRequest (D:FoldersJavascript
ajk
ode_modules@discordjs
estdistlibhandlersSequentialHandler.cjs:293:15)
       at processTicksAndRejections (node:internal/process/task_queues:96:5)
       at async SequentialHandler.queueRequest (D:FoldersJavascript
ajk
ode_modules@discordjs
estdistlibhandlersSequentialHandler.cjs:99:14)
       at async REST.request (D:FoldersJavascript
ajk
ode_modules@discordjs
estdistlibREST.cjs:52:22)
       at async GuildChannelManager.fetch (D:FoldersJavascript
ajk
ode_modulesdiscord.jssrcmanagersGuildChannelManager.js:339:20)
       at async file:///D:/Folders/Javascript/rajk/src/slashCommands/archive.js:49:41 {
     rawError: { message: 'Unknown Channel', code: 10003 },
     code: 10003,
     status: 404,
     method: 'GET',
     url: 'https://discord.com/api/v10/channels/997048704513085500',
     requestBody: { files: undefined, json: undefined }
   }
}

Out of memory when tryng to transcript large channels

I tried to transcript a channel with over 600k messages, obviously it took hours, but at the end of all the fetch when creating the html i get an out of memory error.

it would be cool if the api permit to create multiple part for the transcript (idk, 100k messages for each part).

btw im using Krayon0 pull request, without that i cant fetch more than 100 messages

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 00007FF7E67B815F v8::internal::CodeObjectRegistry::~CodeObjectRegistry+114079
 2: 00007FF7E67454C6 DSA_meth_get_flags+65542
 3: 00007FF7E674637D node::OnFatalError+301
 4: 00007FF7E707BA0E v8::Isolate::ReportExternalAllocationLimitReached+94
 5: 00007FF7E7065FED v8::SharedArrayBuffer::Externalize+781
 6: 00007FF7E6F093BC v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1468
 7: 00007FF7E6F16069 v8::internal::Heap::PublishPendingAllocations+1129
 8: 00007FF7E6F1303A v8::internal::Heap::PageFlagsAreConsistent+2842
 9: 00007FF7E6F05C99 v8::internal::Heap::CollectGarbage+2137
10: 00007FF7E6F03E50 v8::internal::Heap::AllocateExternalBackingStore+2000
11: 00007FF7E6F289D6 v8::internal::Factory::NewFillerObject+214
12: 00007FF7E6C5AEA5 v8::internal::DateCache::Weekday+1797
13: 00007FF7E7109701 v8::internal::SetupIsolateDelegate::SetupHeap+494417
14: 00007FF7E70E552A v8::internal::SetupIsolateDelegate::SetupHeap+346490
15: 00007FF7E70E0FAC v8::internal::SetupIsolateDelegate::SetupHeap+328700
16: 0000022D652AE04D 

Please make it compatible with v14 :(

I need it, would be so great! Sadly, there's an error when I try to use it.
Unhandled promise rejection: DiscordAPIError[50035]: Invalid Form Body before[NUMBER_TYPE_COERCE]: Value "undefined" is not snowflake. at SequentialHandler.runRequest (C:\Users\Felix\OneDrive\Desktop\LSPD\Butler Next Gen\FIB - Nightmare - Recode\node_modules\@discordjs\rest\dist\index.js:679:15) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async SequentialHandler.queueRequest (C:\Users\Felix\OneDrive\Desktop\LSPD\Butler Next Gen\FIB - Nightmare - Recode\node_modules\@discordjs\rest\dist\index.js:482:14) at async MessageManager._fetchMany (C:\Users\Felix\OneDrive\Desktop\LSPD\Butler Next Gen\FIB - Nightmare - Recode\node_modules\discord.js\src\managers\MessageManager.js:226:18) { rawError: { code: 50035, errors: { before: [Object] }, message: 'Invalid Form Body' }, code: 50035, status: 400, method: 'get', url: 'https://discord.com/api/v10/channels/982045634976682084/messages?limit=100&before=undefined', requestBody: { files: undefined, json: undefined } }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.