2022-11-20 18:56:57 +01:00
|
|
|
package wtf.beatrice.hidekobot.commands.slash;
|
2022-11-20 16:07:04 +01:00
|
|
|
|
2022-11-21 16:11:16 +01:00
|
|
|
import net.dv8tion.jda.api.entities.Message;
|
2022-11-22 21:42:35 +01:00
|
|
|
import net.dv8tion.jda.api.entities.MessageEmbed;
|
2022-11-20 16:20:50 +01:00
|
|
|
import net.dv8tion.jda.api.entities.channel.ChannelType;
|
2022-11-20 16:07:04 +01:00
|
|
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
2022-11-22 16:39:31 +01:00
|
|
|
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
|
|
|
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
2022-11-21 16:11:16 +01:00
|
|
|
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
|
|
|
import net.dv8tion.jda.api.requests.restaction.WebhookMessageEditAction;
|
2022-11-20 16:20:50 +01:00
|
|
|
import net.dv8tion.jda.api.requests.restaction.interactions.ReplyCallbackAction;
|
2022-11-20 16:07:04 +01:00
|
|
|
import org.jetbrains.annotations.NotNull;
|
2022-11-22 21:42:35 +01:00
|
|
|
import wtf.beatrice.hidekobot.commands.base.Invite;
|
2022-11-22 16:41:08 +01:00
|
|
|
import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
2022-11-20 16:07:04 +01:00
|
|
|
|
2022-11-22 16:39:31 +01:00
|
|
|
public class InviteCommand extends SlashCommandImpl
|
2022-11-20 16:07:04 +01:00
|
|
|
{
|
2022-11-22 14:32:22 +01:00
|
|
|
|
|
|
|
@Override
|
2022-11-22 16:39:31 +01:00
|
|
|
public CommandData getSlashCommandData()
|
|
|
|
{
|
|
|
|
return Commands.slash("invite", "Get an invite link for the bot.");
|
2022-11-22 14:32:22 +01:00
|
|
|
}
|
|
|
|
|
2022-11-22 16:39:31 +01:00
|
|
|
|
2022-11-22 14:32:22 +01:00
|
|
|
@Override
|
2022-11-20 22:09:58 +01:00
|
|
|
public void runSlashCommand(@NotNull SlashCommandInteractionEvent event)
|
2022-11-20 16:07:04 +01:00
|
|
|
{
|
2022-11-21 16:11:16 +01:00
|
|
|
// defer reply because this might take a moment
|
|
|
|
ReplyCallbackAction replyCallbackAction = event.deferReply();
|
2022-11-22 21:42:35 +01:00
|
|
|
|
2022-11-20 16:20:50 +01:00
|
|
|
// only make message permanent in DMs
|
2022-11-21 16:11:16 +01:00
|
|
|
if(event.getChannelType() != ChannelType.PRIVATE)
|
2022-11-20 16:20:50 +01:00
|
|
|
{
|
2022-11-21 16:11:16 +01:00
|
|
|
replyCallbackAction = replyCallbackAction.setEphemeral(true);
|
2022-11-20 16:20:50 +01:00
|
|
|
}
|
2022-11-21 16:11:16 +01:00
|
|
|
replyCallbackAction.queue();
|
|
|
|
|
2022-11-22 21:42:35 +01:00
|
|
|
MessageEmbed inviteEmbed = Invite.generateEmbed();
|
|
|
|
Button inviteButton = Invite.getInviteButton();
|
2022-11-21 16:11:16 +01:00
|
|
|
|
|
|
|
WebhookMessageEditAction<Message> reply =
|
|
|
|
event.getHook()
|
2022-11-22 21:42:35 +01:00
|
|
|
.editOriginalEmbeds(inviteEmbed)
|
|
|
|
.setActionRow(inviteButton);
|
2022-11-20 16:20:50 +01:00
|
|
|
|
|
|
|
reply.queue();
|
2022-11-20 16:07:04 +01:00
|
|
|
}
|
|
|
|
}
|