Compare commits

..

No commits in common. "589997c29ef99f5f6efb48d8fba4b27ce53ef402" and "3a9795794c9b05b87b6a787b3fe801c05d5e6dc8" have entirely different histories.

20 changed files with 596 additions and 606 deletions

2
.gitignore vendored
View file

@ -1,7 +1,5 @@
### CUSTOM ###
/run/
/data/
data/
/.idea/

View file

@ -4,6 +4,10 @@
A Discord music bot, written in Kotlin using the kord library.
[![Latest Release](https://gitlab.com/moonleay/botendo/-/badges/release.svg)](https://gitlab.com/moonleay/botendo/-/releases)
[![pipeline status](https://gitlab.com/moonleay/botendo/badges/master/pipeline.svg)](https://gitlab.com/moonleay/botendo/-/commits/master)
[![License](https://img.shields.io/badge/license-GPL--3.0-brightgreen)](https://gitlab.com/moonleay/botendo/-/blob/master/LICENSE)
## Contributors
[![Developer](https://img.shields.io/badge/moonleay-Developer-red)](https://gitlab.com/moonleay)
@ -12,9 +16,9 @@ A Discord music bot, written in Kotlin using the kord library.
- HopeBaron for helping me a lot
## Issues
## Known issues
- Report issues to issues@moonleay.net or message @moonleay on Discord
- None (currently). Open an issue, report issues to issues@moonleay.net or message moonleay#0001 on Discord
## Commands & Features
@ -59,3 +63,9 @@ A Discord music bot, written in Kotlin using the kord library.
Install IntellJ and import the project from git.
Done.
## Docker commands 4 me
- docker run -it -m 2g -v/home/limited_dev/Documents/Code/Botendo/run/data/:/data/:rw limiteddev/botendo:x.x.x
- docker build -t limiteddev/botendo:x.x.x .
- docker push limiteddev/botendo:x.x.x

View file

@ -35,7 +35,7 @@ version = System.getenv("CI_COMMIT_TAG")?.let { "$it-${System.getenv("CI_COMMIT_
?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" }
?: "6.5.1"
val kordver = "1.7.1-SNAPSHOT"
val kordver = "1.5.6"
val lavaver = "4.0.0"
val coroutinesver = "1.1.0"
@ -70,14 +70,6 @@ repositories {
}
}
}
maven {
name = "sonatype"
url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots")
}
maven {
name = "sonatype 2"
url = uri("https://oss.sonatype.org/content/repositories/snapshots")
}
}
val shadow by configurations.getting

View file

@ -24,7 +24,6 @@ import dev.kord.common.Color
import dev.kord.core.behavior.interaction.response.respond
import dev.kord.core.event.interaction.ButtonInteractionCreateEvent
import dev.kord.core.on
import dev.kord.rest.builder.message.embed
import dev.schlaubi.lavakord.LavaKord
import dev.schlaubi.lavakord.kord.lavakord
import net.moonleay.botendo.data.CredentialManager
@ -92,14 +91,14 @@ object Bot {
return@on
}
response.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "Error"
this.description = "Could not find button with id \"${inter.componentId}\".\nPlease report this."
this.footer {
this.text = MessageUtil.getFooter(u)
}
}
this.embeds = mutableListOf(
MessageUtil.getEmbed(
Color(0xE0311A),
"Error",
"Could not find button with id \"${inter.componentId}\".\nPlease report this.",
UserUtil.getCommandSrc(u)
)
)
}
}

View file

@ -24,9 +24,6 @@ import dev.kord.core.behavior.interaction.response.DeferredPublicMessageInteract
import dev.kord.core.behavior.interaction.response.respond
import dev.kord.core.entity.Guild
import dev.kord.core.entity.User
import dev.kord.rest.builder.component.ActionRowBuilder
import dev.kord.rest.builder.message.actionRow
import dev.kord.rest.builder.message.embed
import dev.kord.rest.builder.message.modify.actionRow
import dev.schlaubi.lavakord.audio.Link
import net.moonleay.botendo.extensions.music.components.MusicManager
@ -46,14 +43,14 @@ class PauseButton : net.moonleay.botendo.buttons.Button("btn.music.pause") {
val voiceState = user.asMember(guildId).getVoiceStateOrNull()
if (voiceState == null) {
response.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "You are not connected to a VC"
this.description = "Please connect to a VC"
this.footer {
this.text = MessageUtil.getFooter(user)
}
}
this.embeds = mutableListOf(
MessageUtil.getEmbed(
Color(0xE0311A),
"You are not connected to a VC",
"Please connect to a VC",
UserUtil.getCommandSrc(user)
)
)
}
return
}
@ -61,26 +58,26 @@ class PauseButton : net.moonleay.botendo.buttons.Button("btn.music.pause") {
val channelId = voiceState.channelId
if (link.state == Link.State.NOT_CONNECTED) {
response.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "Not connected"
this.description = "I'm not in a VC and therefore, I am not playing anything."
this.footer {
this.text = MessageUtil.getFooter(user)
}
}
this.embeds = mutableListOf(
MessageUtil.getEmbed(
Color(0xE0311A),
"Not connected",
"I'm not in a VC and therefore, I am not playing anything.",
UserUtil.getCommandSrc(user)
)
)
}
return
} else if (link.state == Link.State.CONNECTED && link.lastChannelId != channelId!!.value) {
response.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "You are not in my VC"
this.description = "We are not in the same VC and therefore, you cannot control the music"
this.footer {
this.text = MessageUtil.getFooter(user)
}
}
this.embeds = mutableListOf(
MessageUtil.getEmbed(
Color(0xE0311A),
"You are not in my VC",
"We are not in the same VC and therefore, you cannot control the music",
UserUtil.getCommandSrc(user)
)
)
}
return
}
@ -89,18 +86,19 @@ class PauseButton : net.moonleay.botendo.buttons.Button("btn.music.pause") {
val gts = MusicManager.getGuildTrackScheduler(guild, player)
response.respond {
this.embed {
this.color = Color(0x52E01A)
this.title = if (player.paused) "I paused" else "I'm continuing"
this.description = if (player.paused) "I paused the song" else "I'm continuing to play the song."
this.footer {
this.text = MessageUtil.getFooter(user)
}
}
this.embeds = mutableListOf(
MessageUtil.getEmbed(
Color(0x52E01A),
if (player.paused) "I paused" else "I'm continuing",
if (player.paused) "I paused the song" else "I'm continuing to play the song.",
UserUtil.getCommandSrc(user)
)
)
this.actionRow(fun ActionRowBuilder.() {
components.addAll(ButtonUtil.getMusicControllerButtons(player.paused, gts.repeating).components)
})
this.actionRow {
this.components.addAll(ButtonUtil.getMusicControllerButtons(player.paused, gts.repeating).components)
}
}
}
}

