Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

awesome #4

Merged
merged 33 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
cf6c4cc
Add node 6 & 7 to helpbot
TechStreetDev Apr 8, 2022
8f93d74
Merge pull request #81 from TechStreetDev/master
Tomoli75 Apr 8, 2022
21605bb
Merge pull request #79 from ProjectDF/master
RedDaedalus May 2, 2022
2413380
Fixed the chest paramater emoji for ?code command (currently using DF…
uhki Jul 13, 2022
96a9a1e
Update CowsayCommand.java (#82)
Reasonlesss Jul 13, 2022
16cdee7
feat: Implement role toggle for bao polls (#84)
RedDaedalus Jul 13, 2022
8e0da9c
bao polls -> polls
RedDaedalus Jul 13, 2022
99d517b
Fix Dictionaries in ?code (#85)
Reasonlesss Jul 23, 2022
1d700a0
Yourkit
Owen1212055 Aug 9, 2022
6c5b425
Delete ?query command (#86)
RedDaedalus Aug 19, 2022
b003593
chore: Move to gradle Kotlin DSL (groovy sucks nobody likes it) (#88)
RedDaedalus Oct 1, 2022
eec5d68
Update gradle settings + remove old commented config (#89)
Owen1212055 Oct 1, 2022
61d1333
fix: Rename Expert to SrHelper (#90)
RedDaedalus Oct 1, 2022
85bf948
Remove some old + generally outdated stuff (#91)
Owen1212055 Oct 1, 2022
25c698e
refactor: move permissions to config
tk2217 Oct 2, 2022
cb7a177
fix i think
tk2217 Oct 2, 2022
de3a06a
fix the stupid editorconfig
tk2217 Oct 2, 2022
4ab3b24
make gradlew executable (linux moment
tk2217 Oct 2, 2022
323e52f
Fix ?garfield command.
Reasonlesss Feb 10, 2023
d3682c1
Merge pull request #94 from Reasonlesss/master
tk2217 Feb 12, 2023
585a9f1
Revert "Delete ?query command (#86)" (#95)
Owen1212055 Feb 13, 2023
87c42c5
Add pronouns to ProfileCommand (#97)
TechStreetDev Jun 18, 2023
b4e95ba
yep
tk2217 Aug 7, 2023
1d98753
Merge pull request #99 from MCDiamondFire/do-the-featured-plots-thing
tk2217 Aug 7, 2023
6bfc20d
Merge branch 'master' into refactor/move-permissions-to-config
tk2217 Aug 7, 2023
b300e46
Merge pull request #92 from MCDiamondFire/refactor/move-permissions-t…
tk2217 Aug 7, 2023
a1a2714
fix the stupid thing
tk2217 Aug 7, 2023
f22a43f
Update ?nbs command (#93)
GeorgeRNG Nov 10, 2023
8783ab4
5.0.0
Owen1212055 Apr 16, 2024
59cf40b
Only allow specific bot devs to run ?eval as mods can just give thems…
Reasonlesss May 3, 2024
9f4435c
VIP Role Star (#100)
Reasonlesss Jun 14, 2024
bfe400f
changes (#102)
Reasonlesss Jul 3, 2024
8d2df10
Help Improvements (#104)
RedVortexDev Nov 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,382 changes: 1,191 additions & 1,191 deletions .editorconfig

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ build
/src/main/resources/swear_filter.json

*.json
*.png
*.txt
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,13 @@ After setting up the config, you will need to paste the following into the swear
]
}
```

## Special Thanks To

![YourKit Logo](https://www.yourkit.com/images/yklogo.png)

YourKit supports open source projects with innovative and intelligent tools
for monitoring and profiling Java and .NET applications.
YourKit is the creator of [YourKit Java Profiler](https://www.yourkit.com/java/profiler/),
[YourKit .NET Profiler](https://www.yourkit.com/.net/profiler/),
and [YourKit YouMonitor](ttps://www.yourkit.com/youmonitor/).
45 changes: 0 additions & 45 deletions build.gradle

This file was deleted.

49 changes: 49 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
plugins {
java
application
id("com.github.johnrengelman.shadow") version "7.1.2"
}

application {
mainClass.set("com.diamondfire.helpbot.HelpBot")
}

group = "com.diamondfire.helpbot"

repositories {
mavenCentral()
maven(url = "https://jitpack.io")
maven(url = "https://m2.dv8tion.net/releases")
}

dependencies {
implementation ("net.dv8tion:JDA:5.0.0-beta.20") {
exclude(module = "opus-java")
}

implementation("club.minnced:discord-webhooks:0.5.8")
implementation("ch.qos.logback:logback-classic:1.2.5")
implementation("com.google.code.gson:gson:2.8.6")
implementation ("com.github.Steveice10:MCProtocolLib:c5e4b66")
implementation("mysql:mysql-connector-java:5.1.13")
implementation("org.codehaus.groovy:groovy-jsr223:3.0.8")
implementation("net.kyori:adventure-api:4.16.0")
implementation("net.kyori:adventure-text-minimessage:4.16.0")
implementation("dev.vankka:mcdiscordreserializer:4.3.0")
}

tasks {
compileJava {
options.encoding = "UTF-8"
}

jar {
manifest {
attributes["Main-Class"] = "com.diamondfire.helpbot.HelpBot"
}
}

build {
dependsOn(shadowJar)
}
}
Empty file modified gradlew
100644 → 100755
Empty file.
2 changes: 0 additions & 2 deletions settings.gradle

This file was deleted.

2 changes: 2 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rootProject.name = "DFHelpBot"

3 changes: 0 additions & 3 deletions src/main/java/com/diamondfire/helpbot/HelpBot.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package com.diamondfire.helpbot;


import com.diamondfire.helpbot.bot.HelpBotInstance;
import com.diamondfire.helpbot.df.codeinfo.codedatabase.changelog.CodeDifferenceHandler;
import com.diamondfire.helpbot.df.codeinfo.codedatabase.db.CodeDatabase;
import com.diamondfire.helpbot.sys.tag.TagHandler;

import javax.security.auth.login.LoginException;
import java.io.IOException;

public class HelpBot {

Expand Down
30 changes: 14 additions & 16 deletions src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.diamondfire.helpbot.bot.config.Config;
import com.diamondfire.helpbot.bot.events.*;
import com.diamondfire.helpbot.sys.tasks.TaskRegistry;
import com.google.gson.Gson;
import net.dv8tion.jda.api.*;
import net.dv8tion.jda.api.entities.Activity;
import net.dv8tion.jda.api.requests.GatewayIntent;
Expand All @@ -31,10 +32,11 @@

public class HelpBotInstance {

public static final Gson GSON = new Gson();

private static final Config config = new Config();
public static final long DF_GUILD = config.getGuild();
public static final long LOG_CHANNEL = config.getLogChannel();
public static final OkHttpClient HTTP_CLIENT = new OkHttpClient();

private static JDA jda;
private static final TaskRegistry loop = new TaskRegistry();
Expand All @@ -49,12 +51,13 @@ public static void initialize() throws LoginException {
new SearchCommand(),
new TagsCommand(),
// others
new CowsayCommand(),
//new CowsayCommand(),
new MimicCommand(),
new FetchDataCommand(),
new SolvedCommand(),
//new FetchDataCommand(),
new InfoCommand(),
new EvalCommand(),
new GarfieldCommand(),
//new GarfieldCommand(),
new HelpCommand(),
new RestartCommand(),
new ActionDumpCommand(),
Expand All @@ -75,10 +78,10 @@ public static void initialize() throws LoginException {
new MutedCommand(),
new UnmuteCommand(),
new VerifyCommand(),
new PollCommand(),
// new PollCommand(), - Unused
new IdeaCommand(),
new StoreCommand(),
new ChannelMuteCommand(),
// new StoreCommand(),
// new ChannelMuteCommand(), - not finished
// statsbot
new StatsCommand(),
new SupportBadCommand(),
Expand All @@ -104,7 +107,7 @@ public static void initialize() throws LoginException {
new QueueCommand(),
new WhoHelpedCommand(),
new HelpedByCommand(),
new NamesCommand(),
// new NamesCommand(), - Dead
new PlayerJoinGraphCommand(),
//new CpCommand(),
//new CpRequirementsCommand(),
Expand All @@ -122,24 +125,23 @@ public static void initialize() throws LoginException {
new ExcuseStaffCommand(),
new ExcusedStaffCommand(),
new SupportBannedPlayersCommand(),
new DiscussionMuteCommand(),
new NbsCommand(),
new DailySessionsCommand(),
new EightBallCommand(),
new OcrCommand(),
// new OcrCommand(), - Dead
new JoinsCommand(),
new TagCommand(),
new PurgeCommand()
);

JDABuilder builder = JDABuilder.createDefault(config.getToken())
.enableIntents(GatewayIntent.GUILD_MEMBERS)
.enableIntents(GatewayIntent.GUILD_MEMBERS, GatewayIntent.MESSAGE_CONTENT, GatewayIntent.DIRECT_MESSAGES, GatewayIntent.DIRECT_MESSAGE_REACTIONS)
.setStatus(OnlineStatus.ONLINE)
.setMemberCachePolicy(MemberCachePolicy.NONE)
.setActivity(Activity.watching("for " + getConfig().getPrefix() + "help"))
.setGatewayEncoding(GatewayEncoding.ETF)
.disableCache(CacheFlag.ACTIVITY, CacheFlag.VOICE_STATE, CacheFlag.CLIENT_STATUS)
.addEventListeners(new MessageEvent(), new ReadyEvent(), new GuildJoinEvent(), new ButtonEvent(), new MessageEditEvent());
.addEventListeners(new MessageEvent(), new ReadyEvent(), new GuildJoinEvent(), new ButtonEvent(), new MessageEditEvent(), new PostAppliedTagsEvent(), new ChannelCreatedEvent(), new ChannelArchiveEvent());

jda = builder.build();
CommandHandler.getInstance().initialize();
Expand All @@ -149,10 +151,6 @@ public static JDA getJda() {
return jda;
}

public static OkHttpClient getHttpClient() {
return HTTP_CLIENT;
}

public static Config getConfig() {
return config;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package com.diamondfire.helpbot.bot.command.argument.impl.types.minecraft;

import com.diamondfire.helpbot.bot.HelpBotInstance;
import com.diamondfire.helpbot.bot.command.argument.impl.parsing.exceptions.ArgumentException;
import com.diamondfire.helpbot.bot.command.argument.impl.types.AbstractSimpleValueArgument;
import com.diamondfire.helpbot.bot.events.CommandEvent;
import com.diamondfire.helpbot.util.Util;
import com.diamondfire.helpbot.util.*;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import okhttp3.Request;
import okhttp3.ResponseBody;
import org.jetbrains.annotations.NotNull;

import java.io.IOException;
Expand All @@ -23,16 +19,9 @@ protected UUID parse(@NotNull String argument, CommandEvent event) throws Argume
return Util.toUuid(argument);
} else {
JsonObject responseObject = null;
ResponseBody res = null;
Request request = new Request.Builder().url("https://api.mojang.com/users/profiles/minecraft/" + argument).get().build();
try {
res = HelpBotInstance.getHttpClient().newCall(request).execute().body();
} catch (IOException e) {
e.printStackTrace();
}

try {
responseObject = JsonParser.parseString(res.string()).getAsJsonObject();
responseObject = WebUtil.getJson("https://api.mojang.com/users/profiles/minecraft/" + argument).getAsJsonObject();
} catch (IOException e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public void enable(Command command) {
}

public void disable(Command command) {
if (command == null) {
return;
}
// Prevents tricky people using eval.
if (command instanceof CommandDisableFlag) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
import com.diamondfire.helpbot.sys.interaction.button.ButtonHandler;
import com.diamondfire.helpbot.util.*;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.interactions.components.Button;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
import net.dv8tion.jda.api.entities.emoji.Emoji;
import net.dv8tion.jda.api.interactions.components.buttons.Button;

import java.util.*;
import java.util.function.BiConsumer;
Expand All @@ -22,7 +25,7 @@

public abstract class AbstractSingleQueryCommand extends Command {

public static void sendMultipleMessage(List<CodeObject> actions, TextChannel channel, long userToWait, BiConsumer<CodeObject, TextChannel> onChosen) {
public static void sendMultipleMessage(List<CodeObject> actions, GuildMessageChannel channel, long userToWait, BiConsumer<CodeObject, GuildMessageChannel> onChosen) {
// This here is to determine if all the duplicate types are the same. If not, we need to make sure that we filter those out first..
CodeObject referenceData = actions.get(0);
Class<? extends CodeObject> classReference = referenceData.getClass();
Expand All @@ -46,26 +49,26 @@ public static void sendMultipleMessage(List<CodeObject> actions, TextChannel cha
for (Map.Entry<BasicReaction, CodeObject> reaction : referenceData.getEnum().getEmbedBuilder().generateDupeEmojis(actions).entrySet()) {
Button button = Button.secondary(reaction.getKey().toString(), reaction.getValue().getName());

buttons.add(button.withEmoji(Emoji.fromEmote(reaction.getKey().getEmote())));
buttons.add(button.withEmoji(Emoji.fromCustom(reaction.getKey().getEmote())));
buttonMap.put(button.getId(), reaction.getValue());
}
} else {
for (CodeObject data : actions) {
long emoji = data.getEnum().getEmoji();
Button button = Button.secondary(String.valueOf(data.getEnum().getEmoji()), data.getName());

buttons.add(button.withEmoji(Emoji.fromEmote(HelpBotInstance.getJda().getEmoteById(emoji))));
buttons.add(button.withEmoji(HelpBotInstance.getJda().getEmojiById(emoji)));
buttonMap.put(button.getId(), data);
}
}

channel.sendMessageEmbeds(preset.getEmbed().build()).setActionRows(Util.of(buttons)).queue((message) -> {
channel.sendMessageEmbeds(preset.getEmbed().build()).setActionRow(buttons).queue((message) -> {
ButtonHandler.addListener(userToWait, message, (event) -> {
message.delete().queue();

// when msg is deleted causes nullpointer when tries to remove reactions! FIX
CodeObject object = buttonMap.get(event.getComponentId());
onChosen.accept(object, message.getTextChannel());
onChosen.accept(object, message.getChannel().asGuildMessageChannel());
});
});

Expand All @@ -83,9 +86,9 @@ public void run(CommandEvent event) {
getData(event, onDataReceived());
}

public abstract BiConsumer<CodeObject, TextChannel> onDataReceived();
public abstract BiConsumer<CodeObject, GuildMessageChannel> onDataReceived();

protected void getData(CommandEvent event, BiConsumer<CodeObject, TextChannel> onChosen) {
protected void getData(CommandEvent event, BiConsumer<CodeObject, GuildMessageChannel> onChosen) {
String name = event.getArgument("name");
PresetBuilder preset = new PresetBuilder();

Expand Down Expand Up @@ -118,9 +121,9 @@ protected void getData(CommandEvent event, BiConsumer<CodeObject, TextChannel> o

// If none, proceed. Else we need to special case that.
if (sameActions.size() == 1) {
onChosen.accept(sameActions.get(0), event.getChannel());
onChosen.accept(sameActions.get(0), event.getChannel().asGuildMessageChannel());
} else if (sameActions.size() > 1) {
sendMultipleMessage(sameActions, event.getChannel(), event.getMember().getIdLong(), onChosen);
sendMultipleMessage(sameActions, event.getChannel().asGuildMessageChannel(), event.getMember().getIdLong(), onChosen);
}

return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,24 @@
import com.diamondfire.helpbot.df.codeinfo.codedatabase.db.datatypes.CodeObject;
import com.diamondfire.helpbot.util.Util;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
import net.dv8tion.jda.api.utils.FileUpload;

import java.io.File;
import java.util.function.BiConsumer;


public class CodeCommand extends AbstractSingleQueryCommand {

public static <T extends CodeObject> void sendHelpMessage(T data, TextChannel channel) {
public static <T extends CodeObject> void sendHelpMessage(T data, GuildMessageChannel channel) {
EmbedBuilder builder = data.getEnum().getEmbedBuilder().generateEmbed(data);
String customHead = data.getItem().getHead();

if (customHead == null) {
File actionIcon = Util.fetchMinecraftTextureFile(data.getItem().getMaterial().toUpperCase());
builder.setThumbnail("attachment://" + actionIcon.getName());
channel.sendMessageEmbeds(builder.build()).addFile(actionIcon).queue();
channel.sendMessageEmbeds(builder.build()).addFiles(FileUpload.fromData(actionIcon)).queue();
} else {
builder.setThumbnail(customHead);
channel.sendMessageEmbeds(builder.build()).queue();
Expand Down Expand Up @@ -56,7 +58,7 @@ public void run(CommandEvent event) {
}

@Override
public BiConsumer<CodeObject, TextChannel> onDataReceived() {
public BiConsumer<CodeObject, GuildMessageChannel> onDataReceived() {
return CodeCommand::sendHelpMessage;
}
}
Loading