File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,10 @@ import {
66 optional ,
77} from 'cookiecord' ;
88import { Message , MessageEmbed , TextChannel } from 'discord.js' ;
9- import { compressToEncodedURIComponent } from 'lz-string' ;
9+ import {
10+ compressToEncodedURIComponent ,
11+ decompressFromEncodedURIComponent ,
12+ } from 'lz-string' ;
1013import { TS_BLUE } from '../env' ;
1114import {
1215 findCodeblockFromChannel ,
@@ -56,6 +59,7 @@ export class PlaygroundModule extends Module {
5659 . setColor ( TS_BLUE )
5760 . setTitle ( 'Shortened Playground link' )
5861 . setAuthor ( msg . author . tag , msg . author . displayAvatarURL ( ) )
62+ . setDescription ( extractOneLinerFromURL ( exec [ 0 ] ) )
5963 . setURL ( exec [ 0 ] ) ;
6064 if ( exec [ 0 ] == msg . content ) {
6165 // Message only contained the link
@@ -82,3 +86,11 @@ export class PlaygroundModule extends Module {
8286 this . editedLongLink . delete ( msg . id ) ;
8387 }
8488}
89+
90+ export const extractOneLinerFromURL = ( url : string ) => {
91+ if ( url . includes ( '#code/' ) ) {
92+ const zipped = url . split ( '#code/' ) [ 1 ] ;
93+ const unzipped = decompressFromEncodedURIComponent ( zipped ) ;
94+ return unzipped ?. split ( '\n' ) [ 0 ] + '...' ;
95+ }
96+ } ;
You can’t perform that action at this time.
0 commit comments