Skip to content

Commit 995ce85

Browse files
authored
Merge branch 'master' into update-embed
2 parents c18e1f7 + eba49cf commit 995ce85

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Diff for: src/modules/playground.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import {
66
optional,
77
} from 'cookiecord';
88
import { Message, MessageEmbed, TextChannel } from 'discord.js';
9-
import { compressToEncodedURIComponent } from 'lz-string';
9+
import {
10+
compressToEncodedURIComponent,
11+
decompressFromEncodedURIComponent,
12+
} from 'lz-string';
1013
import { TS_BLUE } from '../env';
1114
import {
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+
};

0 commit comments

Comments
 (0)