Adjust permission of music commands
This commit is contained in:
1 parent
4b26acc63a
commit
02c1eab6e3
4 files changed
+31
-14
No files matched your search
@@ -15,6 +15,7 @@ import netneutrality.utils.MusicUtils;
|
||||
import netneutrality.utils.UserFunction;
|
||||
|
||||
public class SkipCommand extends AbstractMusicCommand {
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
@@ -32,7 +33,14 @@ public class SkipCommand extends AbstractMusicCommand {
|
||||
|
||||
@Override
|
||||
public CommandUsage getUsage() {
|
||||
return CommandUsage.create(this, new CommandUsage.Argument(CommandUsage.Argument.Type.OPTIONAL, new String[]{"number"}, "Number of tracks to skip"));
|
||||
return CommandUsage.create(
|
||||
this,
|
||||
new CommandUsage.Argument(
|
||||
CommandUsage.Argument.Type.OPTIONAL,
|
||||
new String[]{"number"},
|
||||
"Number of tracks to skip"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -47,8 +55,8 @@ public class SkipCommand extends AbstractMusicCommand {
|
||||
if (!MusicUtils.checkIfConnected(player, context))
|
||||
return;
|
||||
|
||||
if (UserFunction.isAdmin(context.getGuildUser())) {
|
||||
if (context.getArgs().length > 0) {
|
||||
if (UserFunction.isAdmin(context.getGuildUser()) || MusicUtils.isUserDj(context.getGuildUser())) {
|
||||
if (UserFunction.isAdmin(context.getGuildUser()) && context.getArgs().length > 0) {
|
||||
try {
|
||||
int skips = Integer.parseInt(context.getArgument(0));
|
||||
player.skip(skips);
|
||||
|
||||
@@ -12,6 +12,7 @@ import netneutrality.command.CommandUsage;
|
||||
import netneutrality.core.context.CommandContext;
|
||||
import netneutrality.music.MusicManager;
|
||||
import netneutrality.utils.MusicUtils;
|
||||
import netneutrality.utils.UserFunction;
|
||||
|
||||
public class StopCommand extends AbstractMusicCommand {
|
||||
|
||||
@@ -44,7 +45,12 @@ public class StopCommand extends AbstractMusicCommand {
|
||||
public void execute(CommandContext context) {
|
||||
MusicManager player = MusicManager.get(context.getGuild());
|
||||
|
||||
if (MusicUtils.checkIfConnected(player, context) && MusicUtils.isDj(player, context)) {
|
||||
if (!MusicUtils.checkIfConnected(player, context))
|
||||
return;
|
||||
|
||||
// Need a resume command before
|
||||
// if (UserFunction.isAdmin(context.getGuildUser()) || MusicUtils.isUserDj(context.getGuildUser())) {
|
||||
if (UserFunction.isAdmin(context.getGuildUser())) {
|
||||
player.stopTrack();
|
||||
context.reply("Stopping current track");
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import netneutrality.command.CommandUsage;
|
||||
import netneutrality.core.context.CommandContext;
|
||||
import netneutrality.music.MusicManager;
|
||||
import netneutrality.utils.MusicUtils;
|
||||
import netneutrality.utils.UserFunction;
|
||||
|
||||
public class VolumeCommand extends AbstractMusicCommand {
|
||||
|
||||
@@ -44,7 +45,10 @@ public class VolumeCommand extends AbstractMusicCommand {
|
||||
public void execute(CommandContext context) {
|
||||
MusicManager player = MusicManager.get(context.getGuild());
|
||||
|
||||
if (MusicUtils.checkIfConnected(player, context) && MusicUtils.isDj(player, context)) {
|
||||
if (!MusicUtils.checkIfConnected(player, context))
|
||||
return;
|
||||
|
||||
if (UserFunction.isAdmin(context.getGuildUser()) || MusicUtils.isUserDj(context.getGuildUser())) {
|
||||
try {
|
||||
int volume = Integer.parseInt(context.getArgument(0));
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package netneutrality.utils;/*
|
||||
package netneutrality.utils;
|
||||
/*
|
||||
* Copyright (c) anthorob
|
||||
*
|
||||
* https://xtremcommunity.com/
|
||||
* https://discord.gg/CdFcyQ
|
||||
*/
|
||||
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.VoiceChannel;
|
||||
import netneutrality.core.context.CommandContext;
|
||||
import netneutrality.exceptions.CommandExecutionException;
|
||||
@@ -28,7 +30,7 @@ public class MusicUtils {
|
||||
}
|
||||
|
||||
VoiceChannel vChannel = context.getGuildUser().getVoiceState().getChannel();
|
||||
if (!manager.isConnectedTo(vChannel)) {
|
||||
if (manager.isNotConnectedTo(vChannel)) {
|
||||
context.reply("The bot isn't in your voice channel");
|
||||
return false;
|
||||
}
|
||||
@@ -36,14 +38,11 @@ public class MusicUtils {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isDj(MusicManager manager, CommandContext context) {
|
||||
public static boolean isUserDj(Member member) {
|
||||
MusicManager manager = MusicManager.get(member.getGuild());
|
||||
|
||||
if (manager.isCurrentlyPlaying()) {
|
||||
if (UserFunction.isAdmin(context.getGuildUser()) || manager.getRequesterOfCurrentTrack().getId().equals(context.getGuildUser().getId())) {
|
||||
return true;
|
||||
} else {
|
||||
context.reply("You're not powerful enough, scrub");
|
||||
return false;
|
||||
}
|
||||
return manager.getRequesterOfCurrentTrack().equals(member);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user