<commit_before>package com.mrpowergamerbr.loritta.commands.vanilla.music

import com.mrpowergamerbr.loritta.Loritta
import com.mrpowergamerbr.loritta.commands.AbstractCommand
import com.mrpowergamerbr.loritta.commands.CommandContext
import com.mrpowergamerbr.loritta.utils.Constants
import com.mrpowergamerbr.loritta.utils.LorittaPermission
import com.mrpowergamerbr.loritta.utils.locale.LegacyBaseLocale
import com.mrpowergamerbr.loritta.utils.loritta
import net.dv8tion.jda.api.Permission
import net.perfectdreams.loritta.api.commands.CommandCategory

class PularCommand : AbstractCommand("skip", listOf("pular"), category = CommandCategory.MUSIC) {
	override fun getDescription(locale: LegacyBaseLocale): String {
		return locale["PULAR_DESCRIPTION"]
	}

	override fun requiresMusicEnabled(): Boolean {
		return true
	}

	override fun canUseInPrivateChannel(): Boolean {
		return false
	}

	override suspend fun run(context: CommandContext, locale: LegacyBaseLocale) {
		val channel = context.guild.selfMember.voiceState?.channel

		if (channel != null) {
			// Só tem uma pessoa escutando no canal de música?
			val usersInChannel = channel.members.filter { !it.user.isBot }
			// Se tiver, vamos deixar ela pular a música, afinal, só tem ela!

			if (usersInChannel.size > 1 || (usersInChannel.size == 1 && usersInChannel.first().user.idLong != context.userHandle.idLong)) { // Mas se tiver mais de uma, vamos verificar se ela tem permissão de DJ!
				val missingPermissions = listOf(LorittaPermission.DJ).filterNot { context.lorittaUser.hasPermission(it) }

				if (missingPermissions.isNotEmpty()) {
					// oh no
					val required = missingPermissions.joinToString(", ", transform = { "`" + locale["LORIPERMISSION_${it.name}"] + "`"})
					var message = locale["LORIPERMISSION_MissingPermissions", required]

					if (context.handle.hasPermission(Permission.ADMINISTRATOR) || context.handle.hasPermission(Permission.MANAGE_SERVER)) {
						message += " ${locale["LORIPERMISSION_MissingPermCanConfigure", loritta.instanceConfig.loritta.website.url]}"
					}
					context.reply(
							message,
							Constants.ERROR
					)
					return
				}
			}
		}

		loritta.audioManager.skipTrack(context)
	}
}<commit_msg>Permitir que a pessoa que colocou a música possa pular ela<commit_after>package com.mrpowergamerbr.loritta.commands.vanilla.music

import com.mrpowergamerbr.loritta.commands.AbstractCommand
import com.mrpowergamerbr.loritta.commands.CommandContext
import com.mrpowergamerbr.loritta.utils.Constants
import com.mrpowergamerbr.loritta.utils.LorittaPermission
import com.mrpowergamerbr.loritta.utils.locale.LegacyBaseLocale
import com.mrpowergamerbr.loritta.utils.loritta
import net.dv8tion.jda.api.Permission
import net.perfectdreams.loritta.api.commands.CommandCategory

class PularCommand : AbstractCommand("skip", listOf("pular"), category = CommandCategory.MUSIC) {
	override fun getDescription(locale: LegacyBaseLocale): String {
		return locale["PULAR_DESCRIPTION"]
	}

	override fun requiresMusicEnabled(): Boolean {
		return true
	}

	override fun canUseInPrivateChannel(): Boolean {
		return false
	}

	override suspend fun run(context: CommandContext, locale: LegacyBaseLocale) {
		val channel = context.guild.selfMember.voiceState?.channel

		if (channel != null) {
			// Só tem uma pessoa escutando no canal de música?
			val usersInChannel = channel.members.filter { !it.user.isBot }
			// Se tiver, vamos deixar ela pular a música, afinal, só tem ela!

			if (usersInChannel.size > 1 || (usersInChannel.size == 1 && usersInChannel.first().user.idLong != context.userHandle.idLong)) { // Mas se tiver mais de uma, vamos verificar se ela tem permissão de DJ!
				// E foi o usuário que colocou essa música?
				val musicManager = loritta.audioManager.getGuildAudioPlayer(context.guild)

				if (musicManager.scheduler.currentTrack?.user?.idLong != context.userHandle.idLong) {
					val missingPermissions = listOf(LorittaPermission.DJ).filterNot { context.lorittaUser.hasPermission(it) }

					if (missingPermissions.isNotEmpty()) {
						// oh no
						val required = missingPermissions.joinToString(", ", transform = { "`" + locale["LORIPERMISSION_${it.name}"] + "`" })
						var message = locale["LORIPERMISSION_MissingPermissions", required]

						if (context.handle.hasPermission(Permission.ADMINISTRATOR) || context.handle.hasPermission(Permission.MANAGE_SERVER)) {
							message += " ${locale["LORIPERMISSION_MissingPermCanConfigure", loritta.instanceConfig.loritta.website.url]}"
						}
						context.reply(
								message,
								Constants.ERROR
						)
						return
					}
				}
			}
		}

		loritta.audioManager.skipTrack(context)
	}
}
{'fraction_non_alphanumeric': 0.10607356715141146, 'fraction_numerical': 0.0012831479897348161, 'mean_word_length': 4.554631828978622, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7155432', 'n_tokens_mistral': 1645, 'n_tokens_neox': 1451, 'n_words': 286}