View file

@ -24,9 +24,6 @@ import dev.kord.core.behavior.interaction.response.DeferredPublicMessageInteract
import dev.kord.core.behavior.interaction.response.respond
import dev.kord.core.entity.Guild
import dev.kord.core.entity.User
import dev.kord.rest.builder.component.ActionRowBuilder
import dev.kord.rest.builder.message.actionRow
import dev.kord.rest.builder.message.embed
import dev.kord.rest.builder.message.modify.actionRow
import dev.schlaubi.lavakord.audio.Link
import net.moonleay.botendo.extensions.music.components.MusicManager
@ -46,14 +43,14 @@ class QueueButton : net.moonleay.botendo.buttons.Button("btn.music.queue") {
val player = link.player
if (link.state == Link.State.NOT_CONNECTED) {
response.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "Not connected"
this.description = "I'm not in a VC and therefore, I am not playing anything."
this.footer {
this.text = MessageUtil.getFooter(user)
}
}
this.embeds = mutableListOf(
MessageUtil.getEmbed(
Color(0xE0311A),
"Not connected",
"I'm not in a VC and therefore, I am not playing anything.",
UserUtil.getCommandSrc(user)
)
)
}
return
}
@ -61,14 +58,14 @@ class QueueButton : net.moonleay.botendo.buttons.Button("btn.music.queue") {
val track = player.playingTrack
if (track == null) {
response.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "Not playing"
this.description = "I'm not playing anything currently"
this.footer {
this.text = MessageUtil.getFooter(user)
}
}
this.embeds = mutableListOf(
MessageUtil.getEmbed(
Color(0xE0311A),
"Not playing",
"I'm not playing anything currently",
UserUtil.getCommandSrc(user)
)
)
}
return
}
@ -82,18 +79,18 @@ class QueueButton : net.moonleay.botendo.buttons.Button("btn.music.queue") {
desc += tr.info.title + " - " + TimeUtil.getTimeFormatedShortend(tr.info.length) + " (" + tr.info.author + ")\n"
}
response.respond {
this.embed {
this.color = Color(0x52E01A)
this.title = "Queue"
this.description = desc
this.footer {
this.text = MessageUtil.getFooter(user)
}
}
this.embeds = mutableListOf(
MessageUtil.getEmbed(
Color(0x52E01A),
"Queue",
desc,
UserUtil.getCommandSrc(user)
)
)
this.actionRow(fun ActionRowBuilder.() {
components.addAll(ButtonUtil.getMusicControllerButtons(player.paused, gts.repeating).components)
})
this.actionRow {
this.components.addAll(ButtonUtil.getMusicControllerButtons(player.paused, gts.repeating).components)
}
}
}
}

View file

@ -24,9 +24,6 @@ import dev.kord.core.behavior.interaction.response.DeferredPublicMessageInteract
import dev.kord.core.behavior.interaction.response.respond
import dev.kord.core.entity.Guild
import dev.kord.core.entity.User
import dev.kord.rest.builder.component.ActionRowBuilder
import dev.kord.rest.builder.message.actionRow
import dev.kord.rest.builder.message.embed
import dev.kord.rest.builder.message.modify.actionRow
import dev.schlaubi.lavakord.audio.Link
import net.moonleay.botendo.extensions.music.components.MusicManager
@ -46,14 +43,14 @@ class RepeatButton : net.moonleay.botendo.buttons.Button("btn.music.repeat") {
val voiceState = user.asMember(guildId).getVoiceStateOrNull()
if (voiceState == null) {
response.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "You are not connected to a VC"
this.description = "Please connect to a VC"
this.footer {
this.text = MessageUtil.getFooter(user)
}
}
this.embeds = mutableListOf(
MessageUtil.getEmbed(
Color(0xE0311A),
"You are not connected to a VC",
"Please connect to a VC",
UserUtil.getCommandSrc(user)
)
)
}
return
}
@ -61,26 +58,26 @@ class RepeatButton : net.moonleay.botendo.buttons.Button("btn.music.repeat") {
val channelId = voiceState.channelId
if (link.state == Link.State.NOT_CONNECTED) {
response.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "Not connected"
this.description = "I'm not in a VC and therefore, I am not playing anything."
this.footer {
this.text = MessageUtil.getFooter(user)
}
}
this.embeds = mutableListOf(
MessageUtil.getEmbed(
Color(0xE0311A),
"Not connected",
"I'm not in a VC and therefore, I am not playing anything.",
UserUtil.getCommandSrc(user)
)
)
}
return
} else if (link.state == Link.State.CONNECTED && link.lastChannelId != channelId!!.value) {
response.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "You are not in my VC"
this.description = "We are not in the same VC and therefore, you cannot control the music"
this.footer {
this.text = MessageUtil.getFooter(user)
}
}
this.embeds = mutableListOf(
MessageUtil.getEmbed(
Color(0xE0311A),
"You are not in my VC",
"We are not in the same VC and therefore, you cannot control the music",
UserUtil.getCommandSrc(user)
)
)
}
return
}
@ -88,19 +85,19 @@ class RepeatButton : net.moonleay.botendo.buttons.Button("btn.music.repeat") {
val gts = MusicManager.getGuildTrackScheduler(guild, player)
gts.repeating = !gts.repeating
response.respond {
this.embed {
this.color = Color(0x52E01A)
this.title = if (gts.repeating) "Now Repeating" else "Now Continuing"
this.description =
if (gts.repeating) "The current track will now loop" else "The next track will play when this song finishes"
this.footer {
this.text = MessageUtil.getFooter(user)
}
}
this.embeds = mutableListOf(
MessageUtil.getEmbed(
Color(0x52E01A),
if (gts.repeating) "Now Repeating" else "Now Continuing",
if (gts.repeating) "The current track will now loop" else "The next track will play when this song finishes",
UserUtil.getCommandSrc(user)
)
)
this.actionRow(fun ActionRowBuilder.() {
components.addAll(ButtonUtil.getMusicControllerButtons(player.paused, gts.repeating).components)
})
this.actionRow {
this.components.addAll(ButtonUtil.getMusicControllerButtons(player.paused, gts.repeating).components)
}
}
}
}

