Skip to content
This repository has been archived by the owner on Mar 5, 2023. It is now read-only.

Commit

Permalink
Merge pull request #95 from BigBotNetwork/greg-dev
Browse files Browse the repository at this point in the history
Avatar Command
  • Loading branch information
greg6775 authored Nov 23, 2019
2 parents 9ab794d + df8e0dc commit f51f470
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 13 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Hadder
on: [push]

jobs:
test:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
Expand All @@ -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
Expand All @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/bbn/hadder/Hadder.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ private static void startBot() {
new RoleCommand(),
new RulesCommand(),
new FeedbackCommand(),
new AvatarCommand(),
new LinkCommand()), config, helpCommand);

builder.addEventListeners(
Expand All @@ -80,7 +81,7 @@ private static void startBot() {
new ReadyListener(rethink, config),
new LinkListener(rethink),
new RulesListener(rethink));


try {
shardManager = builder.build();
Expand Down
57 changes: 57 additions & 0 deletions src/main/java/com/bbn/hadder/commands/fun/AvatarCommand.java
Original file line number Diff line number Diff line change
@@ -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>/<ID>";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
Expand All @@ -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++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("\"")) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit f51f470

Please sign in to comment.