Added new command for channels review

This commit is contained in:
Alexandre64 2020-12-01 23:28:44 +01:00
parent 4bafcb33f4
commit 2d8cc5d6d5
4 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,50 @@
package net.Broken.Commands;
import net.Broken.Commande;
import net.Broken.Tools.EmbedMessageUtils;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import java.time.format.DateTimeFormatter;
public class ChannelsReview implements Commande {
@Override
public void action(String[] args, MessageReceivedEvent event) {
StringBuilder messageToSend= new StringBuilder();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd LLLL yyyy");
for( TextChannel textChannel: event.getGuild().getTextChannels()){
if(textChannel.hasLatestMessage()){
messageToSend.append("\nChannel : ").append(textChannel.getName()).append(" Date :").append((textChannel.retrieveMessageById(textChannel.getLatestMessageId()).complete().getTimeCreated()).toLocalDate().format(formatter));
}
else{
messageToSend.append("\nChannel : ").append(textChannel.getName()).append(" was never used.");
}
}
event.getTextChannel().sendMessage(EmbedMessageUtils.getLastMessageFromTextChannel(messageToSend.toString())).queue();
}
@Override
public boolean isPrivateUsable() {
return false;
}
@Override
public boolean isAdminCmd() {
return true;
}
/**
* 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;
}
}

View File

@ -108,6 +108,11 @@ public class EmbedMessageUtils {
return new EmbedBuilder().setTitle("Bot Command ("+role+")").setDescription(message).setFooter("Use '//help <command>' for more info",MainBot.jda.getSelfUser().getAvatarUrl()).setTimestamp(Instant.now()).setColor(Color.green).setThumbnail(MainBot.jda.getSelfUser().getAvatarUrl()).build(); return new EmbedBuilder().setTitle("Bot Command ("+role+")").setDescription(message).setFooter("Use '//help <command>' for more info",MainBot.jda.getSelfUser().getAvatarUrl()).setTimestamp(Instant.now()).setColor(Color.green).setThumbnail(MainBot.jda.getSelfUser().getAvatarUrl()).build();
} }
public static MessageEmbed getLastMessageFromTextChannel(String message) {
EmbedBuilder temp = new EmbedBuilder().setTitle("Channel uses checker").setDescription(message).setColor(Color.green);
return buildStandar(temp);
}
public static MessageEmbed searchResult(SearchResult result){ public static MessageEmbed searchResult(SearchResult result){
EmbedBuilder builder = new EmbedBuilder() EmbedBuilder builder = new EmbedBuilder()
.setColor(Color.CYAN) .setColor(Color.CYAN)

View File

@ -0,0 +1,2 @@
This command allow you to see which text channel is used by
returning the date from the last message sent in every text channel.

View File

@ -0,0 +1,3 @@
Cette commande permet de verifier quels channels textes ne sont
pas utilisés en remontant la date du dernier message envoyé
dans tout les channels.