commit
03c49ccd9f
7 changed files with 113 additions and 19 deletions
|
|
@ -1,2 +1,2 @@
|
||||||
FROM debian:latest
|
FROM debian:buster
|
||||||
WORKDIR /home/Hadder
|
WORKDIR /home/Hadder
|
||||||
|
|
|
||||||
16
pom.xml
16
pom.xml
|
|
@ -19,18 +19,18 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.dv8tion</groupId>
|
<groupId>net.dv8tion</groupId>
|
||||||
<artifactId>JDA</artifactId>
|
<artifactId>JDA</artifactId>
|
||||||
<version>4.1.0_93</version>
|
<version>4.1.0_95</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.json</groupId>
|
<groupId>org.json</groupId>
|
||||||
<artifactId>json</artifactId>
|
<artifactId>json</artifactId>
|
||||||
<version>20190722</version>
|
<version>20190722</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.rethinkdb</groupId>
|
<groupId>com.rethinkdb</groupId>
|
||||||
<artifactId>rethinkdb-driver</artifactId>
|
<artifactId>rethinkdb-driver</artifactId>
|
||||||
<version>2.3.3</version>
|
<version>2.3.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-simple</artifactId>
|
<artifactId>slf4j-simple</artifactId>
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>club.minnced</groupId>
|
<groupId>club.minnced</groupId>
|
||||||
<artifactId>discord-webhooks</artifactId>
|
<artifactId>discord-webhooks</artifactId>
|
||||||
<version>0.1.8</version>
|
<version>0.2.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.kohsuke</groupId>
|
<groupId>org.kohsuke</groupId>
|
||||||
|
|
@ -49,7 +49,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sedmelluq</groupId>
|
<groupId>com.sedmelluq</groupId>
|
||||||
<artifactId>lavaplayer</artifactId>
|
<artifactId>lavaplayer</artifactId>
|
||||||
<version>1.3.32</version>
|
<version>1.3.33</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,8 @@ public class Hadder {
|
||||||
new VolumeCommand(),
|
new VolumeCommand(),
|
||||||
new StopCommand(),
|
new StopCommand(),
|
||||||
new BlacklistCommand(),
|
new BlacklistCommand(),
|
||||||
new PauseCommand()), config, helpCommand);
|
new PauseCommand(),
|
||||||
|
new LoopCommand()), config, helpCommand);
|
||||||
|
|
||||||
builder.addEventListeners(
|
builder.addEventListeners(
|
||||||
new MentionListener(rethink),
|
new MentionListener(rethink),
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,22 @@ public class Rethink {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void update(String table, String value, String what, int whatvalue) {
|
||||||
|
try {
|
||||||
|
r.table(table).get(value).update(r.hashMap(what, whatvalue)).run(conn);
|
||||||
|
} catch (ClassCastException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(String table, String value, String what, boolean whatvalue) {
|
||||||
|
try {
|
||||||
|
r.table(table).get(value).update(r.hashMap(what, whatvalue)).run(conn);
|
||||||
|
} catch (ClassCastException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void insert(String table, Object object) {
|
public void insert(String table, Object object) {
|
||||||
try {
|
try {
|
||||||
r.table(table).insert(object).run(conn);
|
r.table(table).insert(object).run(conn);
|
||||||
|
|
@ -122,7 +138,8 @@ public class Rethink {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertGuild(String id) {
|
public void insertGuild(String id) {
|
||||||
this.insert("server", r.hashMap("id", id)
|
this.insert("server", r
|
||||||
|
.hashMap("id", id)
|
||||||
.with("prefix", "h.")
|
.with("prefix", "h.")
|
||||||
.with("message_id", "")
|
.with("message_id", "")
|
||||||
.with("role_id", "")
|
.with("role_id", "")
|
||||||
|
|
@ -133,7 +150,11 @@ public class Rethink {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertUser(String id) {
|
public void insertUser(String id) {
|
||||||
this.insert("user", r.hashMap("id", id).with("prefix", "h.").with("language", "en").with("blacklisted", "none"));
|
this.insert("user", r
|
||||||
|
.hashMap("id", id)
|
||||||
|
.with("prefix", "h.")
|
||||||
|
.with("language", "en")
|
||||||
|
.with("blacklisted", "none"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlackListed(String id, String commands) {
|
public void setBlackListed(String id, String commands) {
|
||||||
|
|
@ -204,11 +225,7 @@ public class Rethink {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInviteDetection(String guild_id, boolean b) {
|
public void setInviteDetection(String guild_id, boolean b) {
|
||||||
try {
|
this.update("server", guild_id, "invite_detect", b);
|
||||||
r.table("server").get(guild_id).update(r.hashMap("invite_detect", b)).run(conn);
|
|
||||||
} catch (ClassCastException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getInviteDetection(String guild_id) {
|
public Boolean getInviteDetection(String guild_id) {
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ public class TrackManager extends AudioEventAdapter {
|
||||||
|
|
||||||
private final AudioPlayer player;
|
private final AudioPlayer player;
|
||||||
private final Queue<AudioInfo> queue;
|
private final Queue<AudioInfo> queue;
|
||||||
|
private boolean loop = false;
|
||||||
|
|
||||||
public TrackManager(AudioPlayer player) {
|
public TrackManager(AudioPlayer player) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|
@ -47,8 +48,10 @@ public class TrackManager extends AudioEventAdapter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) {
|
public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) {
|
||||||
Guild g = queue.poll().getAuthor().getGuild();
|
Guild g = queue.element().getAuthor().getGuild();
|
||||||
if (queue.isEmpty()) {
|
if (loop) {
|
||||||
|
player.playTrack(track.makeClone());
|
||||||
|
} else if (queue.isEmpty()) {
|
||||||
g.getAudioManager().closeAudioConnection();
|
g.getAudioManager().closeAudioConnection();
|
||||||
} else {
|
} else {
|
||||||
player.playTrack(queue.element().getTrack());
|
player.playTrack(queue.element().getTrack());
|
||||||
|
|
@ -67,6 +70,16 @@ public class TrackManager extends AudioEventAdapter {
|
||||||
queue.remove(entry);
|
queue.remove(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isLoop()
|
||||||
|
{
|
||||||
|
return loop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLoop(boolean repeating)
|
||||||
|
{
|
||||||
|
this.loop = repeating;
|
||||||
|
}
|
||||||
|
|
||||||
public AudioInfo getTrackInfo(AudioTrack track) {
|
public AudioInfo getTrackInfo(AudioTrack track) {
|
||||||
return queue.stream().filter(audioInfo -> audioInfo.getTrack().equals(track)).findFirst().orElse(null);
|
return queue.stream().filter(audioInfo -> audioInfo.getTrack().equals(track)).findFirst().orElse(null);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
56
src/main/java/com/bbn/hadder/commands/music/LoopCommand.java
Normal file
56
src/main/java/com/bbn/hadder/commands/music/LoopCommand.java
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
package com.bbn.hadder.commands.music;
|
||||||
|
|
||||||
|
import com.bbn.hadder.commands.Command;
|
||||||
|
import com.bbn.hadder.commands.CommandEvent;
|
||||||
|
import com.bbn.hadder.utils.MessageEditor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Skidder / GregTCLTK
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class LoopCommand implements Command {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void executed(String[] args, CommandEvent event) {
|
||||||
|
if (event.getAudioManager().hasPlayer(event.getGuild()) && event.getAudioManager().getPlayer(event.getGuild()).getPlayingTrack() != null) {
|
||||||
|
if (event.getMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().getChannel().equals(event.getMember().getVoiceState().getChannel())) {
|
||||||
|
if (event.getAudioManager().getTrackManager(event.getGuild()).isLoop()) {
|
||||||
|
event.getAudioManager().getTrackManager(event.getGuild()).setLoop(false);
|
||||||
|
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO, "commands.music.loop.success.unloop.title", "commands.music.loop.success.unloop.description").build()).queue();
|
||||||
|
} else {
|
||||||
|
event.getAudioManager().getTrackManager(event.getGuild()).setLoop(true);
|
||||||
|
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO, "commands.music.loop.success.loop.title", "commands.music.loop.success.loop.description").build()).queue();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
|
||||||
|
"commands.music.loop.error.connected.title",
|
||||||
|
"commands.music.loop.error.connected.description")
|
||||||
|
.build()).queue();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
|
||||||
|
"commands.music.info.error.title",
|
||||||
|
"commands.music.info.error.description").build()).queue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] labels() {
|
||||||
|
return new String[]{"loop", "repeat"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String description() {
|
||||||
|
return "commands.music.loop.help.description";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String usage() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String example() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -237,6 +237,13 @@ commands.music.pause.error.paused.description = The song is already paused.
|
||||||
commands.music.pause.error.connected.title = No channel
|
commands.music.pause.error.connected.title = No channel
|
||||||
commands.music.pause.error.connected.description = You have to be in the same voice channel as the bot to pause the song.
|
commands.music.pause.error.connected.description = You have to be in the same voice channel as the bot to pause the song.
|
||||||
commands.music.pause.help.description = Pause the playing song.
|
commands.music.pause.help.description = Pause the playing song.
|
||||||
|
commands.music.loop.success.loop.title = Successfully activated
|
||||||
|
commands.music.loop.success.loop.description = I will now repeat the currently played song.
|
||||||
|
commands.music.loop.success.unloop.title = Successfully deactivated
|
||||||
|
commands.music.loop.success.unloop.description = I will no longer repeat the currently played song.
|
||||||
|
commands.music.loop.error.connected.title = No channel
|
||||||
|
commands.music.loop.error.connected.description = You have to be in the same voice channel as the bot to set the repeat status.
|
||||||
|
commands.music.loop.help.description = Repeats a song/queue.
|
||||||
|
|
||||||
commands.nsfw.gif.error.title = GIF not showing? Click here
|
commands.nsfw.gif.error.title = GIF not showing? Click here
|
||||||
commands.nsfw.img.error.title = Image not showing? Click here
|
commands.nsfw.img.error.title = Image not showing? Click here
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue