Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Lint
  • Loading branch information
duncte123 committed Jun 24, 2024
commit f5ab5e30efe37a0560cfbe50071e695d26f5e3c7
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ class BlackListCommand : ModBaseCommand() {
override fun execute(ctx: CommandContext) {
val args = ctx.args
val sendMsg: (MessageCreateBuilder) -> Unit = {
sendMsg(MessageConfig.Builder.fromCtx(ctx)
.setMessageBuilder(it)
.setFailureAction { thr ->
sendMsg(ctx, "Failed to send (attach file permission missing???): ${thr.message}")
}
.build())
sendMsg(
MessageConfig.Builder.fromCtx(ctx)
.setMessageBuilder(it)
.setFailureAction { thr ->
sendMsg(ctx, "Failed to send (attach file permission missing???): ${thr.message}")
}
.build()
)
}

when (args[0]) {
Expand Down Expand Up @@ -100,7 +102,6 @@ class BlackListCommand : ModBaseCommand() {
return
}


clearBlacklist(
ctx.database,
ctx.guild,
Expand Down Expand Up @@ -249,7 +250,7 @@ class BlackListCommand : ModBaseCommand() {
guild: Guild,
author: User,
jackson: ObjectMapper,
sendMsg: (MessageCreateBuilder) -> Unit
sendMsg: (MessageCreateBuilder) -> Unit,
) {
if (blacklist.isEmpty()) {
sendMsg(
Expand Down Expand Up @@ -279,7 +280,7 @@ class BlackListCommand : ModBaseCommand() {
database: AbstractDatabase,
guild: DunctebotGuild,
jackson: ObjectMapper,
sendMsg: (MessageCreateBuilder) -> Unit
sendMsg: (MessageCreateBuilder) -> Unit,
) {
val blacklist = guild.settings.blacklistedWords

Expand All @@ -300,7 +301,10 @@ class BlackListCommand : ModBaseCommand() {

sendMsg(
MessageCreateBuilder()
.setContent("The blacklist has been cleared!\nYou can use the file attached to import your old blacklist in case this was a mistake.")
.setContent(
"The blacklist has been cleared!\n" +
"You can use the file attached to import your old blacklist in case this was a mistake."
)
.addFiles(
FileUpload.fromData(
listBytes,
Expand All @@ -315,7 +319,7 @@ class BlackListCommand : ModBaseCommand() {
guild: DunctebotGuild,
database: AbstractDatabase,
jackson: ObjectMapper,
attachment: Attachment
attachment: Attachment,
) {
attachment.proxy.download().thenAccept { file ->
try {
Expand Down Expand Up @@ -381,7 +385,7 @@ class BlackListCommand : ModBaseCommand() {
word: String,
database: AbstractDatabase,
guild: DunctebotGuild,
sendMsg: (String) -> Unit
sendMsg: (String) -> Unit,
) {
val list = guild.settings.blacklistedWords

Expand All @@ -402,7 +406,7 @@ class BlackListCommand : ModBaseCommand() {
word: String,
database: AbstractDatabase,
guild: DunctebotGuild,
sendMsg: (String) -> Unit
sendMsg: (String) -> Unit,
) {
val list = guild.settings.blacklistedWords

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import me.duncte123.skybot.utils.FinderUtils
import net.dv8tion.jda.api.EmbedBuilder
import net.dv8tion.jda.api.Permission
import net.dv8tion.jda.api.entities.Guild
import net.dv8tion.jda.api.entities.MessageEmbed
import net.dv8tion.jda.api.entities.Role
import net.dv8tion.jda.api.entities.channel.ChannelType
import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel
Expand All @@ -42,7 +41,6 @@ import net.dv8tion.jda.api.interactions.commands.OptionType
import net.dv8tion.jda.api.interactions.commands.build.OptionData
import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData
import net.dv8tion.jda.api.interactions.commands.build.SubcommandGroupData
import java.util.stream.Collectors

const val RES_OK = 0
Expand Down Expand Up @@ -153,12 +151,14 @@ class VcAutoRoleCommand : ModBaseCommand() {
true
),
// TODO: option not valid yet
/*OptionData(
/*
OptionData(
OptionType.ROLE,
"role",
"The role to unlink from the voice channel",
false
),*/
),
*/
),
SubcommandData(
"off",
Expand Down Expand Up @@ -344,7 +344,6 @@ class VcAutoRoleCommand : ModBaseCommand() {
return
}


val vcAutoRoleCache = variables.vcAutoRoleCache
val cache: TLongLongMap = vcAutoRoleCache.putIfAbsent(guild.idLong, TLongLongHashMap())
val targetRole = role.idLong
Expand Down Expand Up @@ -398,7 +397,7 @@ class VcAutoRoleCommand : ModBaseCommand() {
channel: AudioChannel,
role: Role,
guild: Guild,
variables: Variables
variables: Variables,
): Int {
if (!guild.selfMember.canInteract(role)) {
return RES_ROLE_NOT_INTERACT
Expand All @@ -418,7 +417,7 @@ class VcAutoRoleCommand : ModBaseCommand() {
private fun removeSingleVcAutoRole(
channel: AudioChannel,
guild: Guild,
variables: Variables
variables: Variables,
): Int {
val vcAutoRoleCache = variables.vcAutoRoleCache
val cache: TLongLongMap = vcAutoRoleCache.putIfAbsent(guild.idLong, TLongLongHashMap())
Expand All @@ -436,13 +435,13 @@ class VcAutoRoleCommand : ModBaseCommand() {

private fun listAutoVcRoles(
guild: Guild,
variables: Variables
variables: Variables,
): EmbedBuilder {
val cache = variables.vcAutoRoleCache
val guildId = guild.idLong

if (!cache.containsKey(guildId)) {
return EmbedUtils.getDefaultEmbed(guildId)
return EmbedUtils.getDefaultEmbed(guildId)
.setDescription("No vc autorole has been set for this server")
}

Expand All @@ -457,7 +456,6 @@ class VcAutoRoleCommand : ModBaseCommand() {
return@forEachEntry true
}


return embed
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class BassBoostCommand : MusicCommand() {
override fun handleEvent(
event: SlashCommandInteractionEvent,
guild: DunctebotGuild,
variables: Variables
variables: Variables,
) {
if (!isUserOrGuildPatron(event)) {
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class ForceSkip : MusicCommand() {
override fun handleEvent(
event: SlashCommandInteractionEvent,
guild: DunctebotGuild,
variables: Variables
variables: Variables,
) {
//
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class JoinCommand : MusicCommand() {
override fun handleEvent(
event: SlashCommandInteractionEvent,
guild: DunctebotGuild,
variables: Variables
variables: Variables,
) {
val memberVoice = event.member!!.voiceState!!

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class LeaveCommand : MusicCommand() {
override fun handleEvent(
event: SlashCommandInteractionEvent,
guild: DunctebotGuild,
variables: Variables
variables: Variables,
) {
val guild = event.guild!!

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class LoadCommand : MusicCommand() {
override fun handleEvent(
event: SlashCommandInteractionEvent,
guild: DunctebotGuild,
variables: Variables
variables: Variables,
) {
val attachment = event.getOption("file")!!.asAttachment

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class LyricsCommand : MusicCommand() {
override fun handleEvent(
event: SlashCommandInteractionEvent,
guild: DunctebotGuild,
variables: Variables
variables: Variables,
) {
val opt = event.getOption("song")

Expand Down Expand Up @@ -201,15 +201,17 @@ class LyricsCommand : MusicCommand() {
.subscribe({
it as TextLyrics // We always get text lyrics here since we are using genius.

cb(buildLyricsEmbed(
LyricInfo(
it.track.albumArt.last().url,
it.track.title,
null,
it.source,
it.text
cb(
buildLyricsEmbed(
LyricInfo(
it.track.albumArt.last().url,
it.track.title,
null,
it.source,
it.text
)
)
))
)
}) {
LOGGER.error("Failed searching lyrics for genius", it)
cb(null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class NowPlayingCommand : MusicCommand() {
override fun handleEvent(
event: SlashCommandInteractionEvent,
guild: DunctebotGuild,
variables: Variables
variables: Variables,
) {
val mng = variables.audioUtils.getMusicManager(event.guild!!.idLong)
val player = mng.player.getOrNull()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class PPlayCommand : MusicCommand() {
override fun handleEvent(
event: SlashCommandInteractionEvent,
guild: DunctebotGuild,
variables: Variables
variables: Variables,
) {
event.reply("This command will be going away soon. Please use the `/play` command instead.").queue()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class PauseCommand : MusicCommand() {
override fun handleEvent(
event: SlashCommandInteractionEvent,
guild: DunctebotGuild,
variables: Variables
variables: Variables,
) {
val mng = variables.audioUtils.getMusicManager(event.guild!!.idLong)
val localPlayer = mng.player
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ open class PlayCommand(private val skipParsing: Boolean = false) : MusicCommand(
override fun handleEvent(
event: SlashCommandInteractionEvent,
guild: DunctebotGuild,
variables: Variables
variables: Variables,
) {
if (!event.member!!.voiceState!!.inAudioChannel()) {
event.reply("Auto-join is not yet supported for slash commands. Sorry about that").queue()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class QueueCommand : MusicCommand() {
override fun handleEvent(
event: SlashCommandInteractionEvent,
guild: DunctebotGuild,
variables: Variables
variables: Variables,
) {
val embed = generateQueueEmbed(variables, event.guild!!, "/")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class RadioCommand : MusicCommand() {
override fun handleEvent(
event: SlashCommandInteractionEvent,
guild: DunctebotGuild,
variables: Variables
variables: Variables,
) {
event.reply("Slash command not supported yet, sorry. Please report this issue.").queue()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class ReaddCommand : MusicCommand() {
override fun handleEvent(
event: SlashCommandInteractionEvent,
guild: DunctebotGuild,
variables: Variables
variables: Variables,
) {
event.reply("Slash command not supported yet, sorry. Please report this issue.").queue()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class RepeatCommand : MusicCommand() {
override fun handleEvent(
event: SlashCommandInteractionEvent,
guild: DunctebotGuild,
variables: Variables
variables: Variables,
) {
event.reply("Slash command not supported yet, sorry. Please report this issue.").queue()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class RepeatQueueCommand : MusicCommand() {
override fun handleEvent(
event: SlashCommandInteractionEvent,
guild: DunctebotGuild,
variables: Variables
variables: Variables,
) {
event.reply("Slash command not supported yet, sorry. Please report this issue.").queue()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class RestartCommand : MusicCommand() {
override fun handleEvent(
event: SlashCommandInteractionEvent,
guild: DunctebotGuild,
variables: Variables
variables: Variables,
) {
event.reply("Slash command not supported yet, sorry. Please report this issue.").queue()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SaveCommand : MusicCommand() {
override fun handleEvent(
event: SlashCommandInteractionEvent,
guild: DunctebotGuild,
variables: Variables
variables: Variables,
) {
event.reply("Slash command not supported yet, sorry. Please report this issue.").queue()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class SearchCommand : MusicCommand() {
override fun handleEvent(
event: SlashCommandInteractionEvent,
guild: DunctebotGuild,
variables: Variables
variables: Variables,
) {
event.reply("Slash command not supported yet, sorry. Please report this issue.").queue()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ShuffleCommand : MusicCommand() {
override fun handleEvent(
event: SlashCommandInteractionEvent,
guild: DunctebotGuild,
variables: Variables
variables: Variables,
) {
event.reply("Slash command not supported yet, sorry. Please report this issue.").queue()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SkipCommand : MusicCommand() {
override fun handleEvent(
event: SlashCommandInteractionEvent,
guild: DunctebotGuild,
variables: Variables
variables: Variables,
) {
event.deferReply().queue()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class StopCommand : MusicCommand() {
override fun handleEvent(
event: SlashCommandInteractionEvent,
guild: DunctebotGuild,
variables: Variables
variables: Variables,
) {
val mng = variables.audioUtils.getMusicManager(event.guild!!.idLong)
val player = mng.player.getOrNull()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class VolumeCommand : MusicCommand() {
override fun handleEvent(
event: SlashCommandInteractionEvent,
guild: DunctebotGuild,
variables: Variables
variables: Variables,
) {
if (!isUserOrGuildPatron(event)) {
return
Expand Down