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