Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert command system to use kotlin as base #289

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ plugins {
idea
application

kotlin("jvm") version "1.6.0"
kotlin("jvm") version "1.6.10"
id("com.github.johnrengelman.shadow") version "7.1.2"
id("com.github.breadmoirai.github-release") version "2.2.12"
id("org.jmailen.kotlinter") version "3.5.1"
Expand Down Expand Up @@ -104,7 +104,6 @@ dependencies {

// kotlin
implementation(kotlin("stdlib-jdk8"))
// implementation(kotlin("kotlinx-coroutines-core"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0")

// JDA utils
Expand Down Expand Up @@ -279,7 +278,7 @@ shadowJar.apply {
}

tasks.withType<Wrapper> {
gradleVersion = "7.2"
gradleVersion = "7.3.3"
distributionType = DistributionType.ALL
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ml/duncte123/skybot/CommandManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public CommandManager(Variables variables) {
this.addCommand(new CoinCommand());
this.addCommand(new ColorCommand());
this.addCommand(new CookieCommand());
this.addCommand(new CrashCommand());
// this.addCommand(new CrashCommand());
this.addCommand(new CSShumorCommand());
this.addCommand(new CustomCommandCommand());
this.addCommand(new DanceCommand());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package ml.duncte123.skybot.commands.animals;

import com.fasterxml.jackson.databind.JsonNode;
import ml.duncte123.skybot.objects.command.Command;
import ml.duncte123.skybot.objects.BaseCommand;
import ml.duncte123.skybot.objects.command.CommandCategory;
import ml.duncte123.skybot.objects.command.CommandContext;

Expand All @@ -28,12 +28,13 @@
import static me.duncte123.botcommons.messaging.EmbedUtils.embedImage;
import static me.duncte123.botcommons.messaging.MessageUtils.sendEmbed;

public class AlpacaCommand extends Command {

public class AlpacaCommand extends BaseCommand {
public AlpacaCommand() {
this.category = CommandCategory.ANIMALS;
this.name = "alpaca";
this.help = "Shows an alpaca";
super(
"alpaca",
"Shows a random alpaca",
CommandCategory.ANIMALS
);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,22 @@
import io.sentry.Sentry;
import me.duncte123.botcommons.messaging.EmbedUtils;
import me.duncte123.botcommons.web.WebUtils;
import ml.duncte123.skybot.objects.command.Command;
import ml.duncte123.skybot.objects.BaseCommand;
import ml.duncte123.skybot.objects.command.CommandCategory;
import ml.duncte123.skybot.objects.command.CommandContext;

import javax.annotation.Nonnull;

import static me.duncte123.botcommons.messaging.MessageUtils.sendEmbed;

public class DogCommand extends Command {
public class DogCommand extends BaseCommand {

public DogCommand() {
this.category = CommandCategory.ANIMALS;
this.name = "dog";
this.help = "Shows a dog";
super(
"Dog",
"Shows a random dog",
CommandCategory.ANIMALS
);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,26 @@

import me.duncte123.botcommons.messaging.EmbedUtils;
import me.duncte123.botcommons.web.WebUtils;
import ml.duncte123.skybot.objects.command.Command;
import ml.duncte123.skybot.objects.BaseCommand;
import ml.duncte123.skybot.objects.command.CommandCategory;
import ml.duncte123.skybot.objects.command.CommandContext;

import javax.annotation.Nonnull;

import static me.duncte123.botcommons.messaging.MessageUtils.sendEmbed;

public class KittyCommand extends Command {
public class KittyCommand extends BaseCommand {

public KittyCommand() {
this.category = CommandCategory.ANIMALS;
this.name = "cat";
this.aliases = new String[]{
"kitty",
};
this.help = "Shows a cat";
super(
"cat",
"Shows a random cat",
CommandCategory.ANIMALS,
null,
new String[]{
"kitty",
}
);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,22 @@

import com.fasterxml.jackson.databind.JsonNode;
import me.duncte123.botcommons.messaging.EmbedUtils;
import ml.duncte123.skybot.objects.command.Command;
import ml.duncte123.skybot.objects.BaseCommand;
import ml.duncte123.skybot.objects.command.CommandCategory;
import ml.duncte123.skybot.objects.command.CommandContext;

import javax.annotation.Nonnull;

import static me.duncte123.botcommons.messaging.MessageUtils.sendEmbed;

public class LlamaCommand extends Command {
public class LlamaCommand extends BaseCommand {

public LlamaCommand() {
this.category = CommandCategory.ANIMALS;
this.name = "llama";
this.help = "Shows a llama";
super(
"llama",
"Shows a random llama",
CommandCategory.ANIMALS
);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,22 @@

import com.fasterxml.jackson.databind.JsonNode;
import me.duncte123.botcommons.messaging.EmbedUtils;
import ml.duncte123.skybot.objects.command.Command;
import ml.duncte123.skybot.objects.BaseCommand;
import ml.duncte123.skybot.objects.command.CommandCategory;
import ml.duncte123.skybot.objects.command.CommandContext;

import javax.annotation.Nonnull;

import static me.duncte123.botcommons.messaging.MessageUtils.sendEmbed;

public class SealCommand extends Command {
public class SealCommand extends BaseCommand {

public SealCommand() {
this.category = CommandCategory.ANIMALS;
this.name = "seal";
this.aliases = new String[]{
"zeehond",
};
this.help = "Shows a seal";
super(
"seal",
"Shows a random seal",
CommandCategory.ANIMALS
);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import me.duncte123.durationparser.DurationParser;
import me.duncte123.durationparser.ParsedDuration;
import ml.duncte123.skybot.objects.command.Command;
import ml.duncte123.skybot.objects.BaseCommand;
import ml.duncte123.skybot.objects.command.CommandCategory;
import ml.duncte123.skybot.objects.command.CommandContext;
import ml.duncte123.skybot.objects.command.Flag;
Expand All @@ -34,29 +34,36 @@

import static me.duncte123.botcommons.messaging.MessageUtils.sendMsg;

public class RemindmeCommand extends Command {
public class RemindmeCommand extends BaseCommand {

public RemindmeCommand() {
this.category = CommandCategory.UTILS;
this.name = "remind";
this.aliases = new String[]{
"remindme",
};
this.help = "Creates a reminder for you, add `--channel` to remind you in the current channel";
this.usage = "<reminder> -t <number><w/d/h/m/s>";
this.extraInfo = "Example: `{prefix}remind Clean your room :/ -t 1d5m";
this.flags = new Flag[]{
new Flag(
't',
"time",
"Sets the time for the reminder"
),
new Flag(
'c',
"channel",
"When this flag is set you will be reminded in the channel where you executed the command (reminder is in dms by default)"
),
};
super(
"remind",
"Creates a reminder for you, add `--channel` to remind you in the current channel",
CommandCategory.UTILS,
"Example: `{prefix}remind Clean your room :/ -t 1d5m",
new String[]{
"remindme",
},
false,
"<reminder> -t <number><w/d/h/m/s>",
true,
2,
List.of(),
List.of(),
new Flag[]{
new Flag(
't',
"time",
"Sets the time for the reminder"
),
new Flag(
'c',
"channel",
"When this flag is set you will be reminded in the channel where you executed the command (reminder is in your DMs by default)"
),
}
);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package ml.duncte123.skybot.commands.essentials;

import me.duncte123.botcommons.messaging.MessageUtils;
import ml.duncte123.skybot.objects.command.Command;
import ml.duncte123.skybot.objects.BaseCommand;
import ml.duncte123.skybot.objects.command.CommandCategory;
import ml.duncte123.skybot.objects.command.CommandContext;
import ml.duncte123.skybot.objects.command.Flag;
Expand All @@ -40,22 +40,24 @@
import static me.duncte123.botcommons.messaging.MessageUtils.sendEmbed;

@SuppressWarnings("ConstantConditions")
public class ShardInfoCommand extends Command {
public class ShardInfoCommand extends BaseCommand {

public ShardInfoCommand() {
this.category = CommandCategory.UTILS;
this.name = "shardinfo";
this.aliases = new String[]{
"shards",
};
this.help = "Get information about all things shards";
this.flags = new Flag[]{
new Flag(
'm',
"mobile",
"Shows a mobile friendly embed instead"
),
};
super(
"shardinfo",
"Get information about all things shards!",
CommandCategory.UTILS,
new String[]{
"shards",
},
new Flag[]{
new Flag(
'm',
"mobile",
"Shows a mobile friendly embed instead"
),
}
);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package ml.duncte123.skybot.commands.essentials;

import me.duncte123.botcommons.messaging.EmbedUtils;
import ml.duncte123.skybot.objects.command.Command;
import ml.duncte123.skybot.objects.BaseCommand;
import ml.duncte123.skybot.objects.command.CommandCategory;
import ml.duncte123.skybot.objects.command.CommandContext;
import ml.duncte123.skybot.utils.CommandUtils;
Expand All @@ -30,16 +30,20 @@
import static me.duncte123.botcommons.messaging.MessageUtils.sendEmbed;
import static me.duncte123.botcommons.messaging.MessageUtils.sendMsg;

public class TestTagCommand extends Command {
public class TestTagCommand extends BaseCommand {

public TestTagCommand() {
this.category = CommandCategory.UTILS;
this.name = "testtag";
this.aliases = new String[]{
"tt",
};
this.help = "Test your jagtag format before you save it as custom command etc.";
this.usage = "<JagTag syntax>";
super(
"testtag",
"Test your jagtag format before you save it as custom command etc.",
CommandCategory.UTILS,
null,
new String[]{
"tt",
},
false,
"<JagTag syntax>"
);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

import com.fasterxml.jackson.databind.JsonNode;
import me.duncte123.botcommons.messaging.MessageConfig;
import ml.duncte123.skybot.objects.BaseCommand;
import ml.duncte123.skybot.objects.api.DuncteApis;
import ml.duncte123.skybot.objects.command.Command;
import ml.duncte123.skybot.objects.command.CommandCategory;
import ml.duncte123.skybot.objects.command.CommandContext;

Expand All @@ -37,7 +37,7 @@

import static me.duncte123.botcommons.messaging.MessageUtils.sendMsg;

public class TokenCommand extends Command {
public class TokenCommand extends BaseCommand {

private static final Pattern TOKEN_REGEX = Pattern.compile("([a-zA-Z0-9]+)\\.([a-zA-Z0-9\\-_]+)\\.([a-zA-Z0-9\\-_]+)");
private static final String STRING_FORMAT = "Deconstruction results for token: `%s`%n%n" +
Expand All @@ -46,11 +46,16 @@ public class TokenCommand extends Command {
"Keep in mind that verifying if the token is valid by making a request to discord is against the TOS";

public TokenCommand() {
this.requiresArgs = true;
this.category = CommandCategory.UTILS;
this.name = "token";
this.help = "Deconstructs a token to get as much information as possible from it";
this.usage = "<token of a discord bot>";
super(
"token",
"Deconstructs a bot token to get as much information as possible from it",
CommandCategory.UTILS,
null,
new String[0],
false,
"<token of a discord bot>",
true
);
}

@Override
Expand Down
Loading