amo
amo
Explore posts from servers
KKord
Created by amo on 1/27/2025 in #help
Basic bot isnt... doing anything?
package aster.amo

import aster.amo.App.Companion.LOGGER
import aster.amo.App.Companion.getMessageCountInGuild
import dev.kord.core.Kord
import dev.kord.core.behavior.interaction.response.respond
import dev.kord.core.entity.Application
import dev.kord.core.entity.Guild
import dev.kord.core.entity.Member
import dev.kord.core.entity.channel.TextChannel
import dev.kord.core.event.interaction.GuildChatInputCommandInteractionCreateEvent
import dev.kord.core.on
import dev.kord.gateway.Intent
import dev.kord.gateway.PrivilegedIntent
import dev.kord.rest.builder.interaction.boolean
import dev.kord.rest.builder.interaction.string
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.count
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.filterIsInstance
import kotlinx.coroutines.flow.flatMapConcat
import kotlinx.coroutines.launch
import kotlinx.datetime.Instant
import org.slf4j.LoggerFactory

@OptIn(PrivilegedIntent::class)
suspend fun main(args: Array<String>) {

val kord = Kord("TOKEN_WAS_HERE")
LOGGER.info("Logged in as ${kord.getSelf().username}")
val command = kord.createGlobalChatInputCommand("purge_joins_between", "purges joins between two dates") {
string("start_date", "The start date to purge joins from") {
required = true
}
string("end_date", "The end date to purge joins from") {
required = true
}
boolean("has_messaged", "Whether to remove if the user has messaged in the server") {
required = false
default = false
}
}
LOGGER.info("Registered command: " + command.name)
kord.on<GuildChatInputCommandInteractionCreateEvent> {
val response = interaction.deferPublicResponse()
val command = interaction.command
val startDate = command.strings["start_date"] ?: return@on
val endDate = command.strings["end_date"] ?: return@on
val hasMessaged = command.options["has_messaged"]?.value
val startDateEpoch: Instant = Instant.parse(startDate)
val endDateEpoch: Instant = Instant.parse(endDate)
var kickedCount = 0
this.interaction.guild.asGuild().members.collect {
if (it.joinedAt != null) {
val joinedAt = it.joinedAt ?: return@collect
if (joinedAt in startDateEpoch..endDateEpoch) {
if (hasMessaged == null || hasMessaged == false) {
it.kick()
kickedCount++
} else {
val messages = getMessageCountInGuild(it, this.interaction.guild.asGuild())
if (messages == 0) {
it.kick()
kickedCount++
}
}
}
}
}
response.respond { content = "Kicked $kickedCount members" }
}

kord.login {
intents += Intent.Guilds
intents += Intent.GuildMembers
intents += Intent.GuildMessages
intents += Intent.GuildMessageReactions
}
}
class App {
companion object {
val LOGGER = LoggerFactory.getLogger("App")
@OptIn(PrivilegedIntent::class)


suspend fun getMessageCountInGuild(member: Member, guild: Guild): Int {
val channels = guild.channels.filterIsInstance<TextChannel>()
return channels.flatMapConcat { channel ->
channel.messages.filter { it.author?.id == member.id }
}.count()
}
}
}
package aster.amo

import aster.amo.App.Companion.LOGGER
import aster.amo.App.Companion.getMessageCountInGuild
import dev.kord.core.Kord
import dev.kord.core.behavior.interaction.response.respond
import dev.kord.core.entity.Application
import dev.kord.core.entity.Guild
import dev.kord.core.entity.Member
import dev.kord.core.entity.channel.TextChannel
import dev.kord.core.event.interaction.GuildChatInputCommandInteractionCreateEvent
import dev.kord.core.on
import dev.kord.gateway.Intent
import dev.kord.gateway.PrivilegedIntent
import dev.kord.rest.builder.interaction.boolean
import dev.kord.rest.builder.interaction.string
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.count
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.filterIsInstance
import kotlinx.coroutines.flow.flatMapConcat
import kotlinx.coroutines.launch
import kotlinx.datetime.Instant
import org.slf4j.LoggerFactory

@OptIn(PrivilegedIntent::class)
suspend fun main(args: Array<String>) {

val kord = Kord("TOKEN_WAS_HERE")
LOGGER.info("Logged in as ${kord.getSelf().username}")
val command = kord.createGlobalChatInputCommand("purge_joins_between", "purges joins between two dates") {
string("start_date", "The start date to purge joins from") {
required = true
}
string("end_date", "The end date to purge joins from") {
required = true
}
boolean("has_messaged", "Whether to remove if the user has messaged in the server") {
required = false
default = false
}
}
LOGGER.info("Registered command: " + command.name)
kord.on<GuildChatInputCommandInteractionCreateEvent> {
val response = interaction.deferPublicResponse()
val command = interaction.command
val startDate = command.strings["start_date"] ?: return@on
val endDate = command.strings["end_date"] ?: return@on
val hasMessaged = command.options["has_messaged"]?.value
val startDateEpoch: Instant = Instant.parse(startDate)
val endDateEpoch: Instant = Instant.parse(endDate)
var kickedCount = 0
this.interaction.guild.asGuild().members.collect {
if (it.joinedAt != null) {
val joinedAt = it.joinedAt ?: return@collect
if (joinedAt in startDateEpoch..endDateEpoch) {
if (hasMessaged == null || hasMessaged == false) {
it.kick()
kickedCount++
} else {
val messages = getMessageCountInGuild(it, this.interaction.guild.asGuild())
if (messages == 0) {
it.kick()
kickedCount++
}
}
}
}
}
response.respond { content = "Kicked $kickedCount members" }
}

kord.login {
intents += Intent.Guilds
intents += Intent.GuildMembers
intents += Intent.GuildMessages
intents += Intent.GuildMessageReactions
}
}
class App {
companion object {
val LOGGER = LoggerFactory.getLogger("App")
@OptIn(PrivilegedIntent::class)


suspend fun getMessageCountInGuild(member: Member, guild: Guild): Int {
val channels = guild.channels.filterIsInstance<TextChannel>()
return channels.flatMapConcat { channel ->
channel.messages.filter { it.author?.id == member.id }
}.count()
}
}
}
got this really really basic command, but nothing runs - no logging, nothing, it comes online tho lol
2 replies
CDCloudflare Developers
Created by amo on 10/13/2024 in #general-help
CNAME Cross-User Banned on new site
I just migrated my nameserver over from GoDaddy to Cloudflare, also migrating over all of my dns records, all but one work, and that one is the one for my Notion, which gives me CNAME Cross-User Banned, and zero reason as to why
3 replies