-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #500 from beanbeanjuice/integration
v3.1.0 Integration
- Loading branch information
Showing
36 changed files
with
1,287 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
src/main/java/com/beanbeanjuice/command/fun/BannerCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
package com.beanbeanjuice.command.fun; | ||
|
||
import com.beanbeanjuice.utility.command.CommandCategory; | ||
import com.beanbeanjuice.utility.command.ICommand; | ||
import com.beanbeanjuice.utility.helper.Helper; | ||
import net.dv8tion.jda.api.EmbedBuilder; | ||
import net.dv8tion.jda.api.entities.MessageEmbed; | ||
import net.dv8tion.jda.api.entities.User; | ||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; | ||
import net.dv8tion.jda.api.interactions.commands.OptionType; | ||
import net.dv8tion.jda.api.interactions.commands.build.OptionData; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import javax.imageio.ImageIO; | ||
import java.awt.*; | ||
import java.awt.image.BufferedImage; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
|
||
/** | ||
* An {@link ICommand} used to get the banner of a {@link net.dv8tion.jda.api.entities.User User}. | ||
* | ||
* @author beanbeanjuice | ||
* @since v3.1.0 | ||
*/ | ||
public class BannerCommand implements ICommand { | ||
|
||
private final String filename = "banner_image.jpg"; | ||
|
||
@Override | ||
public void handle(@NotNull SlashCommandInteractionEvent event) { | ||
User user = event.getUser(); | ||
if (event.getOption("user") != null) | ||
user = event.getOption("user").getAsUser(); | ||
|
||
String username = user.getName(); | ||
String avatarURL = user.getAvatarUrl(); | ||
|
||
user.retrieveProfile().queue( | ||
(profile) -> { | ||
if (profile.getBannerUrl() != null) { | ||
event.getHook().sendMessageEmbeds(bannerEmbed(username, avatarURL, profile)).queue(); | ||
} else { | ||
File file = new File(filename); | ||
event.getHook().sendMessageEmbeds(bannerEmbed(username, avatarURL, profile)) | ||
.addFile(file, filename).queue((message) -> { | ||
file.delete(); // Finally delete the file once the message is sent. | ||
}); | ||
} | ||
}, | ||
(failure) -> { | ||
event.getHook().sendMessageEmbeds(Helper.errorEmbed( | ||
"Error Getting Banner", | ||
"There was an error getting " + username + "'s banner. " + | ||
"Please try again later." | ||
)).queue(); | ||
}); | ||
} | ||
|
||
@NotNull | ||
private MessageEmbed bannerEmbed(@NotNull String username, @NotNull String avatarURL, @NotNull User.Profile profile) { | ||
EmbedBuilder embedBuilder = new EmbedBuilder() | ||
.setColor(profile.getAccentColor()) | ||
.setAuthor(username + "'s Banner", null, avatarURL); | ||
|
||
if (profile.getBannerUrl() != null) { | ||
embedBuilder.setImage(profile.getBannerUrl() + "?size=600"); | ||
} else { | ||
int width = 600, height = 240; | ||
|
||
// Creating the image in code. | ||
BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); | ||
Graphics2D graphics2D = bufferedImage.createGraphics(); | ||
|
||
// Setting the colour and filling it. | ||
graphics2D.setColor(profile.getAccentColor()); | ||
graphics2D.fillRect(0, 0, width, height); | ||
|
||
// Clearing up resources. | ||
graphics2D.dispose(); | ||
|
||
// Creating the file, and writing the file. | ||
File file = new File(filename); | ||
try { | ||
ImageIO.write(bufferedImage, "jpg", file); | ||
embedBuilder.setImage("attachment://" + filename); | ||
} catch (IOException ignored) { } | ||
} | ||
|
||
return embedBuilder.build(); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public String getDescription() { | ||
return "Get your or another user's banner!"; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public String exampleUsage() { | ||
return "`/banner` or `/banner @beanbeanjuice`"; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public ArrayList<OptionData> getOptions() { | ||
ArrayList<OptionData> options = new ArrayList<>(); | ||
options.add(new OptionData(OptionType.USER, "user", "The user you want to get the banner of.", false)); | ||
return options; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public CommandCategory getCategoryType() { | ||
return CommandCategory.FUN; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public Boolean allowDM() { | ||
return true; | ||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/com/beanbeanjuice/command/fun/SnipeCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.beanbeanjuice.command.fun; | ||
|
||
import com.beanbeanjuice.utility.command.CommandCategory; | ||
import com.beanbeanjuice.utility.command.ICommand; | ||
import com.beanbeanjuice.utility.handler.snipe.SnipeHandler; | ||
import com.beanbeanjuice.utility.helper.Helper; | ||
import net.dv8tion.jda.api.entities.MessageEmbed; | ||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* An {@link ICommand} to use with the {@link com.beanbeanjuice.utility.handler.snipe.SnipeHandler SnipeHandler}. | ||
* | ||
* @author beanbeanjuice | ||
* @since v3.1.0 | ||
*/ | ||
public class SnipeCommand implements ICommand { | ||
|
||
@Override | ||
public void handle(@NotNull SlashCommandInteractionEvent event) { | ||
MessageEmbed embed = SnipeHandler.getLatestSnipe(event.getTextChannel().getId()); | ||
|
||
if (embed == null) { | ||
event.getHook().sendMessageEmbeds(Helper.errorEmbed( | ||
"No Snipe", | ||
"There was nothing to snipe!" | ||
)).queue(); | ||
return; | ||
} | ||
|
||
event.getHook().sendMessageEmbeds(embed).queue(); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public String getDescription() { | ||
return "Snipe a message in this channel!"; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public String exampleUsage() { | ||
return "`/snipe`"; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public CommandCategory getCategoryType() { | ||
return CommandCategory.FUN; | ||
} | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
src/main/java/com/beanbeanjuice/command/fun/rate/RateCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.beanbeanjuice.command.fun.rate; | ||
|
||
import com.beanbeanjuice.utility.command.CommandCategory; | ||
import com.beanbeanjuice.utility.command.ICommand; | ||
import com.beanbeanjuice.utility.command.ISubCommand; | ||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.ArrayList; | ||
|
||
/** | ||
* An {@link ICommand} used to rate people. | ||
* | ||
* @author beanbeanjuice | ||
* @since v3.1.0 | ||
*/ | ||
public class RateCommand implements ICommand { | ||
|
||
@Override | ||
public void handle(@NotNull SlashCommandInteractionEvent event) { } | ||
|
||
@NotNull | ||
@Override | ||
public String getDescription() { | ||
return "Rate someone!"; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public String exampleUsage() { | ||
return "`/rate simp` or `/rate insane @beanbeanjuice`"; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public CommandCategory getCategoryType() { | ||
return CommandCategory.FUN; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public ArrayList<ISubCommand> getSubCommands() { | ||
ArrayList<ISubCommand> subCommands = new ArrayList<>(); | ||
subCommands.add(new RateSimpSubCommand()); | ||
subCommands.add(new RateGaySubCommand()); | ||
subCommands.add(new RateSmartSubCommand()); | ||
subCommands.add(new RatePoorSubCommand()); | ||
subCommands.add(new RateInsaneSubCommand()); | ||
return subCommands; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public Boolean allowDM() { | ||
return true; | ||
} | ||
|
||
} |
66 changes: 66 additions & 0 deletions
66
src/main/java/com/beanbeanjuice/command/fun/rate/RateGaySubCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.beanbeanjuice.command.fun.rate; | ||
|
||
import com.beanbeanjuice.utility.command.CommandCategory; | ||
import com.beanbeanjuice.utility.command.ISubCommand; | ||
import com.beanbeanjuice.utility.helper.Helper; | ||
import net.dv8tion.jda.api.entities.User; | ||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; | ||
import net.dv8tion.jda.api.interactions.commands.OptionType; | ||
import net.dv8tion.jda.api.interactions.commands.build.OptionData; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.ArrayList; | ||
|
||
/** | ||
* An {@link ISubCommand} used to rate someone's gay percentage. | ||
* | ||
* @author beanbeanjuice | ||
* @since v3.1.0 | ||
*/ | ||
public class RateGaySubCommand implements ISubCommand { | ||
|
||
@Override | ||
public void handle(@NotNull SlashCommandInteractionEvent event) { | ||
User user = event.getUser(); | ||
if (event.getOption("user") != null) | ||
user = event.getOption("user").getAsUser(); | ||
|
||
event.getHook().sendMessageEmbeds(Helper.smallAuthorEmbed( | ||
"Gay Rating", null, user.getAvatarUrl(), | ||
"The gay rating is `" + Helper.getRandomNumber(0, 101) + "`%! 🏳️🌈" // Gay Pride Flag | ||
)).queue(); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public String getDescription() { | ||
return "Rate someone's gay percentage!"; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public String exampleUsage() { | ||
return "`/rate gay` or `/rate gay @beanbeanjuice`"; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public ArrayList<OptionData> getOptions() { | ||
ArrayList<OptionData> options = new ArrayList<>(); | ||
options.add(new OptionData(OptionType.USER, "user", "THe person to rate!", false)); | ||
return options; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public CommandCategory getCategoryType() { | ||
return CommandCategory.FUN; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public String getName() { | ||
return "gay"; | ||
} | ||
|
||
} |
Oops, something went wrong.