diff --git a/src/main/java/net/Broken/Commands/Flush.java b/src/main/java/net/Broken/Commands/Flush.java deleted file mode 100644 index a2b87e8..0000000 --- a/src/main/java/net/Broken/Commands/Flush.java +++ /dev/null @@ -1,65 +0,0 @@ -package net.Broken.Commands; - -import net.Broken.Commande; -import net.Broken.Tools.EmbedMessageUtils; -import net.dv8tion.jda.api.Permission; -import net.dv8tion.jda.api.entities.MessageChannel; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -/** - * Command to flush X last message on channel. - */ - -public class Flush implements Commande { - Logger logger = LogManager.getLogger(); - - @Override - public void action(String[] args, MessageReceivedEvent event) { - if (args.length < 1) { - event.getTextChannel().sendMessage(EmbedMessageUtils.getFlushError("Missing argument!")).queue(); - - } else { - if (event.getMember().hasPermission(Permission.ADMINISTRATOR)) { - try { - int limit = Integer.parseInt(args[0]) + 1; - MessageChannel chanel = event.getChannel(); - - chanel.getIterableHistory().takeAsync(limit).thenAccept(chanel::purgeMessages); - - - } catch (NumberFormatException e) { - event.getTextChannel().sendMessage(EmbedMessageUtils.getFlushError("Argument unknown!")).queue(); - } - } else { - event.getTextChannel().sendMessage(EmbedMessageUtils.getFlushError("You are not a supreme being, you cannot do that !")).queue(); - } - } - } - - @Override - public boolean isPrivateUsable() { - return false; - } - - @Override - public boolean isAdminCmd() { - return false; - } - - /** - * Determines if the command is usable only by bot level admin user - * - * @return boolean - */ - @Override - public boolean isBotAdminCmd() { - return false; - } - - @Override - public boolean isNSFW() { - return false; - } -} diff --git a/src/main/java/net/Broken/Commands/Invite.java b/src/main/java/net/Broken/Commands/Invite.java deleted file mode 100644 index 1527de3..0000000 --- a/src/main/java/net/Broken/Commands/Invite.java +++ /dev/null @@ -1,41 +0,0 @@ -package net.Broken.Commands; - -import net.Broken.Commande; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; -import org.apache.logging.log4j.LogManager; - -public class Invite implements Commande { - @Override - public void action(String[] args, MessageReceivedEvent event) { -// if (event.getChannelType().isGuild()) { -// event.getTextChannel().sendMessage("You can invite me whit this link:\nhttps://discordapp.com/oauth2/authorize?client_id=" + event.getJDA().getSelfUser().getId() + "&scope=bot&permissions=8").complete(); -// } else { -// PrivateMessage.send(event.getAuthor(), "You can invite me whit this link:\nhttps://discordapp.com/oauth2/authorize?client_id=" + event.getJDA().getSelfUser().getId() + "&scope=bot&permissions=8", LogManager.getLogger()); -// } - } - - @Override - public boolean isPrivateUsable() { - return true; - } - - @Override - public boolean isAdminCmd() { - return false; - } - - /** - * Determines if the command is usable only by bot level admin user - * - * @return boolean - */ - @Override - public boolean isBotAdminCmd() { - return false; - } - - @Override - public boolean isNSFW() { - return false; - } -} diff --git a/src/main/java/net/Broken/SlashCommands/Invite.java b/src/main/java/net/Broken/SlashCommands/Invite.java new file mode 100644 index 0000000..c086855 --- /dev/null +++ b/src/main/java/net/Broken/SlashCommands/Invite.java @@ -0,0 +1,41 @@ +package net.Broken.SlashCommands; + +import net.Broken.SlashCommand; +import net.dv8tion.jda.api.Permission; +import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; +import net.dv8tion.jda.api.interactions.commands.build.OptionData; +import net.dv8tion.jda.api.interactions.commands.build.SubcommandData; + +import java.util.List; + +public class Invite implements SlashCommand { + @Override + public void action(SlashCommandEvent event) { + event.reply(event.getJDA().setRequiredScopes("bot", "applications.commands").getInviteUrl(Permission.ADMINISTRATOR)).setEphemeral(true).queue(); + } + + @Override + public String getDescription() { + return "Get the link to invite this bot to your server"; + } + + @Override + public List getOptions() { + return null; + } + + @Override + public List getSubcommands() { + return null; + } + + @Override + public boolean isBotAdminCmd() { + return false; + } + + @Override + public boolean isNSFW() { + return false; + } +} diff --git a/src/main/java/net/Broken/SlashCommands/Music.java b/src/main/java/net/Broken/SlashCommands/Music.java index c7df7fb..63f4638 100644 --- a/src/main/java/net/Broken/SlashCommands/Music.java +++ b/src/main/java/net/Broken/SlashCommands/Music.java @@ -44,7 +44,7 @@ public class Music implements SlashCommand { } } else { Message message = new MessageBuilder().setEmbeds(EmbedMessageUtils.getMusicError("You are not in a voice channel !")).build(); - event.getHook().sendMessage(message).queue(); + event.getHook().setEphemeral(true).sendMessage(message).queue(); } break; case "add": diff --git a/src/main/java/net/Broken/audio/AudioM.java b/src/main/java/net/Broken/audio/AudioM.java index d61faaf..3d922d9 100644 --- a/src/main/java/net/Broken/audio/AudioM.java +++ b/src/main/java/net/Broken/audio/AudioM.java @@ -104,7 +104,7 @@ public class AudioM { public void noMatches() { logger.warn("[" + guild + "] Cant find media!"); Message message = new MessageBuilder().setEmbeds(EmbedMessageUtils.getMusicError("Video not found !")).build(); - event.getHook().sendMessage(message).queue(); + event.getHook().setEphemeral(true).sendMessage(message).queue(); } @Override @@ -112,7 +112,7 @@ public class AudioM { logger.error("[" + guild + "] Can't load media!"); logger.error(exception.getMessage()); Message message = new MessageBuilder().setEmbeds(EmbedMessageUtils.getMusicError("Playback error !")).build(); - event.getHook().sendMessage(message).queue(); + event.getHook().setEphemeral(true).sendMessage(message).queue(); } }); } @@ -293,7 +293,7 @@ public class AudioM { loadAndPlay(event, playedChanel, url, playListLimit, onHead); } else { Message message = new MessageBuilder().setEmbeds(EmbedMessageUtils.getMusicError("Not connected to vocal chanel !")).build(); - event.getHook().sendMessage(message).queue(); + event.getHook().setEphemeral(true).sendMessage(message).queue(); } }