Added new command for channels review
This commit is contained in:
parent
4bafcb33f4
commit
2d8cc5d6d5
50
src/main/java/net/Broken/Commands/ChannelsReview.java
Normal file
50
src/main/java/net/Broken/Commands/ChannelsReview.java
Normal 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;
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
|
||||
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){
|
||||
EmbedBuilder builder = new EmbedBuilder()
|
||||
.setColor(Color.CYAN)
|
||||
|
2
src/main/resources/Help/ChannelsReview/en/main.md
Normal file
2
src/main/resources/Help/ChannelsReview/en/main.md
Normal 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.
|
3
src/main/resources/Help/ChannelsReview/fr/main.md
Normal file
3
src/main/resources/Help/ChannelsReview/fr/main.md
Normal 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.
|
Loading…
Reference in New Issue
Block a user