Search in sources :

Example 1 with WebhookEmbed

use of club.minnced.discord.webhook.send.WebhookEmbed in project MantaroBot by Mantaro.

the class LogUtils method spambot.

public static void spambot(User user, String guildId, String channelId, String messageId, SpamType type) {
    if (SPAMBOT_WEBHOOK == null) {
        log.warn("---- Spambot detected! ID: {}, Reason: {}", user.getId(), type);
        return;
    }
    try {
        List<WebhookEmbed.EmbedField> fields = new ArrayList<>();
        fields.add(new WebhookEmbed.EmbedField(false, "Tag", String.format("%#s", user)));
        fields.add(new WebhookEmbed.EmbedField(true, "ID", user.getId()));
        fields.add(new WebhookEmbed.EmbedField(true, "Guild ID", guildId));
        fields.add(new WebhookEmbed.EmbedField(true, "Channel ID", channelId));
        fields.add(new WebhookEmbed.EmbedField(true, "Message ID", messageId));
        fields.add(new WebhookEmbed.EmbedField(true, "Account Creation", user.getTimeCreated().toString()));
        fields.add(new WebhookEmbed.EmbedField(true, "Mutual Guilds", user.getMutualGuilds().stream().map(g -> g.getId() + ": " + g.getMemberCount() + " members").collect(Collectors.joining("\n"))));
        fields.add(new WebhookEmbed.EmbedField(false, "Type", type.toString()));
        if (type == SpamType.BLATANT) {
            var mantaroData = MantaroData.db().getMantaroData();
            mantaroData.getBlackListedUsers().add(user.getId());
            mantaroData.save();
            fields.add(new WebhookEmbed.EmbedField(false, "Info", "User has been blacklisted automatically. " + "For more information use the investigate command."));
        }
        SPAMBOT_WEBHOOK.send(new WebhookEmbed(null, Color.PINK.getRGB(), null, user.getEffectiveAvatarUrl(), null, new WebhookEmbed.EmbedFooter(Utils.formatDate(OffsetDateTime.now()), ICON_URL), new WebhookEmbed.EmbedTitle("Possible spambot detected", null), null, fields));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Color(java.awt.Color) Logger(org.slf4j.Logger) WebhookClient(club.minnced.discord.webhook.WebhookClient) Utils(net.kodehawa.mantarobot.utils.Utils) LoggerFactory(org.slf4j.LoggerFactory) Collectors(java.util.stream.Collectors) User(net.dv8tion.jda.api.entities.User) ArrayList(java.util.ArrayList) List(java.util.List) OffsetDateTime(java.time.OffsetDateTime) WebhookEmbed(club.minnced.discord.webhook.send.WebhookEmbed) MantaroData(net.kodehawa.mantarobot.data.MantaroData) WebhookClientBuilder(club.minnced.discord.webhook.WebhookClientBuilder) WebhookEmbed(club.minnced.discord.webhook.send.WebhookEmbed) ArrayList(java.util.ArrayList)

Aggregations

WebhookClient (club.minnced.discord.webhook.WebhookClient)1 WebhookClientBuilder (club.minnced.discord.webhook.WebhookClientBuilder)1 WebhookEmbed (club.minnced.discord.webhook.send.WebhookEmbed)1 Color (java.awt.Color)1 OffsetDateTime (java.time.OffsetDateTime)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 User (net.dv8tion.jda.api.entities.User)1 MantaroData (net.kodehawa.mantarobot.data.MantaroData)1 Utils (net.kodehawa.mantarobot.utils.Utils)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1