Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CommandHandler {
- @EventSubscriber
- public void onMessage(MessageReceivedEvent e){
- IMessage msg = e.getMessage();
- IUser user = msg.getAuthor();
- if(user.isBot()) return;
- IChannel ch = msg.getChannel();
- IGuild g = msg.getGuild();
- String[] split = msg.getContent().split(" ");
- if(split.length >= 1 && split[0].startsWith(Start.PREFIX)){
- String cmd = split[0].replaceFirst(Start.PREFIX, "");
- cmd.toLowerCase();
- String[] args = split.length >= 2 ? Arrays.copyOfRange(split, 1, split.length) : new String[0];
- switch(cmd){
- case "hi":
- case "hello":
- ch.sendMessage("Hello! " + user.mention());
- break;
- case "help":
- ch.sendMessage("I'll save you, "+ user.mention()+ "!");
- user.getOrCreatePMChannel().sendMessage("All commands starts with "
- +Start.PREFIX
- +"\n"
- + "```Help - Sends you this message\n"
- + "Hello/Hi - Sends message: Hello!, "+user+"\n"
- + "Hail - Sends a message :)\n"
- + "join - Makes me join your voice channel\n"
- + "leave - Makes me leave the voice channel\n"
- + "play URL - Play the requested URL\n"
- + "skip - Skips the current song\n"
- + "vol - Set the volume of the current song between 0 and 1\n```");
- break;
- case "join":
- BotAudioPlayer.join(ch, user);
- ch.sendMessage("On my way!");
- ch.sendMessage("Joining channel "+ch.getName());
- break;
- case "leave":
- BotAudioPlayer.leave(ch);
- ch.sendMessage("Okay :(");
- break;
- case "play":
- BotAudioPlayer.join(ch, user);
- BotAudioPlayer.loadAndPlay(ch, split[1]);
- break;
- case "skip":
- BotAudioPlayer.skipTrack(msg.getChannel());
- break;
- case "vol":
- BotAudioPlayer.vol(ch, split[1]);
- BotAudioPlayer.sendMessageToChannel(ch,"Volume set to :" + split[0]);
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement