ls-discord-bot icon indicating copy to clipboard operation
ls-discord-bot copied to clipboard

Implement searching threads by creator.

Open ShreyasAyyengar opened this issue 1 year ago • 8 comments

Explain your idea.

Discord does not natively support searching forum channels for a post created by a specific user. The discord bot can facilitate doing so because the JDA provides this functionality:

ForumChannel channel = {...} // get the #help channel.
String creatorId = {...} // requested discord user who created a help thread post.
List<ThreadChannel> foundThreads = new ArrayList<>();

for (ThreadChannel threadChannel : channel.getThreadChannels()) {
    if (threadChannel.getOwnerId().equalsIgnoreCase(creatorId)) {
        foundThreads.add(threadChannel);
    }
}

I realise the Discord bot is written in Kotlin, but I wanted to help anyone who wishes to PR this in finding the proper JDA methods.

Anything else?

No response

ShreyasAyyengar avatar Aug 26 '24 06:08 ShreyasAyyengar

i mean whats the point

granpacho avatar Sep 04 '24 16:09 granpacho

anyways this is the code in kotlin

val helpChannel: ForumChannel = guild.getChannelById(1234)
val creatorID = userId
val threads: MutableList<ThreadChannel> = mutableListOf()

for (thread in helpChannel.threadChannels) {
	if (thread.ownerId.equals(creatorID)) {
		threads.add(thread)
	}
}

granpacho avatar Sep 04 '24 16:09 granpacho

support searching forum channels for a post created by a specific user.

"support searching forum channels for a post created by a specific user."

ShreyasAyyengar avatar Sep 04 '24 16:09 ShreyasAyyengar

i mean i guess i could make a pr later I'm bored anyways

granpacho avatar Sep 04 '24 16:09 granpacho

so how should we make this work, like have three per page and have a button that changes pages or just the top 5 recent

granpacho avatar Sep 04 '24 17:09 granpacho

so how should we make this work, like have three per page and have a button that changes pages or just the top 5 recent

I personally think that having it three per page with a button to change pages would be a nicer addition. You're the one PRing it though, so up to you

Tofpu avatar Sep 04 '24 19:09 Tofpu

anyways this is the code in kotlin

val helpChannel: ForumChannel = guild.getChannelById(1234)
val creatorID = userId
val threads: MutableList<ThreadChannel> = mutableListOf()

for (thread in helpChannel.threadChannels) {
	if (thread.ownerId.equals(creatorID)) {
		threads.add(thread)
	}
}

Here's the code in Kotlin but easier and uses our existing utils:

Server.helpChannel.threadChannels.filter { it.ownerId == userId }

I also think 5 per page, in line with the /reputation command would be nice and consistent.

MLGPenguin avatar Sep 05 '24 01:09 MLGPenguin

Here's the code in Kotlin but easier and uses our existing utils:

Yeah I didn't look at any of the codebase I was just changing their code into kotlin, but that'll help actually I don't need to create a new postregistry method then

granpacho avatar Sep 05 '24 04:09 granpacho