Skip to content

Commit

Permalink
Download image instead of hotlinking craftar images
Browse files Browse the repository at this point in the history
  • Loading branch information
MrPowerGamerBR committed Dec 19, 2024
1 parent ff8d3d8 commit d8cfa68
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import net.perfectdreams.loritta.morenitta.interactions.commands.SlashCommandArg
import net.perfectdreams.loritta.morenitta.interactions.commands.SlashCommandDeclarationWrapper
import net.perfectdreams.loritta.morenitta.interactions.commands.options.ApplicationCommandOptions
import net.perfectdreams.loritta.morenitta.interactions.commands.slashCommand
import net.perfectdreams.loritta.morenitta.utils.LorittaUtils
import net.perfectdreams.minecraftmojangapi.MinecraftMojangAPI
import java.util.*

Expand Down Expand Up @@ -333,8 +334,11 @@ class MinecraftCommand(val loritta: LorittaBot) : SlashCommandDeclarationWrapper
)
}

// Bypasses that "omg amplification attack" embed that Craftar has when hotlinking from Discord...
// TODO: Maybe we should build our own skin service that isn't picky, heck, it could be a smol lib
val attachment = LorittaUtils.downloadFile(loritta, "https://crafatar.com/$type/$uuid?size=128&overlay", bypassSafety = true)!!
context.reply(false) {
content = "https://crafatar.com/$type/$uuid?size=128&overlay"
files += FileUpload.fromData(attachment, "player.png")
}
}
}
Expand Down

0 comments on commit d8cfa68

Please sign in to comment.