Merge branch 'dev' into master
This commit is contained in:
commit
3291eb14f0
@ -28,7 +28,17 @@ public class Main {
|
||||
|
||||
FSDB.init();
|
||||
|
||||
new DiscordApiBuilder().setToken(SecretManager.DISCORD_TOKEN.getPlainText()).login().thenAccept(api -> {
|
||||
String token;
|
||||
if (System.getenv("ENVIRONMENT") != null)
|
||||
{
|
||||
token = SecretManager.DISCORD_TOKEN_PROD.getPlainText();
|
||||
}
|
||||
else
|
||||
{
|
||||
token = SecretManager.DISCORD_TOKEN.getPlainText();
|
||||
}
|
||||
|
||||
new DiscordApiBuilder().setToken(token).login().thenAccept(api -> {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
Guthix guthix = new Guthix(api);
|
||||
|
@ -35,6 +35,7 @@ public class CreateGalleryCommand extends Command {
|
||||
}
|
||||
|
||||
String[] args = ctx.getArgs();
|
||||
// TODO: Check if the tag already exists
|
||||
// Check if the channel is already a registered gallery channel.
|
||||
// Create a gallery channel of the current channel.
|
||||
// Store the gallery channel in the database.
|
||||
|
@ -77,6 +77,15 @@ public class EditMetaCommand extends Command {
|
||||
.setColor(Color.YELLOW)
|
||||
.addField("Edited By:", ctx.getAuthor().getDiscriminatedName());
|
||||
|
||||
// TODO: START ZAMMY
|
||||
if (outfit.getTag().equals("zammy"))
|
||||
{
|
||||
ctx.getApi().getServerTextChannelById(BotConfig.ZAMMY_LOG).ifPresent(
|
||||
chnl -> chnl.sendMessage(log)
|
||||
);
|
||||
}
|
||||
// TODO: END ZAMMY
|
||||
|
||||
ctx.getApi().getServerTextChannelById(BotConfig.OUTFIT_LOG).ifPresent(
|
||||
chnl -> chnl.sendMessage(log)
|
||||
);
|
||||
|
@ -77,6 +77,15 @@ public class RemoveOutfitCommand extends Command {
|
||||
.setColor(Color.RED)
|
||||
.addField("Deleted By:", ctx.getAuthor().getDiscriminatedName());
|
||||
|
||||
// TODO: START ZAMMY
|
||||
if (outfit.getTag().equals("zammy"))
|
||||
{
|
||||
ctx.getApi().getServerTextChannelById(BotConfig.ZAMMY_LOG).ifPresent(
|
||||
chnl -> chnl.sendMessage(log)
|
||||
);
|
||||
}
|
||||
// TODO: END ZAMMY
|
||||
|
||||
ctx.getApi().getServerTextChannelById(BotConfig.OUTFIT_LOG).ifPresent(
|
||||
chnl -> chnl.sendMessage(log)
|
||||
);
|
||||
|
@ -78,6 +78,15 @@ public class RestoreOutfitCommand extends Command {
|
||||
.setColor(Color.BLUE)
|
||||
.addField("Restored By:", ctx.getAuthor().getDiscriminatedName());
|
||||
|
||||
// TODO: START ZAMMY
|
||||
if (outfit.getTag().equals("zammy"))
|
||||
{
|
||||
ctx.getApi().getServerTextChannelById(BotConfig.ZAMMY_LOG).ifPresent(
|
||||
chnl -> chnl.sendMessage(log)
|
||||
);
|
||||
}
|
||||
// TODO: END ZAMMY
|
||||
|
||||
ctx.getApi().getServerTextChannelById(BotConfig.OUTFIT_LOG).ifPresent(
|
||||
chnl -> chnl.sendMessage(log)
|
||||
);
|
||||
|
@ -81,6 +81,15 @@ public class RetagCommand extends Command {
|
||||
.setThumbnail(outfit.getLink())
|
||||
.addField("New tag:", newTag);
|
||||
|
||||
// TODO: START ZAMMY
|
||||
if (outfit.getTag().equals("zammy"))
|
||||
{
|
||||
ctx.getApi().getServerTextChannelById(BotConfig.ZAMMY_LOG).ifPresent(
|
||||
chnl -> chnl.sendMessage(log)
|
||||
);
|
||||
}
|
||||
// TODO: END ZAMMY
|
||||
|
||||
ctx.getApi().getServerTextChannelById(BotConfig.OUTFIT_LOG).ifPresent(
|
||||
chnl -> chnl.sendMessage(log)
|
||||
);
|
||||
|
@ -56,6 +56,9 @@ public class BotConfig {
|
||||
@ConfigurationOption
|
||||
public static String OUTFIT_LOG = "outfit log channel";
|
||||
|
||||
@ConfigurationOption
|
||||
public static String ZAMMY_LOG = "zammy log here";
|
||||
|
||||
@ConfigurationOption
|
||||
public static String ACTIVITY_LOG = "bot_log_channel";
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Aleksei Gryczewski
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.config;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -5,8 +9,8 @@ import java.io.IOException;
|
||||
import com.google.cloud.secretmanager.v1.SecretManagerServiceClient;
|
||||
|
||||
public enum SecretManager {
|
||||
// TODO: Change this to adapt to env
|
||||
DISCORD_TOKEN ("projects/fashionscapers-212707/secrets/fs_discord_token_prod/versions/1"),
|
||||
DISCORD_TOKEN ("projects/fashionscapers-212707/secrets/fs_discord_token/versions/1"),
|
||||
DISCORD_TOKEN_PROD ("projects/fashionscapers-212707/secrets/fs_discord_token_prod/versions/1"),
|
||||
IMGUR_ID ("projects/fashionscapers-212707/secrets/fs_imgur_client_id/versions/1"),
|
||||
IMGUR_BEARER ("projects/fashionscapers-212707/secrets/fs_imgur_bearer_token/versions/1")
|
||||
;
|
||||
|
@ -373,6 +373,7 @@ public class OutfitController {
|
||||
"submitter = ?," +
|
||||
"tag = ?," +
|
||||
"meta = ?," +
|
||||
"discord_name = ?," +
|
||||
"updated = ?," +
|
||||
"featured = ?," +
|
||||
"deleted = ?," +
|
||||
@ -382,6 +383,7 @@ public class OutfitController {
|
||||
outfit.getSubmitter(),
|
||||
outfit.getTag(),
|
||||
outfit.getMeta(),
|
||||
outfit.getDiscordName(),
|
||||
outfit.getUpdated(),
|
||||
outfit.isFeatured(),
|
||||
outfit.isDeleted(),
|
||||
@ -430,6 +432,7 @@ public class OutfitController {
|
||||
.setSubmitter(rs.getString("submitter"))
|
||||
.setTag(rs.getString("tag"))
|
||||
.setMeta(rs.getString("meta"))
|
||||
.setDiscordName(rs.getString("discord_name"))
|
||||
.setCreated(new Timestamp(rs.getLong("created")))
|
||||
.setUpdated(new Timestamp(rs.getLong("updated")))
|
||||
.setDeleted(rs.getBoolean("deleted"))
|
||||
|
@ -115,7 +115,7 @@ public class Outfit extends DatabaseModel {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("Outfit: [id: %s, link: %s, submitter: %s, tag: %s, created: %s, updated: %s, deleted: %s, featured: %s, display count: %s, deletion hash: %s, meta: %s, discordName: %s]",
|
||||
return String.format("Outfit: [id: %s, link: %s, submitter: %s, tag: %s, created: %s, updated: %s, deleted: %s, featured: %s, display count: %s, deletion hash: %s, meta: %s, discord_name: %s]",
|
||||
id, link, submitter, tag, created, updated, deleted, featured, displayCount, deleteHash, meta, discordName
|
||||
);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2021 Aleksei Gryczewski
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.database.models;
|
||||
|
@ -1,3 +1,7 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Aleksei Gryczewski
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.database.models;
|
||||
|
||||
import dev.salmonllama.fsbot.database.DatabaseModel;
|
||||
|
@ -104,7 +104,7 @@ public class ImageListener implements MessageCreateListener {
|
||||
.setId(UUID.randomUUID().toString())
|
||||
.setMeta(event.getMessageContent())
|
||||
.setDiscordName(event.getMessageAuthor().getDiscriminatedName())
|
||||
.setLink("DUMMY-LINK")
|
||||
.setLink(event.getMessageAttachments().get(0).getUrl().toString())
|
||||
.setSubmitter(event.getMessageAuthor().getIdAsString())
|
||||
.setDeleteHash("DUMMY-DELETE-HASH");
|
||||
|
||||
@ -118,6 +118,43 @@ public class ImageListener implements MessageCreateListener {
|
||||
|
||||
OutfitController.insert(outfit).thenAcceptAsync((Void) -> {
|
||||
// Log the outfit
|
||||
|
||||
// TODO: START ZAMMY LOG
|
||||
if (outfit.getTag().equals("zammy"))
|
||||
{
|
||||
event.getApi().getServerTextChannelById(BotConfig.ZAMMY_LOG).ifPresentOrElse(chnl ->
|
||||
{
|
||||
EmbedBuilder response = new EmbedBuilder()
|
||||
.setTitle("Outfit Added")
|
||||
.setAuthor(event.getMessageAuthor())
|
||||
.setThumbnail(outfit.getLink())
|
||||
.setFooter(String.format("%s | %s", outfit.getTag(), outfit.getId()))
|
||||
.setUrl(outfit.getLink())
|
||||
.setColor(Color.GREEN)
|
||||
.addField("Uploaded:", outfit.getCreated().toString())
|
||||
.addField("Discord Name:", outfit.getDiscordName());
|
||||
|
||||
if (!outfit.getMeta().equals("")) {
|
||||
response.addField("Meta:", outfit.getMeta());
|
||||
}
|
||||
|
||||
chnl.sendMessage(response);
|
||||
logger.info(String.format("Outfit from %s successfully added to the zammy event.", event.getMessageAuthor().getDiscriminatedName()));
|
||||
|
||||
// Add the reaction to the original message
|
||||
GalleryController.getEmoji(channel.getIdAsString()).thenAcceptAsync(
|
||||
emoji -> event.getMessage().addReaction(EmojiParser.parseToUnicode(emoji))
|
||||
).exceptionally(ExceptionLogger.get());
|
||||
}, () ->
|
||||
{
|
||||
// Fallback error message to me
|
||||
event.getApi().getUserById(BotConfig.BOT_OWNER).thenAcceptAsync(
|
||||
user -> user.sendMessage("Could not find OUTFIT LOG")
|
||||
);
|
||||
});
|
||||
}
|
||||
// TODO: END ZAMMY LOG
|
||||
|
||||
event.getApi().getServerTextChannelById(BotConfig.OUTFIT_LOG).ifPresentOrElse(chnl -> {
|
||||
EmbedBuilder response = new EmbedBuilder()
|
||||
.setTitle("Outfit Added")
|
||||
@ -126,7 +163,8 @@ public class ImageListener implements MessageCreateListener {
|
||||
.setFooter(String.format("%s | %s", outfit.getTag(), outfit.getId()))
|
||||
.setUrl(outfit.getLink())
|
||||
.setColor(Color.GREEN)
|
||||
.addField("Uploaded:", outfit.getCreated().toString());
|
||||
.addField("Uploaded:", outfit.getCreated().toString())
|
||||
.addField("Discord Name:", outfit.getDiscordName());
|
||||
|
||||
if (!outfit.getMeta().equals("")) {
|
||||
response.addField("Meta:", outfit.getMeta());
|
||||
|
@ -1,3 +1,7 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Aleksei Gryczewski
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.services;
|
||||
|
||||
import java.util.UUID;
|
||||
|
Loading…
Reference in New Issue
Block a user