Music Bot 😏
This commit is contained in:
parent
c016d1246d
commit
9bc4d897a5
4 changed files with 91 additions and 1 deletions
5
pom.xml
5
pom.xml
|
|
@ -62,6 +62,11 @@
|
|||
<artifactId>github-api</artifactId>
|
||||
<version>1.99</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sedmelluq</groupId>
|
||||
<artifactId>lavaplayer</artifactId>
|
||||
<version>1.3.27</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
|||
|
|
@ -7,9 +7,11 @@ import com.bbn.hadder.commands.nsfw.*;
|
|||
import com.bbn.hadder.commands.owner.*;
|
||||
import com.bbn.hadder.commands.fun.*;
|
||||
import com.bbn.hadder.commands.settings.*;
|
||||
import com.bbn.hadder.commands.music.*;
|
||||
import com.bbn.hadder.core.*;
|
||||
import com.bbn.hadder.listener.*;
|
||||
import net.dv8tion.jda.api.entities.Activity;
|
||||
import net.dv8tion.jda.api.managers.AudioManager;
|
||||
import net.dv8tion.jda.api.sharding.DefaultShardManagerBuilder;
|
||||
import net.dv8tion.jda.api.sharding.ShardManager;
|
||||
|
||||
|
|
@ -18,7 +20,8 @@ import java.util.List;
|
|||
|
||||
public class Hadder {
|
||||
|
||||
public static ShardManager shardManager;
|
||||
public static ShardManager shardManager;
|
||||
public static AudioManager audioManager;
|
||||
|
||||
public static void main(String[] args) {
|
||||
startBot();
|
||||
|
|
@ -72,6 +75,7 @@ public class Hadder {
|
|||
new FeedbackCommand(),
|
||||
new AvatarCommand(),
|
||||
new EvalCommand(),
|
||||
new JoinCommand(),
|
||||
new LinkCommand()), config, helpCommand);
|
||||
|
||||
builder.addEventListeners(
|
||||
|
|
|
|||
56
src/main/java/com/bbn/hadder/commands/music/JoinCommand.java
Normal file
56
src/main/java/com/bbn/hadder/commands/music/JoinCommand.java
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
package com.bbn.hadder.commands.music;
|
||||
|
||||
/*
|
||||
* @author Skidder / GregTCLTK
|
||||
*/
|
||||
|
||||
import com.bbn.hadder.commands.Command;
|
||||
import com.bbn.hadder.commands.CommandEvent;
|
||||
import com.bbn.hadder.utils.AudioPlayerSendHandler;
|
||||
import com.bbn.hadder.utils.MessageEditor;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.VoiceChannel;
|
||||
import net.dv8tion.jda.api.managers.AudioManager;
|
||||
|
||||
|
||||
public class JoinCommand implements Command {
|
||||
|
||||
@Override
|
||||
public void executed(String[] args, CommandEvent event) {
|
||||
if (event.getMember().getVoiceState().inVoiceChannel()) {
|
||||
AudioManager audioManager = event.getGuild().getAudioManager();
|
||||
if(!audioManager.isAttemptingToConnect()) {
|
||||
VoiceChannel vc = event.getMember().getVoiceState().getChannel();
|
||||
audioManager.setSendingHandler(new AudioPlayerSendHandler());
|
||||
audioManager.openAudioConnection(vc);
|
||||
} else {
|
||||
EmbedBuilder builder = new EmbedBuilder();
|
||||
event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.WARNING, builder)
|
||||
.setTitle("Already trying to connect")
|
||||
.setDescription("Hadder is already trying to connect. Please wait a moment.")
|
||||
.build()).queue();
|
||||
}
|
||||
} else {
|
||||
EmbedBuilder builder = new EmbedBuilder();
|
||||
event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.WARNING, builder)
|
||||
.setTitle("No Voice Channel")
|
||||
.setDescription("You aren't in a Voice Channel.")
|
||||
.build()).queue();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] labels() {
|
||||
return new String[]{"join"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return "Joins your voice channel";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String usage() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.bbn.hadder.utils;
|
||||
|
||||
/*
|
||||
* @author Skidder / GregTCLTK
|
||||
*/
|
||||
|
||||
import net.dv8tion.jda.api.audio.AudioSendHandler;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class AudioPlayerSendHandler implements AudioSendHandler {
|
||||
|
||||
@Override
|
||||
public boolean canProvide() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ByteBuffer provide20MsAudio() {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue