1919import org .mangorage .mangobot .modules .logs .LogAnalyser ;
2020import org .mangorage .mangobot .modules .logs .MissingDeps ;
2121import org .mangorage .mangobotapi .core .events .DiscordEvent ;
22+ import org .mangorage .mangobotapi .core .plugin .PluginManager ;
2223import org .mangorage .mangobotgithub .MangoBotGithub ;
24+ import org .mangorage .mangobotgithub .core .integration .MangoBotSiteIntegration ;
2325
26+ import java .io .File ;
2427import java .io .IOException ;
2528import java .io .InputStream ;
2629import java .nio .charset .StandardCharsets ;
@@ -159,6 +162,14 @@ public static void createGists(Message msg, User requester) {
159162 gist .setDescription ("Automatically made from MangoBot." );
160163
161164 HashMap <String , GistFile > FILES = new HashMap <>();
165+
166+ String id = null ;
167+ if (PluginManager .isLoaded ("mangobotsite" )) {
168+ try {
169+ id = MangoBotSiteIntegration .handleUpload (attachments );
170+ } catch (IOException ignored ) {}
171+ }
172+
162173 attachments .forEach (attachment -> {
163174 try {
164175
@@ -180,19 +191,26 @@ public static void createGists(Message msg, User requester) {
180191
181192 gist .setFiles (FILES );
182193
183- try {
184- var remote = service .createGist (gist );
185- StringBuilder result = new StringBuilder ();
186- result .append ("Gist -> [[gist](%s)]" .formatted (remote .getHtmlUrl ()));
194+ if (FILES .isEmpty () && id != null ) {
195+ msg .reply (("Upload -> [[mango](https://mangobot.mangorage.org/file?id=%s)]" .formatted (id ))).setSuppressEmbeds (true ).mentionRepliedUser (false ).queue ();
196+ } else {
197+ try {
198+ var remote = service .createGist (gist );
199+ StringBuilder result = new StringBuilder ();
200+ result .append ("Gist -> [[gist](%s)]" .formatted (remote .getHtmlUrl ()));
187201
188- remote . getFiles (). forEach (( key , file ) -> {
189- result .append (" [[raw %s]( %s)]" .formatted (file . getFilename (), file . getRawUrl () ));
190- });
202+ if ( id != null ) {
203+ result .append (" [[mango](https://mangobot.mangorage.org/file?id= %s)]" .formatted (id ));
204+ }
191205
192- msg .reply (result ).setSuppressEmbeds (true ).mentionRepliedUser (false ).queue ();
206+ remote .getFiles ().forEach ((key , file ) -> {
207+ result .append (" [[raw %s](%s)]" .formatted (file .getFilename (), file .getRawUrl ()));
208+ });
193209
194- } catch (IOException e ) {
195- throw new RuntimeException (e );
210+ msg .reply (result ).setSuppressEmbeds (true ).mentionRepliedUser (false ).queue ();
211+ } catch (IOException e ) {
212+ throw new RuntimeException (e );
213+ }
196214 }
197215
198216 });
0 commit comments