@@ -69,9 +69,11 @@ export class PlaygroundModule extends Module {
69
69
const exec = matchPlaygroundLink ( msg . content ) ;
70
70
if ( ! exec ) return ;
71
71
const embed = createPlaygroundEmbed ( msg . author , exec ) ;
72
- if ( exec . url === msg . content && ! isHelpChannel ( msg . channel ) ) {
72
+ if ( exec . isWholeMatch && ! isHelpChannel ( msg . channel ) ) {
73
73
// Message only contained the link
74
- await sendWithMessageOwnership ( msg , { embeds : [ embed ] } ) ;
74
+ await sendWithMessageOwnership ( msg , {
75
+ embeds : [ embed ] ,
76
+ } ) ;
75
77
await msg . delete ( ) ;
76
78
} else {
77
79
// Message also contained other characters
@@ -94,10 +96,12 @@ export class PlaygroundModule extends Module {
94
96
// By default, if you write a message in the box and then paste a long
95
97
// playground link, it will only put the paste in message.txt and will
96
98
// put the rest of the message in msg.content
97
- if ( ! exec || exec . url !== content ) return ;
99
+ if ( ! exec ?. isWholeMatch ) return ;
98
100
const shortenedUrl = await shortenPlaygroundLink ( exec . url ) ;
99
101
const embed = createPlaygroundEmbed ( msg . author , exec , shortenedUrl ) ;
100
- await sendWithMessageOwnership ( msg , { embeds : [ embed ] } ) ;
102
+ await sendWithMessageOwnership ( msg , {
103
+ embeds : [ embed ] ,
104
+ } ) ;
101
105
if ( ! msg . content ) await msg . delete ( ) ;
102
106
}
103
107
@@ -119,7 +123,7 @@ export class PlaygroundModule extends Module {
119
123
// Take care when messing with the truncation, it's extremely finnicky
120
124
function createPlaygroundEmbed (
121
125
author : User ,
122
- { url : _url , query, code } : PlaygroundLinkMatch ,
126
+ { url : _url , query, code, isEscaped } : PlaygroundLinkMatch ,
123
127
url : string = _url ,
124
128
) {
125
129
const embed = new MessageEmbed ( )
@@ -179,13 +183,16 @@ function createPlaygroundEmbed(
179
183
formattedSection . replace ( / ^ \s * \n | \n \s * $ / g, '' ) +
180
184
( prettyEndChar === pretty . length ? '' : '\n...' ) ;
181
185
182
- if ( ! startLine && ! endLine ) {
183
- embed . setFooter (
184
- 'You can choose specific lines to embed by selecting them before copying the link.' ,
185
- ) ;
186
+ if ( ! isEscaped ) {
187
+ embed . setDescription ( '**Preview:**' + makeCodeBlock ( content ) ) ;
188
+ if ( ! startLine && ! endLine ) {
189
+ embed . setFooter (
190
+ 'You can choose specific lines to embed by selecting them before copying the link.' ,
191
+ ) ;
192
+ }
186
193
}
187
194
188
- return embed . setDescription ( '**Preview:**' + makeCodeBlock ( content ) ) ;
195
+ return embed ;
189
196
}
190
197
191
198
async function shortenPlaygroundLink ( url : string ) {
0 commit comments