Skip to content

Commit

Permalink
Merge pull request #179 from Gerald-Development/dev
Browse files Browse the repository at this point in the history
Merge for next Version
  • Loading branch information
Montori authored Apr 13, 2022
2 parents 664f604 + d72121a commit 7e29f7c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
29 changes: 20 additions & 9 deletions src/main/java/de/voidtech/gerald/Gerald.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.OnlineStatus;
//import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.dv8tion.jda.api.requests.GatewayIntent;
import net.dv8tion.jda.api.utils.Compression;
import net.dv8tion.jda.api.utils.MemberCachePolicy;
Expand All @@ -39,10 +38,9 @@
import org.springframework.core.annotation.Order;

import javax.security.auth.login.LoginException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;

@SpringBootApplication
public class Gerald {
Expand All @@ -62,7 +60,7 @@ public JDA getJDA(MessageListener msgListener, GuildGoneListener guildGoneListen
GlobalConfig globalConf = globalConfService.getGlobalConfig();

JDA jda = JDABuilder.createDefault(configService.getToken())
.enableIntents(getNonPrivilegedIntents())
.enableIntents(getApprovedIntents())
.setMemberCachePolicy(MemberCachePolicy.ALL)
.setBulkDeleteSplittingEnabled(false)
.setStatus(OnlineStatus.ONLINE)
Expand All @@ -80,11 +78,24 @@ public JDA getJDA(MessageListener msgListener, GuildGoneListener guildGoneListen
return jda;
}

private List<GatewayIntent> getNonPrivilegedIntents() {
List<GatewayIntent> gatewayIntents = new ArrayList<>(Arrays.asList(GatewayIntent.values()));
gatewayIntents.remove(GatewayIntent.GUILD_PRESENCES);
private Set<GatewayIntent> getApprovedIntents()
{
Set<GatewayIntent> approvedIntents = new HashSet<GatewayIntent>();

approvedIntents.add(GatewayIntent.GUILD_MEMBERS);
approvedIntents.add(GatewayIntent.GUILD_BANS);
approvedIntents.add(GatewayIntent.GUILD_EMOJIS);
approvedIntents.add(GatewayIntent.GUILD_WEBHOOKS);
approvedIntents.add(GatewayIntent.GUILD_INVITES);
approvedIntents.add(GatewayIntent.GUILD_VOICE_STATES);
approvedIntents.add(GatewayIntent.GUILD_MESSAGES);
approvedIntents.add(GatewayIntent.GUILD_MESSAGE_REACTIONS);
approvedIntents.add(GatewayIntent.GUILD_MESSAGE_TYPING);
approvedIntents.add(GatewayIntent.DIRECT_MESSAGES);
approvedIntents.add(GatewayIntent.DIRECT_MESSAGE_REACTIONS);
approvedIntents.add(GatewayIntent.DIRECT_MESSAGE_TYPING);

return gatewayIntents;
return approvedIntents;
}
//TODO (from: Franziska): WIP, DO NOT USE IN PROD
//private void upsertSlashCommands(JDA jda) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/voidtech/gerald/GlobalConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ public class GlobalConstants {
public static final String STREAM_URL = "https://twitch.tv/elementalmp4";
public static final String LINKTREE_URL = "https://linktr.ee/GeraldBot";
public static final String INVITE_URL = "https://discord.com/api/oauth2/authorize?client_id=555816892141404163&permissions=805694544&scope=bot%20applications.commands";
public static final String VERSION = "1.2.7 - Mucho Mocha";
public static final String VERSION = "1.2.8 - Mucho Mocha";
}
3 changes: 1 addition & 2 deletions src/main/java/de/voidtech/gerald/listeners/VoteListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,4 @@ public void onEvent(GenericEvent event) {
if (!hasRole) reaction.getReaction().removeReaction(reaction.getUser()).queue();
}
}

}
}
4 changes: 1 addition & 3 deletions src/main/java/de/voidtech/gerald/service/CommandService.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import main.java.de.voidtech.gerald.GlobalConstants;
import main.java.de.voidtech.gerald.commands.AbstractCommand;
import main.java.de.voidtech.gerald.commands.CommandContext;
import main.java.de.voidtech.gerald.util.CustomCollectors;
Expand Down Expand Up @@ -99,8 +98,7 @@ private String findCommand(String prompt) {
private MessageEmbed createLevenshteinEmbed(List<String> possibleOptions) {
EmbedBuilder levenshteinResultEmbed = new EmbedBuilder()
.setColor(Color.RED)
.setTitle("That's not a command!", GlobalConstants.LINKTREE_URL)
.addField("Is this what you meant?", "`" + String.join("`, `", possibleOptions) + "`", false);
.setTitle("I couldn't find that command! Did you mean `" + String.join("` or `", possibleOptions) + "`?");
return levenshteinResultEmbed.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ private NewContextOptions getContextOptions() {
}

//@EventListener(ApplicationReadyEvent.class)
@SuppressWarnings("unused")
private void initialisePlaywright() {
ExecutorService playwrightExecutor = threadManager.getThreadByName("Playwright");
playwrightExecutor.execute(new Runnable() {
Expand Down

0 comments on commit 7e29f7c

Please sign in to comment.