Skip to content

Commit

Permalink
Set up config and create reaction listener
Browse files Browse the repository at this point in the history
  • Loading branch information
java-coding-prodigy committed Sep 3, 2023
1 parent ae006d2 commit c556a05
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 1 deletion.
5 changes: 5 additions & 0 deletions application/config.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,9 @@
"rateLimitWindowSeconds": 10,
"rateLimitRequestsInWindow": 3
}
"oofsAndLmaos": {
"oofEmojiName": ":oof:"
"lmaoEmojiName": ":lmao"
"starboardChannelId": <put_channel_id_here>
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public final class Config {
private final String openaiApiKey;
private final String sourceCodeBaseUrl;
private final JShellConfig jshell;
private final OofsAndLmaosConfig oofsAndLmaos;

@SuppressWarnings("ConstructorWithTooManyParameters")
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
Expand Down Expand Up @@ -76,7 +77,8 @@ private Config(@JsonProperty(value = "token", required = true) String token,
required = true) String logErrorChannelWebhook,
@JsonProperty(value = "openaiApiKey", required = true) String openaiApiKey,
@JsonProperty(value = "sourceCodeBaseUrl", required = true) String sourceCodeBaseUrl,
@JsonProperty(value = "jshell", required = true) JShellConfig jshell) {
@JsonProperty(value = "jshell", required = true) JShellConfig jshell,
@JsonProperty(value = "oofsAndLmaos", required = true) OofsAndLmaosConfig oofsAndLmaos) {
this.token = Objects.requireNonNull(token);
this.gistApiKey = Objects.requireNonNull(gistApiKey);
this.databasePath = Objects.requireNonNull(databasePath);
Expand All @@ -102,6 +104,7 @@ private Config(@JsonProperty(value = "token", required = true) String token,
this.openaiApiKey = Objects.requireNonNull(openaiApiKey);
this.sourceCodeBaseUrl = Objects.requireNonNull(sourceCodeBaseUrl);
this.jshell = Objects.requireNonNull(jshell);
this.oofsAndLmaos = Objects.requireNonNull(oofsAndLmaos);
}

/**
Expand Down Expand Up @@ -341,5 +344,8 @@ public String getSourceCodeBaseUrl() {
*/
public JShellConfig getJshell() {
return jshell;
}
public OofsAndLmaosConfig getOofsAndLmaos() {
return oofsAndLmaos;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.togetherjava.tjbot.config;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonRootName;

@JsonRootName("oofsAndLmaos")
public final class OofsAndLmaosConfig {
private final String oofEmojiName;
private final String lmaoEmojiName;
private final long starboardChannelId;

@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public OofsAndLmaosConfig(String oofEmojiName, String lmaoEmojiName, long starboardChannelId) {
this.oofEmojiName = oofEmojiName;
this.lmaoEmojiName = lmaoEmojiName;
this.starboardChannelId = starboardChannelId;
}

public String getOofEmojiName() {
return oofEmojiName;
}

public String getLmaoEmojiName() {
return lmaoEmojiName;
}

public long getStarboardChannelId() {
return starboardChannelId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.togetherjava.tjbot.features.basic;

import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import org.jetbrains.annotations.NotNull;

import org.togetherjava.tjbot.config.Config;
import org.togetherjava.tjbot.config.OofsAndLmaosConfig;
import org.togetherjava.tjbot.features.EventReceiver;

public class OofsAndLmaosStarboard extends ListenerAdapter implements EventReceiver {

private final OofsAndLmaosConfig config;

public OofsAndLmaosStarboard(Config config) {
this.config = config.getOofsAndLmaos();
}

@Override
public void onMessageReactionAdd(@NotNull MessageReactionAddEvent event) {
String emojiName = event.getReaction().getEmoji().asCustom().getName();
MessageChannel channel = event.getChannel();
// TODO

}
}

0 comments on commit c556a05

Please sign in to comment.