Hey I have created an auto close thing for discord and I wanted to make a quick transcript function but its really confusing the syntax for the messageHistory, all on stack dont work so if anyone could assist me on getting the last 50 messages and dming them to a user that would be great. Another question would be how to loop through users that have permission to said channel and check who doesnt have support role then use that to dm.
for (long id : categoryIdLong){
Category category = guild.getCategoryById(id);
List<TextChannel> textChannels = category.getTextChannels();
for (TextChannel type : textChannels){
type.getHistory().retrievePast(1).queue(messages->{
if(!messages.isEmpty()){
Message msg=messages.get(0);
if (Duration.between(msg.getTimeCreated(),OffsetDateTime.now()).toDays() > 3){
String name = type.getName();
log.sendMessage("We have Closed **" + name + "** ticket").queue();
//transcript(type,guild);
type.delete().queue();
}
}
});
}
}
}, 1, 3,TimeUnit.DAYS);
log.sendMessage("Operation Complete ");
}
void transcript(TextChannel text, Guild guild){
List <String> transcript = new ArrayList<>();
text.getHistory().retrievePast(50).queue(messages -> {
for (Message a : messages){
transcript.add(a.toString());
}
});