View file

@ -25,9 +25,6 @@ import dev.kord.core.behavior.interaction.response.DeferredPublicMessageInteract
import dev.kord.core.behavior.interaction.response.respond
import dev.kord.core.entity.Guild
import dev.kord.core.entity.User
import dev.kord.rest.builder.component.ActionRowBuilder
import dev.kord.rest.builder.message.actionRow
import dev.kord.rest.builder.message.embed
import dev.kord.rest.builder.message.modify.actionRow
import dev.schlaubi.lavakord.audio.Link
import net.moonleay.botendo.extensions.music.components.MusicManager
@ -45,14 +42,14 @@ class SkipButton : net.moonleay.botendo.buttons.Button("btn.music.skip") {
val voiceState = user.asMember(guildId).getVoiceStateOrNull()
if (voiceState == null) {
response.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "You are not connected to a VC"
this.description = "Please connect to a VC"
this.footer {
this.text = MessageUtil.getFooter(user)
}
}
this.embeds = mutableListOf(
MessageUtil.getEmbed(
Color(0xE0311A),
"You are not connected to a VC",
"Please connect to a VC",
UserUtil.getCommandSrc(user)
)
)
}
return
}
@ -60,40 +57,40 @@ class SkipButton : net.moonleay.botendo.buttons.Button("btn.music.skip") {
val channelId = voiceState.channelId
if (link.state == Link.State.NOT_CONNECTED) {
response.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "Not connected"
this.description = "I'm not in a VC and therefore, I am not playing anything."
this.footer {
this.text = MessageUtil.getFooter(user)
}
}
this.embeds = mutableListOf(
MessageUtil.getEmbed(
Color(0xE0311A),
"Not connected",
"I'm not in a VC and therefore, I am not playing anything.",
UserUtil.getCommandSrc(user)
)
)
}
return
} else if (link.state == Link.State.CONNECTED && link.lastChannelId != channelId!!.value) {
response.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "You are not in my VC"
this.description = "We are not in the same VC and therefore, you cannot control the music"
this.footer {
this.text = MessageUtil.getFooter(user)
}
}
this.embeds = mutableListOf(
MessageUtil.getEmbed(
Color(0xE0311A),
"You are not in my VC",
"We are not in the same VC and therefore, you cannot control the music",
UserUtil.getCommandSrc(user)
)
)
}
return
}
var track = player.playingTrack
if (track == null) {
response.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "Not Playing"
this.description = "I'm not playing anything currently"
this.footer {
this.text = MessageUtil.getFooter(user)
}
}
this.embeds = mutableListOf(
MessageUtil.getEmbed(
Color(0xE0311A),
"Not playing",
"I'm not playing anything currently",
UserUtil.getCommandSrc(user)
)
)
}
return
}
@ -102,22 +99,20 @@ class SkipButton : net.moonleay.botendo.buttons.Button("btn.music.skip") {
track = gts.getHead().toTrack()
gts.playNext(link)
response.respond {
this.embed {
this.color = Color(0x52E01A)
this.title = "Skipped song; now playing"
this.description = "**${track.title}**\n*Now Playing*\nby ${track.author} :: ${
this.embeds = mutableListOf(
MessageUtil.getEmbedWithImage(
Color(0x52E01A),
"Skipped song; now playing",
"**${track.title}**\n*Now Playing*\nby ${track.author} :: ${
TimeUtil.getTimeFormatedRaw(
track.length.inWholeMilliseconds
)
}\n" +
">>>${track.uri}"
this.footer {
this.text = MessageUtil.getFooter(user)
}
this.thumbnail {
this.url = "https://img.youtube.com/vi/" + UrlUtil.getYtThumbnailUrl(track.uri!!) + "/maxresdefault.jpg"
}
}
">>>${track.uri}",
UserUtil.getCommandSrc(user),
"https://img.youtube.com/vi/" + UrlUtil.getYtThumbnailUrl(track.uri!!) + "/maxresdefault.jpg"
)
)
this.actionRow {
this.components.addAll(
@ -133,17 +128,17 @@ class SkipButton : net.moonleay.botendo.buttons.Button("btn.music.skip") {
player.stopTrack()
response.respond {
this.embed {
this.color = Color(0x52E01A)
this.title = "Skipped song"
this.description = "Nothing"
this.footer {
this.text = MessageUtil.getFooter(user)
this.embeds = mutableListOf(
MessageUtil.getEmbed(
Color(0x52E01A),
"Skipped song; now playing",
"Nothing",
UserUtil.getCommandSrc(user)
)
)
this.actionRow {
this.components.addAll(ButtonUtil.getMusicControllerButtons(player.paused, gts.repeating).components)
}
}
this.actionRow(fun ActionRowBuilder.() {
components.addAll(ButtonUtil.getMusicControllerButtons(player.paused, gts.repeating).components)
})
}
}
}

View file

@ -24,7 +24,6 @@ import dev.kord.core.behavior.interaction.response.DeferredPublicMessageInteract
import dev.kord.core.behavior.interaction.response.respond
import dev.kord.core.entity.Guild
import dev.kord.core.entity.User
import dev.kord.rest.builder.message.embed
import dev.schlaubi.lavakord.audio.Link
import net.moonleay.botendo.extensions.music.components.MusicManager
import net.moonleay.botendo.util.MessageUtil
@ -42,14 +41,14 @@ class StopButton : net.moonleay.botendo.buttons.Button("btn.music.stop") {
val voiceState = user.asMember(guildId).getVoiceStateOrNull()
if (voiceState == null) {
response.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "You are not connected to a VC"
this.description = "Please connect to a VC"
this.footer {
this.text = MessageUtil.getFooter(user)
}
}
this.embeds = mutableListOf(
MessageUtil.getEmbed(
Color(0xE0311A),
"You are not connected to a VC",
"Please connect to a VC",
UserUtil.getCommandSrc(user)
)
)
}
return
}
@ -57,26 +56,26 @@ class StopButton : net.moonleay.botendo.buttons.Button("btn.music.stop") {
val channelId = voiceState.channelId
if (link.state == Link.State.NOT_CONNECTED) {
response.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "Not connected"
this.description = "I'm not in a VC and therefore, I am not playing anything."
this.footer {
this.text = MessageUtil.getFooter(user)
}
}
this.embeds = mutableListOf(
MessageUtil.getEmbed(
Color(0xE0311A),
"Not connected",
"I'm not in a VC and therefore, I am not playing anything.",
UserUtil.getCommandSrc(user)
)
)
}
return
} else if (link.state == Link.State.CONNECTED && link.lastChannelId != channelId!!.value) {
response.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "You are not in my VC"
this.description = "We are not in the same VC and therefore, you cannot control the music"
this.footer {
this.text = MessageUtil.getFooter(user)
}
}
this.embeds = mutableListOf(
MessageUtil.getEmbed(
Color(0xE0311A),
"You are not in my VC",
"We are not in the same VC and therefore, you cannot control the music",
UserUtil.getCommandSrc(user)
)
)
}
return
}
@ -85,14 +84,14 @@ class StopButton : net.moonleay.botendo.buttons.Button("btn.music.stop") {
link.destroy()
MusicManager.getGuildTrackScheduler(guild.asGuild(), player).clear()
response.respond {
this.embed {
this.color = Color(0x52E01A)
this.title = "I stopped and left"
this.description = "just like your girlfriend"
this.footer {
this.text = MessageUtil.getFooter(user)
}
}
this.embeds = mutableListOf(
MessageUtil.getEmbed(
Color(0x52E01A),
"I stopped and left",
"just like your girlfriend",
UserUtil.getCommandSrc(user)
)
)
}
}
}

