File tree 1 file changed +13
-1
lines changed
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,10 @@ import {
6
6
optional ,
7
7
} from 'cookiecord' ;
8
8
import { Message , MessageEmbed , TextChannel } from 'discord.js' ;
9
- import { compressToEncodedURIComponent } from 'lz-string' ;
9
+ import {
10
+ compressToEncodedURIComponent ,
11
+ decompressFromEncodedURIComponent ,
12
+ } from 'lz-string' ;
10
13
import { TS_BLUE } from '../env' ;
11
14
import {
12
15
findCodeblockFromChannel ,
@@ -56,6 +59,7 @@ export class PlaygroundModule extends Module {
56
59
. setColor ( TS_BLUE )
57
60
. setTitle ( 'Shortened Playground link' )
58
61
. setAuthor ( msg . author . tag , msg . author . displayAvatarURL ( ) )
62
+ . setDescription ( extractOneLinerFromURL ( exec [ 0 ] ) )
59
63
. setURL ( exec [ 0 ] ) ;
60
64
if ( exec [ 0 ] == msg . content ) {
61
65
// Message only contained the link
@@ -82,3 +86,11 @@ export class PlaygroundModule extends Module {
82
86
this . editedLongLink . delete ( msg . id ) ;
83
87
}
84
88
}
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