Kord 0.14.0 Help

Listening for Messages

suspend fun main(args: Array<String>) { val token = args.firstOrNull() ?: error("token required") val gateway = DefaultGateway() gateway.events.filterIsInstance<MessageCreate>().onEach { val words = it.message.content.split(' ') when (words.firstOrNull()) { "!close" -> gateway.stop() "!detach" -> gateway.detach() "!status" -> when (words.getOrNull(1)) { "playing" -> gateway.editPresence { status = PresenceStatus.Online afk = false playing("Kord") } } } }.launchIn(gateway) gateway.start(token) { @OptIn(PrivilegedIntent::class) intents += Intent.MessageContent } }
Last modified: 08 April 2023