Skip to content

Commit 3929525

Browse files
committed
Use a different short domain for non devs
1 parent 8fedcec commit 3929525

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/main/java/ml/duncte123/skybot/utils/AirUtils.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,13 +346,17 @@ public static void setJDAContext(JDA jda) {
346346
((JDAImpl) jda).setContext();
347347
}
348348

349-
@Nonnull
350349
public static PendingRequest<String> shortenUrl(String url, String googleKey, ObjectMapper mapper) {
350+
return shortenUrl(url, googleKey, mapper, "duncte.bot");
351+
}
352+
353+
@Nonnull
354+
public static PendingRequest<String> shortenUrl(String url, String googleKey, ObjectMapper mapper, String prefix) {
351355
final ObjectNode json = mapper.createObjectNode();
352356

353357
json.set("dynamicLinkInfo",
354358
mapper.createObjectNode()
355-
.put("domainUriPrefix", "duncte.bot")
359+
.put("domainUriPrefix", prefix)
356360
.put("link", url)
357361
);
358362
json.set("suffix",

src/main/kotlin/ml/duncte123/skybot/commands/uncategorized/ShortenCommand.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import ml.duncte123.skybot.objects.command.Command
2323
import ml.duncte123.skybot.objects.command.CommandContext
2424
import ml.duncte123.skybot.utils.AirUtils.isURL
2525
import ml.duncte123.skybot.utils.AirUtils.shortenUrl
26+
import ml.duncte123.skybot.utils.CommandUtils.isDev
2627

2728
class ShortenCommand : Command() {
2829

@@ -42,7 +43,9 @@ class ShortenCommand : Command() {
4243
return
4344
}
4445

45-
shortenUrl(args[0], ctx.config.apis.googl, ctx.variables.jackson).async(
46+
val prefix = if (isDev(ctx.author)) "duncte.bot" else "dunctebot.page.link"
47+
48+
shortenUrl(args[0], ctx.config.apis.googl, ctx.variables.jackson, prefix).async(
4649
{
4750
sendMsg(ctx, "Here is your shortened url: <$it>")
4851
},

0 commit comments

Comments
 (0)