View file

@ -21,11 +21,9 @@ package net.moonleay.botendo.extensions.music
import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
import com.kotlindiscord.kord.extensions.types.respond
import dev.kord.common.Color
import dev.kord.rest.builder.component.ActionRowBuilder
import dev.kord.rest.builder.message.actionRow
import dev.kord.rest.builder.message.create.actionRow
import dev.kord.rest.builder.message.embed
import dev.schlaubi.lavakord.audio.Link
import dev.schlaubi.lavakord.kord.getLink
import net.moonleay.botendo.extensions.music.components.MusicManager
@ -41,41 +39,33 @@ class NowPlayingExtension : Extension() {
val guildId = this.guild!!.id
val link = net.moonleay.botendo.Bot.lava.getLink(guildId)
val player = link.player
val u = this.user
if (link.state == Link.State.NOT_CONNECTED) {
this.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "Not connected"
this.description = "I'm not in a VC and therefore, I am not playing anything."
this.footer {
this.text = MessageUtil.getFooter(u)
}
}
}
MessageUtil.sendEmbedForPublicSlashCommand(
this,
Color(0xE0A81A),
"Not connected",
"I'm not in a VC and therefore, I am not playing anything."
)
return@action
}
val track = player.playingTrack
if (track == null) {
this.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "Not Playing"
this.description = "I'm not playing anything currently"
this.footer {
this.text = MessageUtil.getFooter(u)
}
}
}
MessageUtil.sendEmbedForPublicSlashCommand(
this,
Color(0xE0A81A),
"Not Playing",
"I'm not playing anything currently"
)
return@action
}
val gts = MusicManager.getGuildTrackScheduler(this.guild!!.asGuild(), player)
this.respond {
this.embed {
this.color = Color(0x52E01A)
this.title = "Currently playing"
this.description = "**${track.title}**\n*Now Playing*\nby ${track.author} ; ${
this.embeds.add(
MessageUtil.getEmbedWithImage(
Color(0x52E01A),
"Currently playing",
"**${track.title}**\n*Now Playing*\nby ${track.author} ; ${
TimeUtil.getTimeFormatedRaw(
player.position
)
@ -84,23 +74,20 @@ class NowPlayingExtension : Extension() {
track.length.inWholeMilliseconds
)
}\n" +
">>>${track.uri}"
this.footer {
this.text = MessageUtil.getFooter(u)
}
this.thumbnail {
this.url = "https://img.youtube.com/vi/" + UrlUtil.getYtThumbnailUrl(track.uri.toString()) + "/maxresdefault.jpg"
}
}
">>>${track.uri}",
UserUtil.getCommandSrc(user),
"https://img.youtube.com/vi/" + UrlUtil.getYtThumbnailUrl(track.uri.toString()) + "/maxresdefault.jpg"
)
)
this.actionRow(fun ActionRowBuilder.() {
components.addAll(
this.actionRow {
this.components.addAll(
ButtonUtil.getMusicControllerButtons(
player.paused,
gts.repeating
).components
)
})
}
}
}
}

View file

@ -21,8 +21,8 @@ package net.moonleay.botendo.extensions.music
import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
import com.kotlindiscord.kord.extensions.types.respond
import dev.kord.common.Color
import dev.kord.rest.builder.message.embed
import dev.schlaubi.lavakord.audio.Link
import dev.schlaubi.lavakord.kord.getLink
import net.moonleay.botendo.extensions.music.components.LinkArguments
@ -46,14 +46,14 @@ class PlayExtension : Extension() {
val vcsUser = u.asMember(guildId).getVoiceStateOrNull()
if (vcsUser == null) {
this.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "You are not connected to a VC"
this.description = "Please connect to a VC"
this.footer {
this.text = MessageUtil.getFooter(u)
}
}
embeds.add(
MessageUtil.getEmbed(
Color(0xE0311A),
"You are not connected to a VC",
"Please connect to a VC",
UserUtil.getCommandSrc(u),
)
)
}
return@action
}
@ -64,14 +64,14 @@ class PlayExtension : Extension() {
link.connectAudio(channelId!!.value)
} else if (link.state == Link.State.CONNECTED && link.lastChannelId != channelId!!.value) {
this.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "You are not in my VC"
this.description = "We are not in the same VC and therefore, you cannot play any music"
this.author {
this.name = UserUtil.getCommandSrc(u)
}
}
embeds.add(
MessageUtil.getEmbed(
Color(0xE0311A),
"You are not in my VC",
"We are not in the same VC and therefore, you cannot play any music",
UserUtil.getCommandSrc(u),
)
)
}
return@action
}
@ -83,14 +83,14 @@ class PlayExtension : Extension() {
"ytsearch:$query"
}
this.respond {
this.embed {
this.color = Color(0xE0A81A)
this.title = "Searching..."
this.description = "We are looking for $query"
this.footer {
this.text = MessageUtil.getFooter(u)
}
}
embeds.add(
MessageUtil.getEmbed(
Color(0xE0A81A),
"Searching...",
"We are looking for $query",
UserUtil.getCommandSrc(u),
)
)
}
MusicManager.addToQueue(this, link, search)
}

