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;
|
import netneutrality.utils.UserFunction;
|
||||||
|
|
||||||
public class SkipCommand extends AbstractMusicCommand {
|
public class SkipCommand extends AbstractMusicCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return true;
|
return true;
|
||||||
@@ -32,7 +33,14 @@ public class SkipCommand extends AbstractMusicCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandUsage getUsage() {
|
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
|
@Override
|
||||||
@@ -47,8 +55,8 @@ public class SkipCommand extends AbstractMusicCommand {
|
|||||||
if (!MusicUtils.checkIfConnected(player, context))
|
if (!MusicUtils.checkIfConnected(player, context))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (UserFunction.isAdmin(context.getGuildUser())) {
|
if (UserFunction.isAdmin(context.getGuildUser()) || MusicUtils.isUserDj(context.getGuildUser())) {
|
||||||
if (context.getArgs().length > 0) {
|
if (UserFunction.isAdmin(context.getGuildUser()) && context.getArgs().length > 0) {
|
||||||
try {
|
try {
|
||||||
int skips = Integer.parseInt(context.getArgument(0));
|
int skips = Integer.parseInt(context.getArgument(0));
|
||||||
player.skip(skips);
|
player.skip(skips);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import netneutrality.command.CommandUsage;
|
|||||||
import netneutrality.core.context.CommandContext;
|
import netneutrality.core.context.CommandContext;
|
||||||
import netneutrality.music.MusicManager;
|
import netneutrality.music.MusicManager;
|
||||||
import netneutrality.utils.MusicUtils;
|
import netneutrality.utils.MusicUtils;
|
||||||
|
import netneutrality.utils.UserFunction;
|
||||||
|
|
||||||
public class StopCommand extends AbstractMusicCommand {
|
public class StopCommand extends AbstractMusicCommand {
|
||||||
|
|
||||||
@@ -44,7 +45,12 @@ public class StopCommand extends AbstractMusicCommand {
|
|||||||
public void execute(CommandContext context) {
|
public void execute(CommandContext context) {
|
||||||
MusicManager player = MusicManager.get(context.getGuild());
|
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();
|
player.stopTrack();
|
||||||
context.reply("Stopping current track");
|
context.reply("Stopping current track");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import netneutrality.command.CommandUsage;
|
|||||||
import netneutrality.core.context.CommandContext;
|
import netneutrality.core.context.CommandContext;
|
||||||
import netneutrality.music.MusicManager;
|
import netneutrality.music.MusicManager;
|
||||||
import netneutrality.utils.MusicUtils;
|
import netneutrality.utils.MusicUtils;
|
||||||
|
import netneutrality.utils.UserFunction;
|
||||||
|
|
||||||
public class VolumeCommand extends AbstractMusicCommand {
|
public class VolumeCommand extends AbstractMusicCommand {
|
||||||
|
|
||||||
@@ -44,7 +45,10 @@ public class VolumeCommand extends AbstractMusicCommand {
|
|||||||
public void execute(CommandContext context) {
|
public void execute(CommandContext context) {
|
||||||
MusicManager player = MusicManager.get(context.getGuild());
|
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 {
|
try {
|
||||||
int volume = Integer.parseInt(context.getArgument(0));
|
int volume = Integer.parseInt(context.getArgument(0));
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package netneutrality.utils;/*
|
package netneutrality.utils;
|
||||||
|
/*
|
||||||
* Copyright (c) anthorob
|
* Copyright (c) anthorob
|
||||||
*
|
*
|
||||||
* https://xtremcommunity.com/
|
* https://xtremcommunity.com/
|
||||||
* https://discord.gg/CdFcyQ
|
* https://discord.gg/CdFcyQ
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
import net.dv8tion.jda.api.entities.VoiceChannel;
|
import net.dv8tion.jda.api.entities.VoiceChannel;
|
||||||
import netneutrality.core.context.CommandContext;
|
import netneutrality.core.context.CommandContext;
|
||||||
import netneutrality.exceptions.CommandExecutionException;
|
import netneutrality.exceptions.CommandExecutionException;
|
||||||
@@ -28,7 +30,7 @@ public class MusicUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
VoiceChannel vChannel = context.getGuildUser().getVoiceState().getChannel();
|
VoiceChannel vChannel = context.getGuildUser().getVoiceState().getChannel();
|
||||||
if (!manager.isConnectedTo(vChannel)) {
|
if (manager.isNotConnectedTo(vChannel)) {
|
||||||
context.reply("The bot isn't in your voice channel");
|
context.reply("The bot isn't in your voice channel");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -36,14 +38,11 @@ public class MusicUtils {
|
|||||||
return true;
|
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 (manager.isCurrentlyPlaying()) {
|
||||||
if (UserFunction.isAdmin(context.getGuildUser()) || manager.getRequesterOfCurrentTrack().getId().equals(context.getGuildUser().getId())) {
|
return manager.getRequesterOfCurrentTrack().equals(member);
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
context.reply("You're not powerful enough, scrub");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in new issue
Block a user