commit
176e8f4ecd
@ -25,7 +25,7 @@ dependencies {
|
|||||||
implementation 'org.xerial:sqlite-jdbc:3.36.0.2'
|
implementation 'org.xerial:sqlite-jdbc:3.36.0.2'
|
||||||
implementation 'org.postgresql:postgresql:42.2.24'
|
implementation 'org.postgresql:postgresql:42.2.24'
|
||||||
implementation 'com.github.Kaaz:ConfigurationBuilder:0.4'
|
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.vdurmont:emoji-java:5.1.1'
|
||||||
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
|
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
|
||||||
implementation 'ch.qos.logback:logback-classic:1.2.5'
|
implementation 'ch.qos.logback:logback-classic:1.2.5'
|
||||||
|
@ -12,6 +12,7 @@ import dev.salmonllama.fsbot.listeners.*;
|
|||||||
import org.javacord.api.DiscordApiBuilder;
|
import org.javacord.api.DiscordApiBuilder;
|
||||||
|
|
||||||
import dev.salmonllama.fsbot.utilities.Constants;
|
import dev.salmonllama.fsbot.utilities.Constants;
|
||||||
|
import org.javacord.api.entity.intent.Intent;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
@ -38,7 +39,7 @@ public class Main {
|
|||||||
token = SecretManager.DISCORD_TOKEN.getPlainText();
|
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")
|
@SuppressWarnings("unused")
|
||||||
Guthix guthix = new Guthix(api);
|
Guthix guthix = new Guthix(api);
|
||||||
|
@ -19,8 +19,8 @@ public class AddColorCommand extends Command {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCommand(CommandContext ctx) {
|
public void onCommand(CommandContext ctx) {
|
||||||
ctx.getApi().getOwner().thenAcceptAsync(owner -> {
|
// 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.reply("This command is no longer active. An alternative is currently being developed. For more information, please contact " + owner.getDiscriminatedName());
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,8 @@ package dev.salmonllama.fsbot.listeners;
|
|||||||
import org.javacord.api.DiscordApi;
|
import org.javacord.api.DiscordApi;
|
||||||
import org.javacord.api.entity.channel.TextChannel;
|
import org.javacord.api.entity.channel.TextChannel;
|
||||||
import org.javacord.api.entity.message.Message;
|
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.MessageAuthor;
|
||||||
import org.javacord.api.entity.message.MessageBuilder;
|
|
||||||
import org.javacord.api.entity.message.embed.EmbedBuilder;
|
import org.javacord.api.entity.message.embed.EmbedBuilder;
|
||||||
import org.javacord.api.event.message.MessageCreateEvent;
|
import org.javacord.api.event.message.MessageCreateEvent;
|
||||||
import org.javacord.api.listener.message.MessageCreateListener;
|
import org.javacord.api.listener.message.MessageCreateListener;
|
||||||
@ -23,44 +23,62 @@ public class ReportListener implements MessageCreateListener {
|
|||||||
|
|
||||||
public void onMessageCreate(MessageCreateEvent event) {
|
public void onMessageCreate(MessageCreateEvent event) {
|
||||||
DiscordApi api = event.getApi();
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Message message = event.getMessage();
|
Message message = event.getMessage();
|
||||||
|
String content = message.getContent();
|
||||||
MessageAuthor author = message.getAuthor();
|
MessageAuthor author = message.getAuthor();
|
||||||
|
|
||||||
if (author.isBotUser()) {
|
if (author.isBotUser()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String content = message.getContent();
|
// The report log, also known as the #moderators channel.
|
||||||
message.getAttachments().forEach(
|
Optional<TextChannel> modChannel = api.getTextChannelById(BotConfig.REPORT_LOG);
|
||||||
attachment -> attachment.downloadAsImage().thenAcceptAsync(
|
|
||||||
image -> new MessageBuilder()
|
|
||||||
.addAttachment(image, "evidence")
|
|
||||||
.setContent("Report Evidence:")
|
|
||||||
.send(channel)));
|
|
||||||
|
|
||||||
|
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();
|
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));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user