Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/main' into connecti…
Browse files Browse the repository at this point in the history
…on_test_command_change

# Conflicts:
#	src/main/java/org/geysermc/discordbot/commands/PingCommand.java
  • Loading branch information
onebeastchris committed Jul 9, 2024
2 parents a4c9814 + c2a1475 commit 4dfd80b
Show file tree
Hide file tree
Showing 31 changed files with 594 additions and 354 deletions.
2 changes: 1 addition & 1 deletion .idea/copyright/GeyserDiscordBot.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 19 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,22 @@ A bot for the GeyserMC Discord server
These allow customisation of the bot on a per-guild basis. These can be changed using `!settings set preference value` and checked using `!settings get preference`.

Most of these are lists which values are seperated by `,` and a few are seperated by a `|` aswell which gives them a more key-value like structure.
| Preference | Description | Example value |
|----------------------|--------------------------------------------------------------------------------------|-------------------------------------------------------------|
| `convert-extensions` | File extensions to auto upload to paste.gg | `txt,log,yml,log.0` |
| `log-channel` | Channel ID to output moderation logs to | `614877230811709474` |
| `update-channel` | Channel ID to notify with minecraft updates | `618189671259832320` |
| `roles` | Roles that are available to join with the `role`/`rank` command | `GeyserNews\|613169070367309834,Tester\|775083359101517884` |
| `voice-role` | The role to grant users when in a voice channel | `856161072507518986` |
| `dont-log` | Channels IDs that are excluded from the moderation log | `613168850925649981,613168974645035016` |
| `check-domains` | Domains to check against to filter phishing and malware domains | `steamcommunity.com` |
| `health-checks` | Channel IDs to log web health checks to along with the url to check | `808759445827223572\|https://api.geysermc.org/health` |
| `dont-level` | Channel IDs to ignore messages for the level system, set to 0 to disable server wide | `754458074818805811` |
| `punishment-message` | A message to add to the end of a punishment DM | `If you wish to appeal your punishment, contact an admin.` |
| `banned-domains` | Domains that if found in a message, the message will be removed | `dlscord-nitro.click,discord-airdrop.com` |
| `banned-ips` | IPs that if a domain found in a message resolves to, the message will be removed | `95.181.163.44,95.181.163.46` |
| `rss-feeds` | Channel IDs to log RSS posts to along with the RSS feed url | `916482484122824704\|https://blog.geysermc.org/feed.xml` |
| `allowed-invites` | Guild IDs for allowed invites | `613163671870242838,393465748535640064` |
| `forum-channel` | Channel ID for forum management | `645877230811709456` |
| Preference | Description | Example value |
|-------------------------|--------------------------------------------------------------------------------------|-------------------------------------------------------------|
| `convert-extensions` | File extensions to auto upload to paste.gg | `txt,log,yml,log.0` |
| `log-channel` | Channel ID to output moderation logs to | `614877230811709474` |
| `update-channel` | Channel ID to notify with minecraft updates | `618189671259832320` |
| `roles` | Roles that are available to join with the `role`/`rank` command | `GeyserNews\|613169070367309834,Tester\|775083359101517884` |
| `voice-role` | The role to grant users when in a voice channel | `856161072507518986` |
| `dont-log` | Channels IDs that are excluded from the moderation log | `613168850925649981,613168974645035016` |
| `check-domains` | Domains to check against to filter phishing and malware domains | `steamcommunity.com` |
| `health-checks` | Channel IDs to log web health checks to along with the url to check | `808759445827223572\|https://api.geysermc.org/health` |
| `dont-level` | Channel IDs to ignore messages for the level system, set to 0 to disable server wide | `754458074818805811` |
| `punishment-message` | A message to add to the end of a punishment DM | `If you wish to appeal your punishment, contact an admin.` |
| `banned-domains` | Domains that if found in a message, the message will be removed | `dlscord-nitro.click,discord-airdrop.com` |
| `banned-ips` | IPs that if a domain found in a message resolves to, the message will be removed | `95.181.163.44,95.181.163.46` |
| `rss-feeds` | Channel IDs to log RSS posts to along with the RSS feed url | `916482484122824704\|https://blog.geysermc.org/feed.xml` |
| `allowed-invites` | Guild IDs for allowed invites | `613163671870242838,393465748535640064` |
| `forum-channel` | Channel ID for forum management | `645877230811709456` |
| `preview-feeds-channel` | News channel ID for preview feeds | `614877230811709474` |
| `preview-feeds` | Forum channel ID for preview feeds | `614877230811709474` |
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'java-library'
id 'application'
id 'io.sentry.jvm.gradle' version '3.13.0'
}

Expand Down Expand Up @@ -104,6 +105,11 @@ jar {
}
}

// Allow running with `./gradlew run` task
application {
mainClass = 'org.geysermc.discordbot.GeyserBot'
}

test {
useJUnitPlatform()
}
Expand Down
34 changes: 29 additions & 5 deletions src/main/java/org/geysermc/discordbot/GeyserBot.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2022 GeyserMC. http://geysermc.org
* Copyright (c) 2020-2024 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -27,6 +27,7 @@

import com.jagrosh.jdautilities.command.Command;
import com.jagrosh.jdautilities.command.CommandClientBuilder;
import com.jagrosh.jdautilities.command.ContextMenu;
import com.jagrosh.jdautilities.command.SlashCommand;
import com.jagrosh.jdautilities.commons.waiter.EventWaiter;
import io.sentry.Sentry;
Expand Down Expand Up @@ -61,7 +62,6 @@
import org.slf4j.LoggerFactory;
import pw.chew.chewbotcca.util.RestClient;

import javax.security.auth.login.LoginException;
import java.io.FileInputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
Expand All @@ -78,6 +78,7 @@ public class GeyserBot {
public static final Logger LOGGER = LoggerFactory.getLogger(GeyserBot.class);
public static final List<Command> COMMANDS;
public static final List<SlashCommand> SLASH_COMMANDS;
public static final List<ContextMenu> CONTEXT_MENUS;

public static AbstractStorageManager storageManager;

Expand All @@ -96,8 +97,9 @@ public class GeyserBot {
Set<Class<? extends Command>> subTypes = reflections.getSubTypesOf(Command.class);
for (Class<? extends Command> theClass : subTypes) {
// Don't load SubCommands
if (theClass.getName().contains("SubCommand"))
if (theClass.getName().contains("SubCommand")) {
continue;
}
try {
commands.add(theClass.getDeclaredConstructor().newInstance());
LoggerFactory.getLogger(theClass).debug("Loaded Command Successfully!");
Expand All @@ -109,8 +111,9 @@ public class GeyserBot {
Set<Class<? extends SlashCommand>> slashSubTypes = reflections.getSubTypesOf(SlashCommand.class);
for (Class<? extends SlashCommand> theClass : slashSubTypes) {
// Don't load SubCommands
if (theClass.getName().contains("SubCommand"))
if (theClass.getName().contains("SubCommand")) {
continue;
}
slashCommands.add(theClass.getDeclaredConstructor().newInstance());
LoggerFactory.getLogger(theClass).debug("Loaded SlashCommand Successfully!");
}
Expand All @@ -119,9 +122,26 @@ public class GeyserBot {
}
COMMANDS = commands;
SLASH_COMMANDS = slashCommands;

// Gathers all context menu items from "context_menu" package.
List<ContextMenu> contextMenus = new ArrayList<>();
try {
Reflections reflections = new Reflections("org.geysermc.discordbot.context_menus");
Set<Class<? extends ContextMenu>> subTypes = reflections.getSubTypesOf(ContextMenu.class);
for (Class<? extends ContextMenu> theClass : subTypes) {
if (!theClass.getPackageName().startsWith("org.geysermc.discordbot.context_menus")) {
continue;
}
contextMenus.add(theClass.getDeclaredConstructor().newInstance());
LoggerFactory.getLogger(theClass).debug("Loaded ContextMenu Successfully!");
}
} catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
LOGGER.error("Unable to load context menus", e);
}
CONTEXT_MENUS = contextMenus;
}

public static void main(String[] args) throws IOException, LoginException {
public static void main(String[] args) throws IOException {
// Load properties into the PropertiesManager
Properties prop = new Properties();
prop.load(new FileInputStream("bot.properties"));
Expand All @@ -133,6 +153,7 @@ public static void main(String[] args) throws IOException, LoginException {
Sentry.init(options -> {
options.setDsn(PropertiesManager.getSentryDsn());
options.setEnvironment(PropertiesManager.getSentryEnv());
options.setEnabled(true);
LOGGER.info("Sentry.io loaded");
});
}
Expand Down Expand Up @@ -169,6 +190,7 @@ public static void main(String[] args) throws IOException, LoginException {
client.useHelpBuilder(false);
client.addCommands(COMMANDS.toArray(new Command[0]));
client.addSlashCommands(SLASH_COMMANDS.toArray(new SlashCommand[0]));
client.addContextMenus(CONTEXT_MENUS.toArray(new ContextMenu[0]));
client.setListener(new CommandErrorHandler());
client.setCommandPreProcessBiFunction((event, command) -> !SwearHandler.filteredMessages.contains(event.getMessage().getIdLong()));

Expand Down Expand Up @@ -216,6 +238,8 @@ public static void main(String[] args) throws IOException, LoginException {
new BadLinksHandler(),
new HelpHandler(),
new SupportHandler(),
new DeleteHandler(),
new PreviewHandler(),
client.build(),
tagClient.build())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public DownloadCommand() {
this.defaultDownloadOption = new GeyserDownloadOption("Geyser", "https://geysermc.org/download");
this.optionsToRepository = ImmutableMap.<String, DownloadOption>builder()
.put("geyser", this.defaultDownloadOption)
.put("floodgate", new GeyserDownloadOption("Floodgate", this.defaultDownloadOption.downloadUrl))
.put("geyseroptionalpack", new GeyserDownloadOption("GeyserOptionalPack", "https://ci.opencollab.dev/job/GeyserMC/job/GeyserOptionalPack/job/master/"))
.put("floodgate", new GeyserDownloadOption("Floodgate", "https://geysermc.org/download#floodgate"))
.put("geyseroptionalpack", new GeyserDownloadOption("GeyserOptionalPack", "https://download.geysermc.org/v2/projects/geyseroptionalpack/versions/latest/builds/latest/downloads/geyseroptionalpack"))
.put("floodgate-fabric", new FabricDownloadOption("Floodgate-Fabric", "https://modrinth.com/mod/floodgate"))
.put("paper", new DownloadOption("Paper", "https://papermc.io/downloads", "https://github.com/PaperMC.png"))
.put("viaversion", new DownloadOption("ViaVersion", "https://ci.viaversion.com/job/ViaVersion/", "https://github.com/ViaVersion.png"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ protected void execute(SlashCommandEvent event) {
case 503 -> {
builder.addField("Global API", "Error " + serverCode, false);
builder.addField("Bedrock Player Name", username, false);
builder.addField("Reason", " The requested account was not cached and we where not able to call the Xbox Live API", false);
builder.addField("Fix", "You have to join a Floodgate server so the Bedrock account will get added to the GlobalAPI cache.", false);
builder.addField("Reason", " The requested account has not yet been cached, and we were unable to call the Xbox Live API", false);
builder.addField("Fix", "You need to join a Floodgate server in order for the Bedrock account to be added to the GlobalAPI cache", false);
builder.setColor(BotColors.FAILURE.getColor());
}
default -> {
Expand Down
Loading

0 comments on commit 4dfd80b

Please sign in to comment.