#Transcripts

3 messages · Page 1 of 1 (latest)

nimble escarp
#

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());
            }

        });
edgy pelicanBOT
#

This post has been reserved for your question.

Hey @nimble escarp! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.