Basic permission for music commands
This commit is contained in:
1 parent
4036a7ddea
commit
9aa8f3da75
12 files changed
+61
-72
No files matched your search
@@ -1,5 +1,8 @@
|
||||
package netneutrality.command;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
|
||||
public abstract class AbstractCommand implements ICommand {
|
||||
|
||||
/**
|
||||
@@ -32,4 +35,8 @@ public abstract class AbstractCommand implements ICommand {
|
||||
|
||||
public abstract CommandType getType();
|
||||
|
||||
@Override
|
||||
public boolean canBeExecutedBy(Guild guild, Member member) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package netneutrality.command;/*
|
||||
* Copyright (c) anthorob
|
||||
*
|
||||
* https://xtremcommunity.com/
|
||||
* https://discord.gg/CdFcyQ
|
||||
*/
|
||||
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
import netneutrality.GuildManager;
|
||||
import netneutrality.MusicBot;
|
||||
|
||||
public abstract class AbstractMusicCommand extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public CommandType getType() {
|
||||
return CommandType.MUSIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeExecutedBy(Guild guild, Member member) {
|
||||
String roleDb = GuildManager.getManager(guild).getSetting("music_role");
|
||||
|
||||
if (!roleDb.isEmpty()) {
|
||||
Role neededRole = MusicBot.getJDA().getRoleById(roleDb);
|
||||
return member.getRoles().contains(neededRole);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@ package netneutrality.command;/*
|
||||
* https://discord.gg/CdFcyQ
|
||||
*/
|
||||
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public interface ICommand {
|
||||
@@ -13,4 +15,6 @@ public interface ICommand {
|
||||
* @param args the arguments to the command
|
||||
*/
|
||||
String execute(MessageReceivedEvent event, String[] args);
|
||||
|
||||
boolean canBeExecutedBy(Guild guild, Member member);
|
||||
}
|
||||
@@ -9,12 +9,11 @@ package netneutrality.command.music;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.VoiceChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import netneutrality.command.AbstractCommand;
|
||||
import netneutrality.command.CommandType;
|
||||
import netneutrality.command.AbstractMusicCommand;
|
||||
import netneutrality.command.Visibility;
|
||||
import netneutrality.music.MusicManager;
|
||||
|
||||
public class BitconnectCommand extends AbstractCommand {
|
||||
public class BitconnectCommand extends AbstractMusicCommand {
|
||||
@Override
|
||||
public boolean needAdmin() {
|
||||
return true;
|
||||
@@ -50,11 +49,6 @@ public class BitconnectCommand extends AbstractCommand {
|
||||
return Visibility.CHANNEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandType getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String execute(MessageReceivedEvent event, String[] args) {
|
||||
Member member = event.getMember();
|
||||
|
||||
@@ -9,12 +9,11 @@ package netneutrality.command.music;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.VoiceChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import netneutrality.command.AbstractCommand;
|
||||
import netneutrality.command.CommandType;
|
||||
import netneutrality.command.AbstractMusicCommand;
|
||||
import netneutrality.command.Visibility;
|
||||
import netneutrality.music.MusicManager;
|
||||
|
||||
public class DeleteQueueCommand extends AbstractCommand {
|
||||
public class DeleteQueueCommand extends AbstractMusicCommand {
|
||||
@Override
|
||||
public boolean needAdmin() {
|
||||
return true;
|
||||
@@ -50,11 +49,6 @@ public class DeleteQueueCommand extends AbstractCommand {
|
||||
return Visibility.CHANNEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandType getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String execute(MessageReceivedEvent event, String[] args) {
|
||||
Member member = event.getMember();
|
||||
|
||||
@@ -9,12 +9,11 @@ package netneutrality.command.music;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.VoiceChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import netneutrality.command.AbstractCommand;
|
||||
import netneutrality.command.CommandType;
|
||||
import netneutrality.command.AbstractMusicCommand;
|
||||
import netneutrality.command.Visibility;
|
||||
import netneutrality.music.MusicManager;
|
||||
|
||||
public class JoinCommand extends AbstractCommand {
|
||||
public class JoinCommand extends AbstractMusicCommand {
|
||||
@Override
|
||||
public boolean needAdmin() {
|
||||
return true;
|
||||
@@ -50,11 +49,6 @@ public class JoinCommand extends AbstractCommand {
|
||||
return Visibility.CHANNEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandType getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String execute(MessageReceivedEvent event, String[] args) {
|
||||
Member member = event.getMember();
|
||||
|
||||
@@ -9,12 +9,11 @@ package netneutrality.command.music;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.VoiceChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import netneutrality.command.AbstractCommand;
|
||||
import netneutrality.command.CommandType;
|
||||
import netneutrality.command.AbstractMusicCommand;
|
||||
import netneutrality.command.Visibility;
|
||||
import netneutrality.music.MusicManager;
|
||||
|
||||
public class LeaveCommand extends AbstractCommand {
|
||||
public class LeaveCommand extends AbstractMusicCommand {
|
||||
@Override
|
||||
public boolean needAdmin() {
|
||||
return true;
|
||||
@@ -50,11 +49,6 @@ public class LeaveCommand extends AbstractCommand {
|
||||
return Visibility.CHANNEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandType getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String execute(MessageReceivedEvent event, String[] args) {
|
||||
Member member = event.getMember();
|
||||
|
||||
@@ -9,12 +9,11 @@ package netneutrality.command.music;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.VoiceChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import netneutrality.command.AbstractCommand;
|
||||
import netneutrality.command.CommandType;
|
||||
import netneutrality.command.AbstractMusicCommand;
|
||||
import netneutrality.command.Visibility;
|
||||
import netneutrality.music.MusicManager;
|
||||
|
||||
public class PlayCommand extends AbstractCommand {
|
||||
public class PlayCommand extends AbstractMusicCommand {
|
||||
@Override
|
||||
public boolean needAdmin() {
|
||||
return true;
|
||||
@@ -50,11 +49,6 @@ public class PlayCommand extends AbstractCommand {
|
||||
return Visibility.CHANNEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandType getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String execute(MessageReceivedEvent event, String[] args) {
|
||||
Member member = event.getMember();
|
||||
|
||||
@@ -9,12 +9,11 @@ package netneutrality.command.music;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.VoiceChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import netneutrality.command.AbstractCommand;
|
||||
import netneutrality.command.CommandType;
|
||||
import netneutrality.command.AbstractMusicCommand;
|
||||
import netneutrality.command.Visibility;
|
||||
import netneutrality.music.MusicManager;
|
||||
|
||||
public class SkipCommand extends AbstractCommand {
|
||||
public class SkipCommand extends AbstractMusicCommand {
|
||||
@Override
|
||||
public boolean needAdmin() {
|
||||
return true;
|
||||
@@ -50,11 +49,6 @@ public class SkipCommand extends AbstractCommand {
|
||||
return Visibility.CHANNEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandType getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String execute(MessageReceivedEvent event, String[] args) {
|
||||
Member member = event.getMember();
|
||||
|
||||
@@ -9,12 +9,11 @@ package netneutrality.command.music;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.VoiceChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import netneutrality.command.AbstractCommand;
|
||||
import netneutrality.command.CommandType;
|
||||
import netneutrality.command.AbstractMusicCommand;
|
||||
import netneutrality.command.Visibility;
|
||||
import netneutrality.music.MusicManager;
|
||||
|
||||
public class StopCommand extends AbstractCommand {
|
||||
public class StopCommand extends AbstractMusicCommand {
|
||||
@Override
|
||||
public boolean needAdmin() {
|
||||
return true;
|
||||
@@ -50,11 +49,6 @@ public class StopCommand extends AbstractCommand {
|
||||
return Visibility.CHANNEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandType getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String execute(MessageReceivedEvent event, String[] args) {
|
||||
Member member = event.getMember();
|
||||
|
||||
@@ -9,12 +9,11 @@ package netneutrality.command.music;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.VoiceChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import netneutrality.command.AbstractCommand;
|
||||
import netneutrality.command.CommandType;
|
||||
import netneutrality.command.AbstractMusicCommand;
|
||||
import netneutrality.command.Visibility;
|
||||
import netneutrality.music.MusicManager;
|
||||
|
||||
public class VolumeCommand extends AbstractCommand {
|
||||
public class VolumeCommand extends AbstractMusicCommand {
|
||||
@Override
|
||||
public boolean needAdmin() {
|
||||
return true;
|
||||
@@ -50,11 +49,6 @@ public class VolumeCommand extends AbstractCommand {
|
||||
return Visibility.CHANNEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandType getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String execute(MessageReceivedEvent event, String[] args) {
|
||||
Member member = event.getMember();
|
||||
|
||||
@@ -6,11 +6,10 @@ package netneutrality.command.music;/*
|
||||
*/
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import netneutrality.command.AbstractCommand;
|
||||
import netneutrality.command.CommandType;
|
||||
import netneutrality.command.AbstractMusicCommand;
|
||||
import netneutrality.command.Visibility;
|
||||
|
||||
public class VoteSkipCommand extends AbstractCommand {
|
||||
public class VoteSkipCommand extends AbstractMusicCommand {
|
||||
@Override
|
||||
public boolean needAdmin() {
|
||||
return false;
|
||||
@@ -46,11 +45,6 @@ public class VoteSkipCommand extends AbstractCommand {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandType getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String execute(MessageReceivedEvent event, String[] args) {
|
||||
return null;
|
||||
|
||||
Reference in new issue
Block a user