View file

@ -21,11 +21,9 @@ package net.moonleay.botendo.extensions.music
import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
import com.kotlindiscord.kord.extensions.types.respond
import dev.kord.common.Color
import dev.kord.rest.builder.component.ActionRowBuilder
import dev.kord.rest.builder.message.actionRow
import dev.kord.rest.builder.message.create.actionRow
import dev.kord.rest.builder.message.embed
import dev.schlaubi.lavakord.audio.Link
import net.moonleay.botendo.extensions.music.components.MusicManager
import net.moonleay.botendo.util.ButtonUtil
@ -43,32 +41,23 @@ class QueueExtension : Extension() {
val guildId = this.guild!!.id
val link = net.moonleay.botendo.Bot.lava.getLink(guildId.toString())
val player = link.player
val u = this.user
if (link.state == Link.State.NOT_CONNECTED) {
this.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "Not connected"
this.description = "I'm not in a VC and therefore, I am not playing anything."
this.footer {
this.text = MessageUtil.getFooter(u)
}
}
}
MessageUtil.sendEmbedForPublicSlashCommand(
this,
Color(0xE0311A),
"Not connected",
"I'm not in a VC and therefore, I am not playing anything."
)
return@action
}
val track = player.playingTrack
if (track == null) {
this.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "Queue empty"
this.description = "I'm not playing anything currently"
this.footer {
this.text = MessageUtil.getFooter(u)
}
}
}
MessageUtil.sendEmbedForPublicSlashCommand(
this,
Color(0xE0A81A),
"Queue empty",
"I'm not playing anything currently"
)
return@action
}
val gts = MusicManager.getGuildTrackScheduler(this.guild!!.asGuild(), player)
@ -81,23 +70,23 @@ class QueueExtension : Extension() {
desc += tr.info.title + " - " + TimeUtil.getTimeFormatedShortend(tr.info.length) + " (" + tr.info.author + ")\n"
}
this.respond {
this.embed {
this.color = Color(0x52E01A)
this.title = "Queue"
this.description = desc
this.footer {
this.text = MessageUtil.getFooter(u)
}
}
this.embeds.add(
MessageUtil.getEmbed(
Color(0x52E01A),
"Queue",
desc,
UserUtil.getCommandSrc(user),
)
)
this.actionRow(fun ActionRowBuilder.() {
components.addAll(
this.actionRow {
this.components.addAll(
ButtonUtil.getMusicControllerButtons(
player.paused,
gts.repeating
).components
)
})
}
}
}
}

View file

@ -21,10 +21,9 @@ package net.moonleay.botendo.extensions.music
import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
import com.kotlindiscord.kord.extensions.types.respond
import dev.kord.common.Color
import dev.kord.rest.builder.component.ActionRowBuilder
import dev.kord.rest.builder.message.actionRow
import dev.kord.rest.builder.message.embed
import dev.kord.rest.builder.message.create.actionRow
import dev.schlaubi.lavakord.audio.Link
import net.moonleay.botendo.extensions.music.components.MusicManager
import net.moonleay.botendo.extensions.music.components.SeekArguments
@ -44,14 +43,14 @@ class SeekExtension : Extension() {
val voiceState = u.asMember(guildId).getVoiceStateOrNull()
if (voiceState == null) {
this.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "You are not connected to a VC"
this.description = "Please connect to a VC"
this.footer {
this.text = MessageUtil.getFooter(u)
}
}
this.embeds.add(
MessageUtil.getEmbed(
Color(0xE0311A),
"You are not connected to a VC",
"Please connect to a VC",
UserUtil.getCommandSrc(u),
)
)
}
return@action
}
@ -59,40 +58,40 @@ class SeekExtension : Extension() {
val channelId = voiceState.channelId
if (link.state == Link.State.NOT_CONNECTED) {
this.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "Not connected"
this.description = "I'm not in a VC and therefore, I am not playing anything."
this.footer {
this.text = MessageUtil.getFooter(u)
}
}
this.embeds.add(
MessageUtil.getEmbed(
Color(0xE0311A),
"Not connected",
"I'm not in a VC and therefore, I am not playing anything.",
UserUtil.getCommandSrc(u),
)
)
}
return@action
} else if (link.state == Link.State.CONNECTED && link.lastChannelId != channelId!!.value) {
this.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "You are not in my VC"
this.description = "We are not in the same VC and therefore, you cannot control the music"
this.footer {
this.text = MessageUtil.getFooter(u)
}
}
this.embeds.add(
MessageUtil.getEmbed(
Color(0xE0311A),
"You are not in my VC",
"We are not in the same VC and therefore, you cannot control the music",
UserUtil.getCommandSrc(u),
)
)
}
return@action
}
var track = player.playingTrack
if (track == null) {
this.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "Not playing"
this.description = "I'm not playing anything currently"
this.footer {
this.text = MessageUtil.getFooter(u)
}
}
this.embeds.add(
MessageUtil.getEmbed(
Color(0xE0311A),
"Not playing",
"I'm not playing anything currently",
UserUtil.getCommandSrc(u)
)
)
}
return@action
}
@ -102,24 +101,25 @@ class SeekExtension : Extension() {
player.seekTo(targetPos)
} else {
this.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "Invalid position"
this.description = "The position you specified is invalid"
this.footer {
this.text = MessageUtil.getFooter(u)
}
}
this.embeds.add(
MessageUtil.getEmbed(
Color(0xE0311A),
"Invalid position",
"The position you specified is invalid",
UserUtil.getCommandSrc(u),
)
)
}
return@action
}
this.respond {
this.embed {
this.color = Color(0x52E01A)
this.title = "Jumped; now playing"
this.description = "**${track.title}**\n*Now Playing*\nby ${track.author} ; ${
this.embeds.add(
MessageUtil.getEmbedWithImage(
Color(0x52E01A),
"Jumped; now playing",
"**${track.title}**\n*Now Playing*\nby ${track.author} ; ${
TimeUtil.getTimeFormatedRaw(
player.position
)
@ -128,24 +128,20 @@ class SeekExtension : Extension() {
track.length.inWholeMilliseconds
)
}\n" +
">>>${track.uri}"
this.footer {
this.text = MessageUtil.getFooter(u)
}
this.thumbnail {
this.url = "https://img.youtube.com/vi/" + UrlUtil.getYtThumbnailUrl(track.uri!!) + "/maxresdefault.jpg"
">>>${track.uri}",
UserUtil.getCommandSrc(user),
"https://img.youtube.com/vi/" + UrlUtil.getYtThumbnailUrl(track.uri!!) + "/maxresdefault.jpg"
)
)
}
}
this.actionRow(fun ActionRowBuilder.() {
components.addAll(
this.actionRow {
this.components.addAll(
ButtonUtil.getMusicControllerButtons(
player.paused,
gts.repeating
).components
)
})
}
}
}
}

