diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index aaeb3973..a15e1a2e 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -3,7 +3,7 @@ name: Hadder on: [push] jobs: - test: + build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 @@ -16,7 +16,7 @@ jobs: deploy: runs-on: ubuntu-latest - needs: test + needs: build if: github.ref == 'refs/heads/master' steps: - uses: actions/checkout@v1 @@ -41,7 +41,7 @@ jobs: username: ${{ secrets.USERNAME }} password: ${{ secrets.PASSWORD }} port: ${{ secrets.PORT }} - script: /home/Bots/deploy.sh + script: /home/Bots/deploy.sh - name: Send Webhook Notification if: always() env: diff --git a/src/main/java/com/bbn/hadder/Hadder.java b/src/main/java/com/bbn/hadder/Hadder.java index eede5b60..ce0ae2cb 100644 --- a/src/main/java/com/bbn/hadder/Hadder.java +++ b/src/main/java/com/bbn/hadder/Hadder.java @@ -70,6 +70,7 @@ private static void startBot() { new RoleCommand(), new RulesCommand(), new FeedbackCommand(), + new AvatarCommand(), new LinkCommand()), config, helpCommand); builder.addEventListeners( @@ -80,7 +81,7 @@ private static void startBot() { new ReadyListener(rethink, config), new LinkListener(rethink), new RulesListener(rethink)); - + try { shardManager = builder.build(); diff --git a/src/main/java/com/bbn/hadder/commands/fun/AvatarCommand.java b/src/main/java/com/bbn/hadder/commands/fun/AvatarCommand.java new file mode 100644 index 00000000..e45b9497 --- /dev/null +++ b/src/main/java/com/bbn/hadder/commands/fun/AvatarCommand.java @@ -0,0 +1,57 @@ +package com.bbn.hadder.commands.fun; + +/* + * @author Skidder / GregTCLTK + */ + +import com.bbn.hadder.commands.Command; +import com.bbn.hadder.commands.CommandEvent; +import com.bbn.hadder.utils.MessageEditor; +import net.dv8tion.jda.api.EmbedBuilder; +import net.dv8tion.jda.api.entities.Member; + +public class AvatarCommand implements Command { + + @Override + public void executed(String[] args, CommandEvent event) { + if (args.length == 0) { + Member member = event.getMember(); + event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.INFO, new EmbedBuilder() + .setTitle("Avatar of " + member.getUser().getAsTag())) + .setImage(member.getUser().getAvatarUrl()) + .setFooter(member.getUser().getAsTag()) + .build()).queue(); + } else if (event.getMessage().getMentionedMembers().size() == 1) { + Member member = event.getMessage().getMentionedMembers().get(0); + event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.INFO, new EmbedBuilder() + .setTitle("Avatar of " + member.getUser().getAsTag())) + .setImage(member.getUser().getAvatarUrl()) + .setFooter(member.getUser().getAsTag()) + .build()).queue(); + } else if (args[0].length() == 18){ + Member member = event.getGuild().getMemberById(args[0]); + event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.INFO, new EmbedBuilder() + .setTitle("Avatar of " + member.getUser().getAsTag())) + .setImage(member.getUser().getAvatarUrl()) + .setFooter(member.getUser().getAsTag()) + .build()).queue(); + } else { + event.getHelpCommand().sendHelp(this , event.getRethink(), event.getAuthor(), event.getTextChannel()); + } + } + + @Override + public String[] labels() { + return new String[]{"avatar"}; + } + + @Override + public String description() { + return "Sends the avatar of the specified member."; + } + + @Override + public String usage() { + return "<@User>/"; + } +} diff --git a/src/main/java/com/bbn/hadder/commands/moderation/BanCommand.java b/src/main/java/com/bbn/hadder/commands/moderation/BanCommand.java index 07405a41..22872bc4 100644 --- a/src/main/java/com/bbn/hadder/commands/moderation/BanCommand.java +++ b/src/main/java/com/bbn/hadder/commands/moderation/BanCommand.java @@ -15,7 +15,7 @@ public class BanCommand implements Command { @Override public void executed(String[] args, CommandEvent event) { - if (event.getGuild().getMemberById(event.getAuthor().getId()).hasPermission(Permission.BAN_MEMBERS) || event.getGuild().getOwner().getId().equals(event.getAuthor().getId())) { + if (event.getGuild().getMemberById(event.getAuthor().getId()).hasPermission(Permission.BAN_MEMBERS) || event.getConfig().getOwners().toString().contains(event.getAuthor().getId())) { if (event.getMessage().getMentionedMembers().size() == 1) { Member victim = event.getMessage().getMentionedMembers().get(0); if (!event.getAuthor().getId().equals(victim.getId())) { @@ -37,8 +37,6 @@ public void executed(String[] args, CommandEvent event) { event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.WARNING, builder).setTitle("Not possible").setDescription("You can't ban yourself.").build()).queue(); } } else if (event.getMessage().getMentionedMembers().size() == 0) { - EmbedBuilder builder = new EmbedBuilder(); - event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.WARNING, builder).setDescription("You have to mention at least one user!").build()).queue(); event.getHelpCommand().sendHelp(this, event.getRethink(), event.getAuthor(), event.getTextChannel()); } else if (event.getMessage().getMentionedMembers().size() > 1) { for (int i = 0; i < event.getMessage().getMentionedMembers().size(); i++) { diff --git a/src/main/java/com/bbn/hadder/commands/moderation/ClearCommand.java b/src/main/java/com/bbn/hadder/commands/moderation/ClearCommand.java index 884c7d8d..98ad5b57 100644 --- a/src/main/java/com/bbn/hadder/commands/moderation/ClearCommand.java +++ b/src/main/java/com/bbn/hadder/commands/moderation/ClearCommand.java @@ -20,7 +20,7 @@ public class ClearCommand implements Command { @Override public void executed(String[] args, CommandEvent event) { if (args.length > 0) { - if (event.getGuild().getMemberById(event.getAuthor().getId()).hasPermission(Permission.MESSAGE_MANAGE) || event.getGuild().getOwnerId().equals(event.getAuthor().getId())) { + if (event.getGuild().getMemberById(event.getAuthor().getId()).hasPermission(Permission.MESSAGE_MANAGE) || event.getConfig().getOwners().toString().contains(event.getAuthor().getId())) { if (event.getGuild().getMemberById(event.getJDA().getSelfUser().getId()).hasPermission(Permission.MESSAGE_MANAGE)) { try { int nbToDelete = Integer.parseInt(args[0]); diff --git a/src/main/java/com/bbn/hadder/commands/moderation/GuildPrefixCommand.java b/src/main/java/com/bbn/hadder/commands/moderation/GuildPrefixCommand.java index 8407394e..5c4e493a 100644 --- a/src/main/java/com/bbn/hadder/commands/moderation/GuildPrefixCommand.java +++ b/src/main/java/com/bbn/hadder/commands/moderation/GuildPrefixCommand.java @@ -10,7 +10,7 @@ public class GuildPrefixCommand implements Command { @Override public void executed(String[] args, CommandEvent event) { - if (event.getGuild().getMemberById(event.getAuthor().getId()).hasPermission(Permission.MANAGE_SERVER) || event.getGuild().getOwnerId().equals(event.getAuthor().getId())) { + if (event.getGuild().getMemberById(event.getAuthor().getId()).hasPermission(Permission.MANAGE_SERVER) || event.getConfig().getOwners().toString().contains(event.getAuthor().getId())) { if (args.length == 1) { if (!args[0].contains("\"")) { diff --git a/src/main/java/com/bbn/hadder/commands/moderation/KickCommand.java b/src/main/java/com/bbn/hadder/commands/moderation/KickCommand.java index 36a76509..7fc6f853 100644 --- a/src/main/java/com/bbn/hadder/commands/moderation/KickCommand.java +++ b/src/main/java/com/bbn/hadder/commands/moderation/KickCommand.java @@ -16,7 +16,7 @@ public class KickCommand implements Command { @Override public void executed(String[] args, CommandEvent event) { - if (event.getGuild().getMemberById(event.getAuthor().getId()).hasPermission(Permission.KICK_MEMBERS) || event.getGuild().getOwnerId().equals(event.getAuthor().getId())) { + if (event.getGuild().getMemberById(event.getAuthor().getId()).hasPermission(Permission.KICK_MEMBERS) || event.getConfig().getOwners().toString().contains(event.getAuthor().getId())) { if (event.getMessage().getMentionedMembers().size() == 1) { Member victim = event.getMessage().getMentionedMembers().get(0); if (!event.getAuthor().getId().equals(victim.getId())) { diff --git a/src/main/java/com/bbn/hadder/commands/moderation/NickCommand.java b/src/main/java/com/bbn/hadder/commands/moderation/NickCommand.java index 4ab91b9d..f8d44118 100644 --- a/src/main/java/com/bbn/hadder/commands/moderation/NickCommand.java +++ b/src/main/java/com/bbn/hadder/commands/moderation/NickCommand.java @@ -15,7 +15,7 @@ public class NickCommand implements Command { @Override public void executed(String[] args, CommandEvent event) { - if (event.getMember().hasPermission(Permission.NICKNAME_MANAGE) || event.getGuild().getOwnerId().equals(event.getMember().getId())) { + if (event.getMember().hasPermission(Permission.NICKNAME_MANAGE) || event.getConfig().getOwners().toString().contains(event.getAuthor().getId())) { if (event.getGuild().getSelfMember().hasPermission(Permission.NICKNAME_MANAGE)) { if (event.getMessage().getMentionedMembers().size() == 1) { if (!event.getMessage().getMentionedMembers().get(0).getId().equals(event.getGuild().getSelfMember().getId())) { diff --git a/src/main/java/com/bbn/hadder/commands/moderation/RoleCommand.java b/src/main/java/com/bbn/hadder/commands/moderation/RoleCommand.java index b0a92be3..797bc120 100644 --- a/src/main/java/com/bbn/hadder/commands/moderation/RoleCommand.java +++ b/src/main/java/com/bbn/hadder/commands/moderation/RoleCommand.java @@ -14,7 +14,7 @@ public class RoleCommand implements Command { public void executed(String[] args, CommandEvent event) { if (args.length > 0) { if (event.getMember().hasPermission(Permission.MANAGE_ROLES)) { - if (event.getGuild().getSelfMember().hasPermission(Permission.MANAGE_ROLES)) { + if (event.getGuild().getSelfMember().hasPermission(Permission.MANAGE_ROLES) || event.getConfig().getOwners().toString().contains(event.getAuthor().getId())) { switch (args[0].toLowerCase()) { case "add": if (event.getMessage().getMentionedMembers().size() > 0 && event.getMessage().getMentionedRoles().size() > 0) { diff --git a/src/main/java/com/bbn/hadder/commands/moderation/RulesCommand.java b/src/main/java/com/bbn/hadder/commands/moderation/RulesCommand.java index 53f263b0..e2e20cca 100644 --- a/src/main/java/com/bbn/hadder/commands/moderation/RulesCommand.java +++ b/src/main/java/com/bbn/hadder/commands/moderation/RulesCommand.java @@ -18,7 +18,7 @@ public class RulesCommand implements Command { @Override public void executed(String[] args, CommandEvent event) { - if (event.getMember().hasPermission(Permission.MANAGE_SERVER)) { + if (event.getMember().hasPermission(Permission.MANAGE_SERVER) || event.getConfig().getOwners().toString().contains(event.getAuthor().getId())) { if (event.getGuild().getSelfMember().hasPermission(Permission.MANAGE_ROLES)) { event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.INFO, new EmbedBuilder() .setTitle("Set up rules")