Package me.jakejmattson.discordkt.api.extensions

Extension functions to aid in bot development.

Functions

addField
Link copied to clipboard
fun EmbedBuilder.addField(name: String, value: String)
Utility function to create a field.
addInlineField
Link copied to clipboard
fun EmbedBuilder.addInlineField(name: String, value: String)
Utility function to create an inline field.
button
Link copied to clipboard
fun ActionRowBuilder.button(label: String?, emoji: DiscordEmoji?, style: ButtonStyle = ButtonStyle.Secondary, disabled: Boolean = false, action: ButtonBuilder.InteractionButtonBuilder.() -> Unit)
Create an interaction button with a UUID.
containsInvite
Link copied to clipboard
fun Message.containsInvite(): Boolean
Checks whether or not this message's raw content contains an invite.
fun String.containsInvite(): Boolean
Whether or not this string matches the invite regex.
containsURL
Link copied to clipboard
fun String.containsURl(): Boolean
Whether ot not this string matches a URL regex.
createMenu
Link copied to clipboard
suspend fun MessageChannelBehavior.createMenu(construct: suspend MenuBuilder.() -> Unit): Message?
Create a new menu in a message channel.
createTextChannel
Link copied to clipboard
suspend fun Category.createTextChannel(name: String, builder: TextChannelCreateBuilder.() -> Unit = {}): TextChannel
Create a new text channel under this category.
createVoiceChannel
Link copied to clipboard
suspend fun Category.createVoiceChannel(name: String, builder: VoiceChannelCreateBuilder.() -> Unit = {}): VoiceChannel
Create a new voice channel under this category.
disconnect
Link copied to clipboard
suspend fun VoiceState.disconnect(): Member
Disconnect this member from their voice channel.
intentsOf
Link copied to clipboard
inline fun <T : Event> intentsOf(): Intents
Convert an Event to its Intents.
isBooleanValue
Link copied to clipboard
fun String.isBooleanValue(): Boolean
Whether or not this string is a valid boolean value (true/false/t/f).
isImagePost
Link copied to clipboard
fun Message.isImagePost(): Boolean
Checks whether or not this message has an attached image and has no text.
isSelf
Link copied to clipboard
fun MemberBehavior.isSelf(): Boolean
Checks whether this member is the bot.
fun UserBehavior.isSelf(): Boolean
Checks whether this user is the bot.
jumpLink
Link copied to clipboard
suspend fun Message.jumpLink(): String?
Determine the Discord URL for this message (or null if in a DM).
mentionsSomeone
Link copied to clipboard
suspend fun Message.mentionsSomeone(): Boolean
Checks whether or not this message's raw content mentions a user or role.
move
Link copied to clipboard
suspend fun VoiceState.move(channel: VoiceChannel): Member
Move this member to a new voice channel.
pluralize
Link copied to clipboard
fun Number.pluralize(unit: String): String
Create a string with a number and its respective singular/plural unit string.
plus
Link copied to clipboard
operator fun Intent.plus(intent: Intent): Intents
Combine two Intent into a set.
sanitiseMentions
Link copied to clipboard
suspend fun String.sanitiseMentions(discord: Discord): String
Sanitize all mentions and replace them with their resolved discord names.
sendPrivateMessage
Link copied to clipboard
suspend fun UserBehavior.sendPrivateMessage(message: String): Message
Send the user a private string message.
suspend fun UserBehavior.sendPrivateMessage(embed: suspend EmbedBuilder.() -> Unit): Message
Send the user a private embed message.
toPartialEmoji
Link copied to clipboard
fun ReactionEmoji.toPartialEmoji(): DiscordPartialEmoji
Convert a ReactionEmoji to a DiscordPartialEmoji.
fun DiscordEmoji.toPartialEmoji(): DiscordPartialEmoji
Convert a DiscordEmoji to a DiscordPartialEmoji.
toSnowflake
Link copied to clipboard
fun Long.toSnowflake(): Snowflake
Convert a Long ID to a Snowflake.
fun String.toSnowflake(): Snowflake
Convert a String ID or mention to a Snowflake.
toSnowflakeOrNull
Link copied to clipboard
fun String.toSnowflakeOrNull(): Snowflake?
Convert an ID or mention to a Snowflake.
toTimeString
Link copied to clipboard
fun Long.toTimeString(trimLeadingZeroes: Boolean = true, trimTrailingZeros: Boolean = true): String
Convert this long value to a time string
trimToID
Link copied to clipboard
fun String.trimToID(): String
Trim any type of mention into an ID.

Properties

mutualGuilds
Link copied to clipboard
val UserBehavior.mutualGuilds: Flow<Guild>
Get guilds shared between the user and the bot.
profileLink
Link copied to clipboard
val UserBehavior.profileLink: String
A Discord profile link for this user.