View file

@ -21,11 +21,9 @@ package net.moonleay.botendo.extensions.music
import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
import com.kotlindiscord.kord.extensions.types.respond
import dev.kord.common.Color
import dev.kord.rest.builder.component.ActionRowBuilder
import dev.kord.rest.builder.message.actionRow
import dev.kord.rest.builder.message.create.actionRow
import dev.kord.rest.builder.message.embed
import dev.schlaubi.lavakord.audio.Link
import net.moonleay.botendo.extensions.music.components.MusicManager
import net.moonleay.botendo.util.*
@ -43,57 +41,41 @@ class SkipExtension : Extension() {
val u = this.user
val voiceState = u.asMember(guildId).getVoiceStateOrNull()
if (voiceState == null) {
this.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "You are not connected to a VC"
this.description = "Please connect to a VC"
this.footer {
this.text = MessageUtil.getFooter(u)
}
}
}
MessageUtil.sendEmbedForPublicSlashCommand(
this,
Color(0xE0311A),
"You are not connected to a VC",
"Please connect to a VC"
)
return@action
}
val channelId = voiceState.channelId
if (link.state == Link.State.NOT_CONNECTED) {
this.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "Not connected"
this.description = "I'm not in a VC and therefore, I am not playing anything."
this.footer {
this.text = MessageUtil.getFooter(u)
}
}
}
MessageUtil.sendEmbedForPublicSlashCommand(
this,
Color(0xE0311A),
"Not connected",
"I'm not in a VC and therefore, I am not playing anything."
)
return@action
} else if (link.state == Link.State.CONNECTED && link.lastChannelId != channelId!!.value) {
this.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "You are not in my VC"
this.description = "We are not in the same VC and therefore, you cannot control the music"
this.footer {
this.text = MessageUtil.getFooter(u)
}
}
}
MessageUtil.sendEmbedForPublicSlashCommand(
this,
Color(0xE0311A),
"You are not in my VC",
"We are not in the same VC and therefore, you cannot control the music"
)
return@action
}
var track = player.playingTrack
if (track == null) {
this.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "Not playing"
this.description = "I'm not playing anything currently"
this.footer {
this.text = MessageUtil.getFooter(u)
}
}
}
MessageUtil.sendEmbedForPublicSlashCommand(
this,
Color(0xE0311A),
"Not playing",
"I'm not playing anything currently"
)
return@action
}
val gts = MusicManager.getGuildTrackScheduler(this.guild!!.asGuild(), player)
@ -106,31 +88,29 @@ class SkipExtension : Extension() {
this.respond {
this.embed {
this.color = Color(0x52E01A)
this.title = "Skipped song; now playing"
this.description = "**${track.title}**\n*Now Playing*\nby ${track.author} ;: ${
this.embeds.add(
MessageUtil.getEmbedWithImage(
Color(0x52E01A),
"Skipped song; now playing",
"**${track.title}**\n*Now Playing*\nby ${track.author} ;: ${
TimeUtil.getTimeFormatedRaw(
track.length.inWholeMilliseconds
)
}\n" +
">>>${track.uri}"
this.footer {
this.text = MessageUtil.getFooter(u)
}
this.thumbnail {
this.url = "https://img.youtube.com/vi/" + UrlUtil.getYtThumbnailUrl(track.uri!!) + "/maxresdefault.jpg"
}
}
">>>${track.uri}",
UserUtil.getCommandSrc(user),
"https://img.youtube.com/vi/" + UrlUtil.getYtThumbnailUrl(track.uri!!) + "/maxresdefault.jpg"
)
)
this.actionRow(fun ActionRowBuilder.() {
components.addAll(
this.actionRow {
this.components.addAll(
ButtonUtil.getMusicControllerButtons(
player.paused,
gts.repeating
).components
)
})
}
}
}
}

View file

@ -21,8 +21,8 @@ package net.moonleay.botendo.extensions.music
import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
import com.kotlindiscord.kord.extensions.types.respond
import dev.kord.common.Color
import dev.kord.rest.builder.message.embed
import dev.schlaubi.lavakord.audio.Link
import dev.schlaubi.lavakord.kord.getLink
import net.moonleay.botendo.extensions.music.components.MusicManager
@ -43,40 +43,40 @@ class StopExtension : Extension() {
val vcsUser = u.asMember(guildId).getVoiceStateOrNull()
if (vcsUser == null) {
this.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "You are not connected to a VC"
this.description = "Please connect to a VC"
this.footer {
this.text = MessageUtil.getFooter(u)
}
}
this.embeds.add(
MessageUtil.getEmbed(
Color(0xE0311A),
"You are not connected to a VC",
"Please connect to my VC",
UserUtil.getCommandSrc(u),
)
)
}
return@action
}
val channelId = vcsUser.channelId
if (link.state == Link.State.NOT_CONNECTED) {
this.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "Not connected"
this.description = "I'm not in a VC and therefore, I am not playing anything."
this.footer {
this.text = MessageUtil.getFooter(u)
}
}
this.embeds.add(
MessageUtil.getEmbed(
Color(0xE0311A),
"Not connected",
"I'm not in a VC and therefore, I am not playing anything.",
UserUtil.getCommandSrc(u),
)
)
}
return@action
} else if (link.state == Link.State.CONNECTED && link.lastChannelId != channelId!!.value) {
this.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "You are not in my VC"
this.description = "We are not in the same VC"
this.footer {
this.text = MessageUtil.getFooter(u)
}
}
this.embeds.add(
MessageUtil.getEmbed(
Color(0xE0311A),
"You are not in my VC",
"We are not in the same VC",
UserUtil.getCommandSrc(u),
)
)
}
return@action
}
@ -84,14 +84,14 @@ class StopExtension : Extension() {
link.destroy()
MusicManager.getGuildTrackScheduler(this.getGuild()!!.asGuild(), player).clear()
this.respond {
this.embed {
this.color = Color(0x52E01A)
this.title = "I stopped and left"
this.description = "just like your girlfriend"
this.footer {
this.text = MessageUtil.getFooter(u)
}
}
this.embeds.add(
MessageUtil.getEmbed(
Color(0x52E01A),
"I stopped and left",
"just like your girlfriend",
UserUtil.getCommandSrc(u),
)
)
}
}
}

