Skip to content

Commit 305f7a0

Browse files
committed
Obviously I had already created this system
1 parent 4a46490 commit 305f7a0

File tree

3 files changed

+33
-65
lines changed

3 files changed

+33
-65
lines changed

bot/src/main/java/me/duncte123/skybot/commands/guild/mod/ModBaseCommand.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,28 @@
1818

1919
package me.duncte123.skybot.commands.guild.mod;
2020

21+
import me.duncte123.skybot.Variables;
22+
import me.duncte123.skybot.objects.SlashSupport;
2123
import me.duncte123.skybot.objects.command.Command;
2224
import me.duncte123.skybot.objects.command.CommandCategory;
2325
import net.dv8tion.jda.api.Permission;
26+
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
27+
import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData;
28+
import org.jetbrains.annotations.NotNull;
2429

25-
public abstract class ModBaseCommand extends Command {
30+
public abstract class ModBaseCommand extends SlashSupport {
2631
public ModBaseCommand() {
2732
this.category = CommandCategory.MODERATION;
2833
this.userPermissions = new Permission[]{Permission.KICK_MEMBERS, Permission.BAN_MEMBERS};
2934
}
35+
36+
@Override
37+
protected void configureSlashSupport(@NotNull SlashCommandData baseData) {
38+
39+
}
40+
41+
@Override
42+
public void handleEvent(@NotNull SlashCommandInteractionEvent event, @NotNull Variables variables) {
43+
event.reply("Soontm").queue();
44+
}
3045
}

bot/src/main/java/me/duncte123/skybot/objects/command/ISlashCommand.java

Lines changed: 0 additions & 41 deletions
This file was deleted.

bot/src/main/kotlin/me/duncte123/skybot/commands/mod/VoiceKickCommand.kt

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,14 @@ import me.duncte123.botcommons.messaging.MessageUtils.sendSuccess
2323
import me.duncte123.skybot.Variables
2424
import me.duncte123.skybot.commands.guild.mod.ModBaseCommand
2525
import me.duncte123.skybot.objects.command.CommandContext
26-
import me.duncte123.skybot.objects.command.ISlashCommand
2726
import net.dv8tion.jda.api.Permission
2827
import net.dv8tion.jda.api.entities.channel.ChannelType
2928
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent
3029
import net.dv8tion.jda.api.interactions.commands.OptionType
3130
import net.dv8tion.jda.api.interactions.commands.build.OptionData
3231
import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData
3332

34-
class VoiceKickCommand : ModBaseCommand(), ISlashCommand {
33+
class VoiceKickCommand : ModBaseCommand() {
3534
init {
3635
this.requiresArgs = true
3736
this.name = "voicekick"
@@ -76,27 +75,24 @@ class VoiceKickCommand : ModBaseCommand(), ISlashCommand {
7675
sendMsg(ctx, "I could not find any Voice Channel or member to kick from voice")
7776
}
7877

79-
override fun getDescription(): String = this.help
80-
81-
override fun getSlashData(): SlashCommandData {
82-
return super.getSlashData()
83-
.addOptions(
84-
OptionData(
85-
OptionType.CHANNEL,
86-
"voice_channel",
87-
"The voice channel to kick ALL users from.",
88-
false
89-
),
90-
OptionData(
91-
OptionType.USER,
92-
"user",
93-
"The user to kick from the voice channel they are currently in.",
94-
false
95-
),
96-
)
78+
override fun configureSlashSupport(baseData: SlashCommandData) {
79+
baseData.addOptions(
80+
OptionData(
81+
OptionType.CHANNEL,
82+
"voice_channel",
83+
"The voice channel to kick ALL users from.",
84+
false
85+
),
86+
OptionData(
87+
OptionType.USER,
88+
"user",
89+
"The user to kick from the voice channel they are currently in.",
90+
false
91+
),
92+
)
9793
}
9894

99-
override fun handleSlashEvent(event: SlashCommandInteractionEvent, variables: Variables) {
95+
override fun handleEvent(event: SlashCommandInteractionEvent, variables: Variables) {
10096
val vc = event.getOption("voice_channel")?.asChannel
10197

10298
if (vc != null) {
@@ -122,8 +118,6 @@ class VoiceKickCommand : ModBaseCommand(), ISlashCommand {
122118
val member = event.getOption("user")?.asMember
123119

124120
if (member != null) {
125-
val memberChannel = member.voiceState?.channel
126-
127121
// We have to "== true" here because the return type is a nullable boolean
128122
if (member.voiceState?.inAudioChannel() == true) {
129123
event.guild!!.kickVoiceMember(member).queue()

0 commit comments

Comments
 (0)