File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -29,13 +29,23 @@ const executeSage = async function(interaction){
2929 await interaction . deferReply ( ) ;
3030
3131 return client . askSage ( code )
32- . then ( res => {
32+ . then ( async res => {
3333 embed . description = "Input:\n```py\n" + code + "\n```\nOutput:\n```\n" + (
3434 res ?. result ?. [ "text/plain" ] ?. trim ( ) || res ?. stdout ?. trim ( ) || ( res . result ?. image ? "Image Below" : "No Output" )
3535 ) + "\n```" ;
3636
37- if ( res ?. result ?. image ) { // @ts -ignore
38- embed . image = { url : res . result . image } ;
37+ if ( res ?. result ?. image ) {
38+ const imageRes = await fetch ( res . result . image ) ;
39+ if ( imageRes . ok ) {
40+ const buffer = await imageRes . arrayBuffer ( ) ;
41+ const attachment = {
42+ attachment : Buffer . from ( buffer ) ,
43+ name : `sage_output_${ interaction . id } .png` ,
44+ } ;
45+ // @ts -ignore
46+ embed . image = { url : `attachment://${ attachment . name } ` } ;
47+ return await interaction . editReply ( { embeds : [ embed ] , files : [ attachment ] } ) ;
48+ }
3949 }
4050
4151 return interaction . editReply ( { embeds : [ embed ] } ) ;
You can’t perform that action at this time.
0 commit comments