Skip to content

Commit 3cbaa81

Browse files
authored
Merge pull request #132 from ShreyasAyyengar/v4
Lamp to only delete slash-commands.
2 parents 6a73cca + 5a08fbc commit 3cbaa81

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ plugins {
1616
}
1717

1818
group = "io.github.revxrsal"
19-
version = "4.0.0-rc.10"
19+
version = "4.0.0-rc.11"
2020

2121
java {
2222
toolchain {

jda/src/main/java/revxrsal/commands/jda/JDAVisitors.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
3131
import net.dv8tion.jda.api.entities.emoji.Emoji;
3232
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
33+
import net.dv8tion.jda.api.interactions.commands.Command;
3334
import org.jetbrains.annotations.NotNull;
3435
import revxrsal.commands.Lamp;
3536
import revxrsal.commands.LampBuilderVisitor;
@@ -67,7 +68,14 @@ public final class JDAVisitors {
6768
for (ExecutableCommand<A> child : lamp.registry().commands()) {
6869
parser.parse(child);
6970
}
70-
jda.updateCommands().addCommands(parser.commands().values()).queue();
71+
jda.retrieveCommands().queue(existingCommands -> {
72+
existingCommands.forEach(existingCommand -> {
73+
if (existingCommand.getType() == Command.Type.SLASH) {
74+
jda.deleteCommandById(existingCommand.getId()).queue();
75+
}
76+
});
77+
});
78+
parser.commands().values().forEach(newCommand -> jda.upsertCommand(newCommand).queue());
7179
jda.addEventListener(new JDASlashListener<>(lamp, actorFactory));
7280
};
7381
}

0 commit comments

Comments
 (0)