View file

@ -21,8 +21,8 @@ package net.moonleay.botendo.extensions.music
import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
import com.kotlindiscord.kord.extensions.types.respond
import dev.kord.common.Color
import dev.kord.rest.builder.message.embed
import dev.schlaubi.lavakord.audio.Link
import dev.schlaubi.lavakord.kord.getLink
import net.moonleay.botendo.extensions.music.components.LinkArguments
@ -46,14 +46,14 @@ class UpsertExtension : Extension() {
val vcsUser = u.asMember(guildId).getVoiceStateOrNull()
if (vcsUser == null) {
this.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "You are not connected to a VC"
this.description = "Please connect to a VC"
this.footer {
this.text = MessageUtil.getFooter(u)
}
}
embeds.add(
MessageUtil.getEmbed(
Color(0xE0311A),
"You are not connected to a VC",
"Please connect to a VC",
UserUtil.getCommandSrc(u),
)
)
}
return@action
}
@ -64,14 +64,14 @@ class UpsertExtension : Extension() {
link.connectAudio(channelId!!.value)
} else if (link.state == Link.State.CONNECTED && link.lastChannelId != channelId!!.value) {
this.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "You are not in my VC"
this.description = "We are not in the same VC and therefore, you cannot play any music"
this.footer {
this.text = MessageUtil.getFooter(u)
}
}
embeds.add(
MessageUtil.getEmbed(
Color(0xE0311A),
"You are not in my VC",
"We are not in the same VC and therefore, you cannot play any music",
UserUtil.getCommandSrc(u),
)
)
}
return@action
}
@ -83,14 +83,14 @@ class UpsertExtension : Extension() {
"ytsearch:$query"
}
this.respond {
this.embed {
this.color = Color(0xE0A81A)
this.title = "Searching..."
this.description = "We are looking for $query"
this.footer {
this.text = MessageUtil.getFooter(u)
}
}
embeds.add(
MessageUtil.getEmbed(
Color(0xE0A81A),
"Searching...",
"We are looking for $query",
UserUtil.getCommandSrc(u),
)
)
}
MusicManager.upsertIntoQueue(this, link, search)
}

View file

