Merge remote-tracking branch 'origin/hax-dev'

This commit is contained in:
Hax 2020-01-07 18:48:07 +01:00
commit 9e13ec1b1c
4 changed files with 26 additions and 11 deletions

View file

@ -196,11 +196,11 @@ public class Rethink {
} }
public String getRulesAEmote(String guild_id) { public String getRulesAEmote(String guild_id) {
return this.get("server", "id", guild_id, "accept_emote").toString().replaceAll("\"", ""); return (String) this.get("server", "id", guild_id, "accept_emote");
} }
public String getRulesDEmote(String guild_id) { public String getRulesDEmote(String guild_id) {
return this.get("server", "id", guild_id, "decline_emote").toString().replaceAll("\"", ""); return (String) this.get("server", "id", guild_id, "decline_emote");
} }
public void setInviteDetection(String guild_id, boolean b) { public void setInviteDetection(String guild_id, boolean b) {

View file

@ -23,11 +23,13 @@ public class QueueCommand implements Command {
} else { } else {
Set<AudioInfo> queue = event.getAudioManager().getTrackManager(event.getGuild()).getQueuedTracks(); Set<AudioInfo> queue = event.getAudioManager().getTrackManager(event.getGuild()).getQueuedTracks();
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
long queuelength = 0;
for (AudioInfo g : queue) { for (AudioInfo g : queue) {
builder.append("**").append(g.getTrack().getInfo().author).append("**: `").append(g.getTrack().getInfo().title).append("` \n"); queuelength = queuelength + g.getTrack().getInfo().length;
builder.append("("+event.getAudioManager().getTimestamp(g.getTrack().getInfo().length)+") **").append(g.getTrack().getInfo().author).append("**: `").append(g.getTrack().getInfo().title).append("` \n");
} }
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO, event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
"commands.music.queue.success.title", "", "commands.music.queue.success.title", "("+String.valueOf(event.getAudioManager().getTimestamp(queuelength))+")",
"commands.music.queue.success.description", builder.toString()) "commands.music.queue.success.description", builder.toString())
.build()).queue(); .build()).queue();
} }

View file

@ -21,20 +21,33 @@ public class RulesListener extends ListenerAdapter {
public void onMessageReactionAdd(MessageReactionAddEvent event) { public void onMessageReactionAdd(MessageReactionAddEvent event) {
if (event.getMessageId().equals(rethink.getRulesMID(event.getGuild().getId())) && !event.getMember().getUser().isBot()) { if (event.getMessageId().equals(rethink.getRulesMID(event.getGuild().getId())) && !event.getMember().getUser().isBot()) {
if (event.getReactionEmote().isEmote()) { if (event.getReactionEmote().isEmote()) {
if (rethink.getRulesAEmote(event.getGuild().getId()).contains(event.getReactionEmote().getId())) { if (rethink.getRulesAEmote(event.getGuild().getId()).equals(event.getReactionEmote().getId())) {
event.getGuild().addRoleToMember(event.getMember(), event.getGuild().getRoleById(rethink.getRulesRID(event.getGuild().getId()))).reason("Accepted rules").queue(); addRole(event);
} else if (rethink.getRulesDEmote(event.getGuild().getId()).contains(event.getReactionEmote().getId())) { } else if (rethink.getRulesDEmote(event.getGuild().getId()).equals(event.getReactionEmote().getId())) {
event.getReaction().removeReaction(event.getUser()).queue(); event.getReaction().removeReaction(event.getUser()).queue();
if (event.getGuild().getSelfMember().canInteract(event.getMember())) { if (event.getGuild().getSelfMember().canInteract(event.getMember())) {
event.getMember().kick().reason("Declined the rules"); event.getMember().kick().reason("Declined the rules");
} }
} }
} else if (event.getReactionEmote().isEmoji()) { } else if (event.getReactionEmote().isEmoji()) {
event.getGuild().addRoleToMember(event.getMember(), event.getGuild().getRoleById(rethink.getRulesRID(event.getGuild().getId()))).reason("Accepted rules").queue(); if (rethink.getRulesAEmote(event.getGuild().getId()).equals(event.getReactionEmote().getEmoji())) {
addRole(event);
} else if (rethink.getRulesDEmote(event.getGuild().getId()).equals(event.getReactionEmote().getEmoji())) {
event.getReaction().removeReaction(event.getUser()).queue();
if (event.getGuild().getSelfMember().canInteract(event.getMember())) {
event.getMember().kick().reason("Declined the rules");
}
}
} }
} }
} }
private void addRole(MessageReactionAddEvent event) {
if (event.getMember().getRoles().contains(event.getGuild().getRoleById(rethink.getRulesRID(event.getGuild().getId())))) {
event.getGuild().removeRoleFromMember(event.getMember(), event.getGuild().getRoleById(rethink.getRulesRID(event.getGuild().getId()))).reason("Accepted rules").queue();
} else event.getGuild().addRoleToMember(event.getMember(), event.getGuild().getRoleById(rethink.getRulesRID(event.getGuild().getId()))).reason("Accepted rules").queue();
}
@Override @Override
public void onMessageReactionRemove(MessageReactionRemoveEvent event) { public void onMessageReactionRemove(MessageReactionRemoveEvent event) {
if (event.getMessageId().equals(rethink.getRulesMID(event.getGuild().getId())) && !event.getMember().getUser().isBot()) { if (event.getMessageId().equals(rethink.getRulesMID(event.getGuild().getId())) && !event.getMember().getUser().isBot()) {

View file

@ -132,8 +132,8 @@ commands.moderation.rules.channel.error.title = Channel not found
commands.moderation.rules.channel.error.description = I can't find the specified channel. Please start the setup again. commands.moderation.rules.channel.error.description = I can't find the specified channel. Please start the setup again.
commands.moderation.rules.rules.title = Rules message commands.moderation.rules.rules.title = Rules message
commands.moderation.rules.rules.description = The channel was successfully set to %extra%. Please send me the rules now. commands.moderation.rules.rules.description = The channel was successfully set to %extra%. Please send me the rules now.
commands.moderation.rules.role.title = Role to assign commands.moderation.rules.role.title = Role to assign/remove
commands.moderation.rules.role.description = The rules were successfully set. Please send me the name of the role which the user receives after he accepted the rules. commands.moderation.rules.role.description = The rules were successfully set. Please send me the name of the role which the user receives/loses after he accepted the rules.
commands.moderation.rules.role.error.title = Role does not exist commands.moderation.rules.role.error.title = Role does not exist
commands.moderation.rules.role.error.description = The specified role does not exist on this guild. commands.moderation.rules.role.error.description = The specified role does not exist on this guild.
commands.moderation.rules.role.permission.error.title = No permission commands.moderation.rules.role.permission.error.title = No permission
@ -205,7 +205,7 @@ commands.music.info.error.description = I am not playing anything at the moment
commands.music.info.help.description = Shows information about the playing song. commands.music.info.help.description = Shows information about the playing song.
commands.music.queue.error.title = No queue commands.music.queue.error.title = No queue
commands.music.queue.error.description = There are no queued songs at the moment commands.music.queue.error.description = There are no queued songs at the moment
commands.music.queue.success.title = Queue commands.music.queue.success.title = Queue %extra%
commands.music.queue.success.description = This is the queue\: \n %extra% commands.music.queue.success.description = This is the queue\: \n %extra%
commands.music.queue.help.description = Shows the music queue. commands.music.queue.help.description = Shows the music queue.
commands.music.skip.success.title = Successfully skipped commands.music.skip.success.title = Successfully skipped