Merge branch 'master' into develop
This commit is contained in:
commit
e906b70670
66
src/main/java/net/Broken/Commands/ChannelsReview.java
Normal file
66
src/main/java/net/Broken/Commands/ChannelsReview.java
Normal file
@ -0,0 +1,66 @@
|
||||
package net.Broken.Commands;
|
||||
|
||||
import net.Broken.Commande;
|
||||
import net.Broken.Tools.EmbedMessageUtils;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.MessageHistory;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class ChannelsReview implements Commande {
|
||||
Logger logger = LogManager.getLogger();
|
||||
@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()){
|
||||
String lastMessageId = textChannel.getLatestMessageId();
|
||||
logger.debug("Last message in chanel " + textChannel.toString() + " is " + lastMessageId );
|
||||
try {
|
||||
Message lastMessage = textChannel.retrieveMessageById(lastMessageId).complete();
|
||||
String date = lastMessage.getTimeCreated().toLocalDate().format(formatter);
|
||||
messageToSend.append("\nChannel : ").append(textChannel.getName()).append(" Date :").append(date);
|
||||
}catch (RuntimeException e){
|
||||
logger.warn("Can't find message with id: " + lastMessageId);
|
||||
messageToSend.append("\nChannel : ERROR");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
@ -112,11 +112,11 @@ public class Init {
|
||||
List<UserEntity> users = (List<UserEntity>) userRepository.findAll();
|
||||
UserStatsUtils userStatsUtils = UserStatsUtils.getINSTANCE();
|
||||
logger.debug("Stats...");
|
||||
for (UserEntity userEntity : users) {
|
||||
logger.debug("..." + userEntity.getName());
|
||||
userStatsUtils.getUserStats(userEntity);
|
||||
|
||||
}
|
||||
// for (UserEntity userEntity : users) {
|
||||
// logger.debug("..." + userEntity.getName());
|
||||
// userStatsUtils.getUserStats(userEntity);
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
@ -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