@ -21,13 +21,11 @@ package net.moonleay.botendo.extensions.music.components
import com.kotlindiscord.kord.extensions.commands.application.slash.PublicSlashCommandContext
import com.kotlindiscord.kord.extensions.components.forms.ModalForm
import com.kotlindiscord.kord.extensions.types.respond
import dev.kord.common.Color
import dev.kord.common.entity.Snowflake
import dev.kord.core.entity.Guild
import dev.kord.rest.builder.component.ActionRowBuilder
import dev.kord.rest.builder.message.actionRow
import dev.kord.rest.builder.message.create.actionRow
import dev.kord.rest.builder.message.embed
import dev.schlaubi.lavakord.audio.Link
import dev.schlaubi.lavakord.audio.player.Player
import dev.schlaubi.lavakord.rest.loadItem
@ -79,32 +77,29 @@ object MusicManager {
gts.queue(item.track, type)
if (!silent)
ctx.respond {
this.embed {
this.color = Color(0x52E01A)
this.title = "${type.s} track from link"
this.description = "**${item.track.info.title}**\n*Queue*\nby ${item.track.info.author} ;: ${
this.embeds.add(
MessageUtil.getEmbedWithImage(
Color(0x52E01A),
"${type.s} track from link",
"**${item.track.info.title}**\n*Queue*\nby ${item.track.info.author} ;: ${
TimeUtil.getTimeFormatedRaw(
item.track.info.length
)
}\n" +
">>>${item.track.info.uri}"
this.footer {
this.text = MessageUtil.getFooter(u)
}
this.thumbnail {
this.url =
">>>${item.track.info.uri}",
UserUtil.getCommandSrc(u),
"https://img.youtube.com/vi/" + UrlUtil.getYtThumbnailUrl(item.track.info.uri) + "/maxresdefault.jpg"
}
}
)
)
this.actionRow(fun ActionRowBuilder.() {
components.addAll(
this.actionRow {
this.components.addAll(
ButtonUtil.getMusicControllerButtons(
player.paused,
gts.repeating
).components
)
})
}
}
}
@ -115,23 +110,19 @@ object MusicManager {
}
if (!silent)
ctx.respond {
this.embed {
this.color = Color(0x52E01A)
this.title = "${type.s} playlist from link"
this.description = "**${item.tracks.first().info.title}**\n*${item.playlistInfo.name}*\nby ${item.tracks.first().info.author} ;: ${
this.embeds.add(
MessageUtil.getEmbed(
Color(0x52E01A),
"${type.s} playlist from link",
"**${item.tracks.first().info.title}**\n*${item.playlistInfo.name}*\nby ${item.tracks.first().info.author} ;: ${
TimeUtil.getTimeFormatedRaw(
item.tracks.first().info.length
)
}\n" +
">>>${item.tracks.first().info.uri}"
this.footer {
this.text = MessageUtil.getFooter(u)
}
this.thumbnail {
this.url =
"https://img.youtube.com/vi/" + UrlUtil.getYtThumbnailUrl(item.tracks.first().info.uri) + "/maxresdefault.jpg"
}
}
">>>${item.tracks.first().info.uri}",
UserUtil.getCommandSrc(u),
)
)
this.actionRow {
this.components.addAll(
@ -148,23 +139,20 @@ object MusicManager {
gts.queue(item.tracks.first(), type)
if (!silent)
ctx.respond {
this.embed {
this.color = Color(0x52E01A)
this.title = "${type.s} track from query"
this.description = "**${item.tracks.first().info.title}**\n*Queue*\nby ${item.tracks.first().info.author} ;: ${
this.embeds.add(
MessageUtil.getEmbedWithImage(
Color(0x52E01A),
"${type.s} track from query",
"**${item.tracks.first().info.title}**\n*Queue*\nby ${item.tracks.first().info.author} ;: ${
TimeUtil.getTimeFormatedRaw(
item.tracks.first().info.length
)
}\n" +
">>>${item.tracks.first().info.uri}"
this.footer {
this.text = MessageUtil.getFooter(u)
}
this.thumbnail {
this.url =
">>>${item.tracks.first().info.uri}",
UserUtil.getCommandSrc(u),
"https://img.youtube.com/vi/" + UrlUtil.getYtThumbnailUrl(item.tracks.first().info.uri) + "/maxresdefault.jpg"
}
}
)
)
this.actionRow {
this.components.addAll(
@ -180,28 +168,28 @@ object MusicManager {
TrackResponse.LoadType.NO_MATCHES -> {
if (!silent)
ctx.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "Not found"
this.description = "There were no matches."
this.footer {
this.text = MessageUtil.getFooter(u)
}
}
this.embeds.add(
MessageUtil.getEmbed(
Color(0xE0311A),
"Not found",
"There were no matches.",
UserUtil.getCommandSrc(u),
)
)
}
}
TrackResponse.LoadType.LOAD_FAILED -> {
if (!silent)
ctx.respond {
this.embed {
this.color = Color(0xE0311A)
this.title = "Load failed"
this.description = "There was an error while loading."
this.footer {
this.text = MessageUtil.getFooter(u)
}
}
this.embeds.add(
MessageUtil.getEmbed(
Color(0xE0311A),
"Load failed",
"There was an error while loading.",
UserUtil.getCommandSrc(u),
)
)
}
}
}

View file

@ -22,7 +22,6 @@ package net.moonleay.botendo.extensions.util
import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
import dev.kord.common.Color
import dev.kord.rest.builder.message.embed
import net.moonleay.botendo.util.MessageUtil
class InfoExtension : Extension() {
@ -32,23 +31,17 @@ class InfoExtension : Extension() {
name = "info"
description = "Show infos about the bot"
this.action {
val u = this.user
this.respond {
this.embed {
this.color = Color(0x52E01A)
this.title = "Botendo"
this.description = "Botendo ***v." + net.moonleay.botendo.build.BuildConstants.version + "***\n" +
MessageUtil.sendEmbedForPublicSlashCommand(
this,
Color(0x52E01A), "Botendo",
"Botendo ***v." + net.moonleay.botendo.build.BuildConstants.version + "***\n" +
"Kord-Extensions ***v." + net.moonleay.botendo.build.BuildConstants.kordVersion + "***\n" +
"lavalink.kt ***v." + net.moonleay.botendo.build.BuildConstants.lavaVersion + "***\n" +
"Coroutines ***v." + net.moonleay.botendo.build.BuildConstants.coroutinesVersion + "***\n\n\n" +
"***Bot made by moonleay***\n" +
"(c) 2023, licensed under GPL-3.0\n" +
"More infos: https://moonleay.net/projects/botendo\n"
this.footer {
this.text = MessageUtil.getFooter(u)
}
}
}
)
}
}
}

View file

@ -22,8 +22,8 @@ package net.moonleay.botendo.util
import com.kotlindiscord.kord.extensions.commands.Arguments
import com.kotlindiscord.kord.extensions.commands.application.slash.PublicSlashCommandContext
import com.kotlindiscord.kord.extensions.components.forms.ModalForm
import com.kotlindiscord.kord.extensions.types.respond
import dev.kord.common.Color
import dev.kord.core.behavior.UserBehavior
import dev.kord.rest.builder.message.EmbedBuilder
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
@ -31,8 +31,74 @@ import java.time.format.DateTimeFormatter
object MessageUtil {
private val dtf: DateTimeFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy @ HH:mm:ss")
suspend fun getFooter(u: UserBehavior? = null): String{
///Send an embedded message as a reply
suspend fun sendEmbedForPublicSlashCommand(
ctx: PublicSlashCommandContext<Arguments, ModalForm>,
color: Color,
title: String,
description: String
) {
ctx.respond {
embeds.add(
getEmbed(
color,
title,
description,
UserUtil.getCommandSrc(ctx.user)
)
)
}
}
///Send an embedded message with an image as a reply
suspend fun sendEmbedForPublicSlashCommandWithImage(
ctx: PublicSlashCommandContext<Arguments, ModalForm>,
color: Color,
title: String,
description: String,
thumbnailUrl: String
) {
ctx.respond {
embeds.add(
getEmbedWithImage(
color,
title,
description,
UserUtil.getCommandSrc(ctx.user),
thumbnailUrl
)
)
}
}
///Get an embedded msg with title, description and a src
fun getEmbed(
color: Color,
title: String,
description: String,
source: String
): EmbedBuilder {
val now: LocalDateTime = LocalDateTime.now()
return ">" + dtf.format(now) + " - ${u?.asUser()?.username?:"Automatic Message"}"
val ebb = EmbedBuilder()
ebb.title = title
ebb.description = description
ebb.footer = EmbedBuilder.Footer()
ebb.footer!!.text = ">" + dtf.format(now) + " - $source"
ebb.color = color
return ebb
}
///Get an embedded msg with image, title, description and a src
fun getEmbedWithImage(
color: Color,
title: String,
description: String,
source: String,
thumbnailUrl: String
): EmbedBuilder {
val ebb = getEmbed(color, title, description, source)
ebb.thumbnail = EmbedBuilder.Thumbnail()
ebb.thumbnail!!.url = thumbnailUrl
return ebb
}
}

View file

@ -23,6 +23,12 @@ import dev.kord.core.behavior.UserBehavior
object UserUtil {
suspend fun getCommandSrc(u: UserBehavior): String {
return "${u.asUser().username}}"
return "${u.asUser().username}${getUserDiscriminator(u)}"
}
private suspend fun getUserDiscriminator(u: UserBehavior): String {
if (u.asUser().discriminator == "0")
return ""
return "#${u.asUser().discriminator}"
}
}