Kord Extensions

KE

Kord Extensions

The official server for Kord Extensions (KordEx), the premier Kotlin Discord bot framework.

Join

How send message to user by id?

I need send message to user/channel by it id How i can do it? I try get guild and when get channel id, but i don`t see methods to get guild/user by id...
Solution:
kordRef on that object

It's that time again

It's that time where I need to make another discord bot, where can I look to get started with voice?

Get guild id from channel/event

I using ButtonInteractionCreateEvent and i need check guild id similar, event object don`t have param for guild id. How i can get it from channel?
Solution:
you'd have to cast it to a guild channel type using to of or ofOrNull functions

Why event called twice when i send message?

I linked without send message, called once
Solution:
You get that event both when the thread is created and when the bot is added to the thread https://discord.com/developers/docs/events/gateway-events#thread-create
No description

Channel change perms

Which method is responsible for issuing access to the channel? I need that when creating a thread (on a forum), only the owner and the administration can write there.
Solution:
You can use channel.edit to modify the permission overrides

How send modal respond when modal window sended?

I need send text when user send modal window
Solution:
result.createEphemeralFollowup { content = "Заявка успешно отправлена." }?...

Error with rewrite server logic

Again... When i start discord bot it overwrite minecraft logic :hvh:...
Solution:
I ran the bot in a separate thread and it worked :hvh:
No description

I18n is from default?

It take a key from i18n, but i have only ru ppl
Solution:
you can get one from a string using .toKey() if you really need to
No description

What event was called when bot started?

I can`t found it(
Solution:
then listen for the ButtonInteractionCreateEvent

How i can start kordex on 21 jdk?

I need add a discord bot to my Minecraft plugin for version 1.21.1. Minecraft plugin need 21 jdk, but kordex 13...
Solution:
heyo, you can solve that as explained in the FAQ here: https://discord.com/channels/1121419906995458098/1121523729734840350/1302560008671858709 basically just add the jvmTarget property to the kordEx builder ```kotlin...

Can I load a .env file for a module instead of the whole project?

There are some utils for loading .env files, can this support the above? Or do I need to use my own solution here....
Solution:
I see what you mean, I'll change the working directory in the IDEA run configuration

Production instance's caching behaving very differently

So this one is a very odd one for me. I have different parts of my code where caching works fine on my test bot (5 servers) vs my production bot (16k servers). One example is this command where I'm using guild.getMemberOrNull to display a list of users (IDs coming from my DB) into strings with their usernames. The problem is that it takes a long time to resolve the response. I would understand if it took long to resolve once, and then subsequent calls didn't, because they are supposed to be cached (EntitySupplyStrategy.cacheWithCachingRestFallback), but every time, it takes a long time. We have tried to switching strategies for this particular command, like using cache only, and it would result in a lot of users just not being found. Now, recently, I added some channel permission checks to some task I have. And I noticed that since then, the task is taking a long time to complete. Upon checking my logs, I see a bunch of requests to https://discord.com/api/v10/guilds/<guildId>/members/<myBotId>, sometimes even making two calls within the same second (there is another permission check further down the task's execution)...
No description

How long do user commands take to register?

How long do user commands take to register?
Solution:
Well that's message commands

ephemeralStringSelectMenu option values

I'm trying to get the value of a selected option in the ephemeralStringSelectMenu from the components builder in the action. is this possible using conventional means? if not, what should be done instead? for reference, I'm trying to dynamically get something from my database with the value from the string select menu, which does not have static options and is also dynamically made...
Solution:
oh it's selected

how does defaultGuild interact with user apps?

I can't seem to test user commands with defaultGuild being set, is there a workaround for this?

How do monetization stuffs work?

I'm trying to monetize my bot/app how does this work with kordex?

Can you send an ephemeral response from a public slash command?

^
Solution:
```kotlin check { val user = userFor(event)!! val usage = usageService.checkUsage(user.id) event.extraData["usageResponse"] = usage...

My commands aren't updating

I've set the defaultGuild on my bot config, when I restart my bot, the commands aren't updated on my guild so I cannot test them.
Solution:
then don't use defaultGuild

ConcurrentModificationException errors

So today I finally released by bot to production, which was scary because it meant going from 3 servers to 16k servers... so of course I expected errors. This error is popping up on various places on my bot when accessing stuff from Discord. I'm using: defaultStrategy = EntitySupplyStrategy.cacheWithCachingRestFallback....
Solution:
@Galarzaa when https://github.com/kordlib/kord/pull/954 is merged, kord 0.15.0-SNAPSHOT should fix the issue
Message Not Public
Sign In & Join Server To View
Next