Merge branch 'hax-dev'

This commit is contained in:
Schlauer-Hax 2020-03-13 21:44:39 +01:00
commit 7cc51d680e
5 changed files with 80 additions and 18 deletions

View file

@ -66,7 +66,7 @@
<dependency> <dependency>
<groupId>net.dv8tion</groupId> <groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId> <artifactId>JDA</artifactId>
<version>4.1.1_110</version> <version>4.1.1_113</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.json</groupId> <groupId>org.json</groupId>
@ -142,7 +142,7 @@
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-site-plugin</artifactId> <artifactId>maven-site-plugin</artifactId>
<version>3.8.2</version> <version>3.9.0</version>
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-project-info-reports-plugin</artifactId> <artifactId>maven-project-info-reports-plugin</artifactId>

View file

@ -126,7 +126,8 @@ public class Hadder {
new EchoCommand(), new EchoCommand(),
new ServerStatsCommand(), new ServerStatsCommand(),
new ProfileCommand(), new ProfileCommand(),
new CodeCommand()), config, helpCommand); new CodeCommand(),
new MoveAllCommand()), config, helpCommand);
builder.addEventListeners( builder.addEventListeners(
new MentionListener(rethink), new MentionListener(rethink),

View file

@ -0,0 +1,50 @@
/*
* @author Hax / Hax6775 / Schlauer_Hax
*/
package com.bbn.hadder.commands.misc;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.core.Perm;
import com.bbn.hadder.core.Perms;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.Member;
import java.util.ArrayList;
import java.util.Objects;
public class MoveAllCommand implements Command {
@Perms(Perm.VOICE_MOVE_OTHERS)
@Override
public void executed(String[] args, CommandEvent e) {
if (args.length == 2) {
Objects.requireNonNull(e.getGuild().getVoiceChannelById(args[0])).getMembers().forEach(
member -> e.getGuild().moveVoiceMember(member, e.getGuild().getVoiceChannelById(args[1])).queue()
);
} else {
e.getHelpCommand().sendHelp(this, e);
}
}
@Override
public String[] labels() {
return new String[]{"moveall", "move-all"};
}
@Override
public String description() {
return "Moves All users in channel1 to channel2";
}
@Override
public String usage() {
return "[channel1] [channel2]";
}
@Override
public String example() {
return "452806287307046923 452858405212782623";
}
}

View file

@ -74,6 +74,12 @@ public enum Perm {
public boolean check(CommandEvent e) { public boolean check(CommandEvent e) {
return e.getMember().hasPermission(Permission.MANAGE_WEBHOOKS) || e.getConfig().getOwners().contains(e.getAuthor().getIdLong()); return e.getMember().hasPermission(Permission.MANAGE_WEBHOOKS) || e.getConfig().getOwners().contains(e.getAuthor().getIdLong());
} }
},
VOICE_MOVE_OTHERS {
@Override
public boolean check(CommandEvent e) {
return e.getMember().hasPermission(Permission.VOICE_MOVE_OTHERS) || e.getConfig().getOwners().contains(e.getAuthor().getIdLong());
}
}; };
public abstract boolean check(CommandEvent e); public abstract boolean check(CommandEvent e);

View file

@ -25,6 +25,7 @@ import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.ChannelType; import net.dv8tion.jda.api.entities.ChannelType;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.exceptions.ErrorResponseException;
import net.dv8tion.jda.api.hooks.ListenerAdapter; import net.dv8tion.jda.api.hooks.ListenerAdapter;
import java.awt.*; import java.awt.*;
@ -64,6 +65,7 @@ public class CommandListener extends ListenerAdapter {
} }
} }
} else { } else {
try {
e.getAuthor().openPrivateChannel().complete().sendMessage(new EmbedBuilder() e.getAuthor().openPrivateChannel().complete().sendMessage(new EmbedBuilder()
.setTitle("No permission") .setTitle("No permission")
.setDescription("I need the `MESSAGE EMBED LINKS` permission in order to work!") .setDescription("I need the `MESSAGE EMBED LINKS` permission in order to work!")
@ -71,6 +73,9 @@ public class CommandListener extends ListenerAdapter {
.setFooter("Hadder", "https://bigbotnetwork.com/images/Hadder.png") .setFooter("Hadder", "https://bigbotnetwork.com/images/Hadder.png")
.setTimestamp(Instant.now()) .setTimestamp(Instant.now())
.build()).queue(); .build()).queue();
} catch (ErrorResponseException ex) {
e.getTextChannel().sendMessage("I need the `MESSAGE EMBED LINKS` permission in order to work!").queue();
}
} }
} else { } else {
e.getAuthor().openPrivateChannel().complete().sendMessage(new EmbedBuilder() e.getAuthor().openPrivateChannel().complete().sendMessage(new EmbedBuilder()