Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Alex Gryczewski 2023-02-27 14:18:56 -05:00
commit 781f14d165
6 changed files with 59 additions and 35 deletions

View File

@ -10,9 +10,10 @@ FROM openjdk:16
EXPOSE 8080
ENV ENVIRONMENT=PROD
ENV GOOGLE_APPLICATION_CREDENTIALS=/root/.fsbot/google_application_credentials.json
RUN mkdir /app
COPY --from=build /home/gradle/src/build/libs/*.jar /app/fashionscape-bot.jar
COPY --from=build /home/gradle/src/build/libs/* /app/fashionscape-bot.jar
ENTRYPOINT ["java","-jar","-Xmx800m","/app/fashionscape-bot.jar"]

View File

@ -7,10 +7,14 @@ plugins {
id 'application'
}
jar {
enabled = false
}
apply plugin: 'io.spring.dependency-management'
group 'dev.salmonllama'
version '2.0.5'
version '2.1.1'
sourceCompatibility = 16
@ -25,7 +29,7 @@ dependencies {
implementation 'org.xerial:sqlite-jdbc:3.36.0.2'
implementation 'org.postgresql:postgresql:42.2.24'
implementation 'com.github.Kaaz:ConfigurationBuilder:0.4'
implementation 'org.javacord:javacord:3.3.2'
implementation 'org.javacord:javacord:3.7.0'
implementation 'com.vdurmont:emoji-java:5.1.1'
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
implementation 'ch.qos.logback:logback-classic:1.2.5'

View File

@ -12,6 +12,7 @@ import dev.salmonllama.fsbot.listeners.*;
import org.javacord.api.DiscordApiBuilder;
import dev.salmonllama.fsbot.utilities.Constants;
import org.javacord.api.entity.intent.Intent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
@ -38,7 +39,7 @@ public class Main {
token = SecretManager.DISCORD_TOKEN.getPlainText();
}
new DiscordApiBuilder().setToken(token).login().thenAccept(api -> {
new DiscordApiBuilder().addIntents(Intent.MESSAGE_CONTENT).setToken(token).login().thenAccept(api -> {
@SuppressWarnings("unused")
Guthix guthix = new Guthix(api);

View File

@ -19,8 +19,8 @@ public class AddColorCommand extends Command {
@Override
public void onCommand(CommandContext ctx) {
ctx.getApi().getOwner().thenAcceptAsync(owner -> {
ctx.reply("This command is no longer active. An alternative is currently being developed. For more information, please contact " + owner.getDiscriminatedName());
});
// ctx.getApi().getOwner().thenAcceptAsync(owner -> {
// ctx.reply("This command is no longer active. An alternative is currently being developed. For more information, please contact " + owner.getDiscriminatedName());
// });
}
}

View File

@ -81,7 +81,7 @@ public class RestoreOutfitCommand extends Command {
// TODO: START ZAMMY
if (outfit.getTag().equals("zammy"))
{
ctx.getApi().getServerTextChannelById(BotConfig.OUTFIT_LOG).ifPresent(
ctx.getApi().getServerTextChannelById(BotConfig.ZAMMY_LOG).ifPresent(
chnl -> chnl.sendMessage(log)
);
}

View File

@ -7,8 +7,8 @@ package dev.salmonllama.fsbot.listeners;
import org.javacord.api.DiscordApi;
import org.javacord.api.entity.channel.TextChannel;
import org.javacord.api.entity.message.Message;
import org.javacord.api.entity.message.MessageAttachment;
import org.javacord.api.entity.message.MessageAuthor;
import org.javacord.api.entity.message.MessageBuilder;
import org.javacord.api.entity.message.embed.EmbedBuilder;
import org.javacord.api.event.message.MessageCreateEvent;
import org.javacord.api.listener.message.MessageCreateListener;
@ -23,44 +23,62 @@ public class ReportListener implements MessageCreateListener {
public void onMessageCreate(MessageCreateEvent event) {
DiscordApi api = event.getApi();
TextChannel channel = event.getChannel();
TextChannel reportChannel = event.getChannel();
if (!channel.getIdAsString().equals(BotConfig.REPORT_CHANNEL)) {
if (!reportChannel.getIdAsString().equals(BotConfig.REPORT_CHANNEL)) {
return;
}
Message message = event.getMessage();
String content = message.getContent();
MessageAuthor author = message.getAuthor();
if (author.isBotUser()) {
return;
}
String content = message.getContent();
message.getAttachments().forEach(
attachment -> attachment.downloadAsImage().thenAcceptAsync(
image -> new MessageBuilder()
.addAttachment(image, "evidence")
.setContent("Report Evidence:")
.send(channel)));
// The report log, also known as the #moderators channel.
Optional<TextChannel> modChannel = api.getTextChannelById(BotConfig.REPORT_LOG);
if (message.getAttachments().stream().anyMatch(MessageAttachment::isImage)) {
// Send the images with the content
message.getAttachments().stream().filter(MessageAttachment::isImage).forEach(
messageAttachment -> {
// The messageAttachment is an image, proceed accordingly.
// Upload the image to an embed and send it to the mods channel
// Include any content that was sent with it
messageAttachment.asImage().thenAcceptAsync(bufferedImage -> {
EmbedBuilder embed = new EmbedBuilder()
.setTitle("User Report with Image")
.setColor(Color.GREEN)
.setImage(bufferedImage)
.setFooter("Sent by: " + author.getDiscriminatedName());
if (!message.getContent().equals("")) {
embed.setDescription(message.getContent());
}
modChannel.ifPresentOrElse(
chnl -> chnl.sendMessage(embed),
() -> reportChannel.sendMessage("An error has occurred. Could not find the proper log channel. Please contact a staff member")
.thenAccept(MessageUtilities.deleteAfter(30, TimeUnit.SECONDS)));
});
});
} else {
// Just send the content
EmbedBuilder embed = new EmbedBuilder()
.setTitle("User Report")
.setDescription(content)
.setColor(Color.GREEN)
.setFooter("From: " + author.getDiscriminatedName());
modChannel.ifPresentOrElse(
chnl -> chnl.sendMessage(embed),
() -> reportChannel.sendMessage("An error has occurred. Could not find the proper log channel. Please contact a staff member")
.thenAccept(MessageUtilities.deleteAfter(30, TimeUnit.SECONDS)));
}
// Delete the message from the channel.
message.delete().join();
EmbedBuilder embed = new EmbedBuilder()
.setTitle("User Report")
.setDescription(content)
.setColor(Color.GREEN)
.setFooter("From: " + author.getDiscriminatedName());
Optional<TextChannel> logChannel = api.getTextChannelById(BotConfig.REPORT_LOG);
if (logChannel.isPresent()) {
logChannel.get().sendMessage(embed);
}
else {
channel.sendMessage("Could not find proper log channel, please contact a staff member.")
.thenAccept(MessageUtilities.deleteAfter(30, TimeUnit.SECONDS));
}
}
}