From 6b0ab6ed3770055ed46888ccdc0b5eee134f2758 Mon Sep 17 00:00:00 2001 From: ConCode Date: Tue, 16 Feb 2021 13:30:39 +0100 Subject: [PATCH] Everybody needs a hug :) --- .../nilstrieb/commands/fun/HugCommand.java | 33 +++++++++++++++++++ .../java/com/github/nilstrieb/core/Main.java | 7 ++-- 2 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/github/nilstrieb/commands/fun/HugCommand.java diff --git a/src/main/java/com/github/nilstrieb/commands/fun/HugCommand.java b/src/main/java/com/github/nilstrieb/commands/fun/HugCommand.java new file mode 100644 index 0000000..7063021 --- /dev/null +++ b/src/main/java/com/github/nilstrieb/commands/fun/HugCommand.java @@ -0,0 +1,33 @@ +package com.github.nilstrieb.commands.fun; + +import com.github.nilstrieb.cofig.Config; +import com.github.nilstrieb.core.command.Command; +import net.dv8tion.jda.api.EmbedBuilder; +import net.dv8tion.jda.api.entities.Member; + +import java.util.List; +import java.util.Objects; + +public class HugCommand extends Command { + + public HugCommand() { + super("hug", "Get and give some hugs :)", "hug @Clyde#0000", ""); + } + + @Override + public void called(String args) { + Member member = event.getMember(); + List mentions = event.getMessage().getMentionedMembers(); + EmbedBuilder builder = Config.getDefaultEmbed(); + + if (mentions.size() == 1 && !mentions.get(0).getId().equalsIgnoreCase(Objects.requireNonNull(member).getId())) { + member = mentions.get(0); + builder.setDescription(mentions.get(0).getEffectiveName() +" is giving " + member.getEffectiveName() + " a hug! :)"); + } else { + builder.setDescription("Get a hug, bro <3"); + } + + builder.setImage("https://namespace.media/img/images/2021/02/15/7f76102bedf6de4e34065709d16a9ef8.gif"); + reply(builder.build()); + } +} diff --git a/src/main/java/com/github/nilstrieb/core/Main.java b/src/main/java/com/github/nilstrieb/core/Main.java index f04cef2..d896915 100644 --- a/src/main/java/com/github/nilstrieb/core/Main.java +++ b/src/main/java/com/github/nilstrieb/core/Main.java @@ -1,11 +1,7 @@ package com.github.nilstrieb.core; import com.github.nilstrieb.cofig.Config; -import com.github.nilstrieb.cofig.Secrets; -import com.github.nilstrieb.commands.fun.DepartureCommand; -import com.github.nilstrieb.commands.fun.FightCommand; -import com.github.nilstrieb.commands.fun.QuoteCommand; -import com.github.nilstrieb.commands.fun.SayCommand; +import com.github.nilstrieb.commands.fun.*; import com.github.nilstrieb.commands.fun.trivia.TriviaCommand; import com.github.nilstrieb.commands.info.InviteCommand; import com.github.nilstrieb.commands.info.EvalCommand; @@ -84,5 +80,6 @@ public class Main { new TriviaCommand(); new EmoteAddCommand(); new FightCommand(); + new HugCommand(); } }