Add clearchat dismiss button
This commit is contained in:
parent
3d626bb46f
commit
3a5b2a23c1
@ -4,9 +4,12 @@ import net.dv8tion.jda.api.entities.Message;
|
|||||||
import net.dv8tion.jda.api.entities.MessageHistory;
|
import net.dv8tion.jda.api.entities.MessageHistory;
|
||||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||||
|
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
|
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
|
||||||
import net.dv8tion.jda.api.interactions.InteractionHook;
|
import net.dv8tion.jda.api.interactions.InteractionHook;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
||||||
|
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -134,17 +137,28 @@ public class ClearChatCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// log having deleted the messages.
|
|
||||||
|
Button deleteButton = Button.danger("clear_delete", "Delete").withEmoji(Emoji.fromUnicode("❌"));
|
||||||
|
|
||||||
|
// log having deleted the messages (or not).
|
||||||
if(deleted < 1)
|
if(deleted < 1)
|
||||||
{
|
{
|
||||||
replyInteraction.editOriginal("\uD83D\uDE22 Couldn't clear any message!").queue();
|
replyInteraction.editOriginal("\uD83D\uDE22 Couldn't clear any message!")
|
||||||
|
.setActionRow(deleteButton).queue();
|
||||||
} else if(deleted == 1)
|
} else if(deleted == 1)
|
||||||
{
|
{
|
||||||
replyInteraction.editOriginal("✂ Cleared 1 message!").queue();
|
replyInteraction.editOriginal("✂ Cleared 1 message!")
|
||||||
|
.setActionRow(deleteButton).queue();
|
||||||
} else {
|
} else {
|
||||||
replyInteraction.editOriginal("✂ Cleared " + deleted + " messages!").queue();
|
replyInteraction.editOriginal("✂ Cleared " + deleted + " messages!")
|
||||||
|
.setActionRow(deleteButton).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteButton(ButtonInteractionEvent event)
|
||||||
|
{
|
||||||
|
// todo: permissions check
|
||||||
|
event.getInteraction().getMessage().delete().queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package wtf.beatrice.hidekobot.listeners;
|
|||||||
|
|
||||||
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
|
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
|
||||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
|
import wtf.beatrice.hidekobot.commands.slash.ClearChatCommand;
|
||||||
import wtf.beatrice.hidekobot.commands.slash.CoinFlipCommand;
|
import wtf.beatrice.hidekobot.commands.slash.CoinFlipCommand;
|
||||||
|
|
||||||
public class ButtonInteractionListener extends ListenerAdapter
|
public class ButtonInteractionListener extends ListenerAdapter
|
||||||
@ -14,7 +15,10 @@ public class ButtonInteractionListener extends ListenerAdapter
|
|||||||
switch (event.getComponentId().toLowerCase()) {
|
switch (event.getComponentId().toLowerCase()) {
|
||||||
|
|
||||||
// coinflip
|
// coinflip
|
||||||
case "reflip" -> new CoinFlipCommand().buttonReflip(event);
|
case "coinflip_reflip" -> new CoinFlipCommand().buttonReFlip(event);
|
||||||
|
|
||||||
|
// clearchat command
|
||||||
|
case "clear_delete" -> new ClearChatCommand().deleteButton(event);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user