Skip to content

Commit 7f80e4a

Browse files
Add tag support (#43)
* fixed an issue with gradle * cleanup * starting work on tag commands * added owner only to help command * Finished with tag command need to test it * done
1 parent 7ad248f commit 7f80e4a

25 files changed

+1092
-59
lines changed

build.gradle

+17-7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
* See the License for the specific language governing permissions and
1717
* limitations under the License.
1818
*/
19+
20+
import groovy.json.JsonSlurper
1921
import nu.studer.gradle.jooq.JooqEdition
2022

2123
buildscript {
@@ -50,7 +52,7 @@ dependencies {
5052
implementation group: 'ch.qos.logback', name: 'logback-core', version: '1.4.0'
5153
//implementation group: 'uk.org.lidalia', name: 'sysout-over-slf4j', version: '1.0.2'
5254
//config
53-
implementation group: 'io.github.realyusufismail', name: 'jconfig', version: '1.0.5'
55+
implementation group: 'io.github.realyusufismail', name: 'jconfig', version: '1.0.6'
5456
//database
5557
implementation group: 'com.zaxxer', name: 'HikariCP', version: '5.0.1'
5658
implementation group: 'org.postgresql', name: 'postgresql', version: '42.5.0'
@@ -147,10 +149,18 @@ jar {
147149
}
148150

149151

150-
def props = new Properties()
152+
def props = new Hashtable<String,Object>()
151153
//if the file exists, load the properties
152154
if (file("config.json").exists()) {
153-
file("config.json").withInputStream { props.load(it) }
155+
def jsonFile = file('config.json')
156+
157+
if (jsonFile.exists()) {
158+
def jsonSlurper = new JsonSlurper()
159+
def json = jsonSlurper.parseText(jsonFile.text)
160+
props.putAll(json)
161+
} else {
162+
throw new GradleException("config.json does not exist!")
163+
}
154164
}
155165

156166
//create the build directory so no errors happen with the workflow
@@ -166,7 +176,7 @@ task createBuildDir {
166176

167177

168178
jooq {
169-
version = '3.15.2'
179+
version = '3.17.3'
170180
edition = JooqEdition.OSS
171181
configurations {
172182
main {
@@ -175,9 +185,9 @@ jooq {
175185
logging = org.jooq.meta.jaxb.Logging.WARN
176186
jdbc {
177187
driver = 'org.postgresql.Driver'
178-
url = props.getProperty("DB_URL", "null")
179-
user = props.getProperty("DB_USER", "null")
180-
password = props.getProperty("DB_PASSWORD", "null")
188+
url = props.get("DB_URL") as String
189+
user = props.get("DB_USER") as String
190+
password = props.get("DB_PASSWORD") as String
181191
}
182192
generator {
183193
name = 'org.jooq.codegen.JavaGenerator'

src/main/java/io/github/org/programming/bot/RegisterSlashCommands.java

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import io.github.org.programming.bot.commands.thread.CloseAskThread;
3232
import io.github.org.programming.bot.commands.thread.EditAskThread;
3333
import io.github.org.programming.bot.config.BotConfig;
34+
import io.github.org.programming.bot.tag.TagCommand;
3435
import net.dv8tion.jda.api.JDA;
3536
import net.dv8tion.jda.api.entities.Guild;
3637
import org.jetbrains.annotations.NotNull;
@@ -61,6 +62,7 @@ protected RegisterSlashCommands(@NotNull JDA jda, @NotNull Guild guild) {
6162
extenders.add(new BotInfoCommand());
6263
extenders.add(new ServerInfoCommand());
6364
extenders.add(new RestartCommand());
65+
extenders.add(new TagCommand());
6466

6567
// Always keep at the end
6668
extenders.add(new HelpCommand(extenders));

src/main/java/io/github/org/programming/bot/commands/help/HelpCommand.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public class HelpCommand extends SlashCommandExtender {
4040
private final List<SlashCommand> infoCommands = new ArrayList<>();
4141
private final List<SlashCommand> supportCommands = new ArrayList<>();
4242
private final List<SlashCommand> normalCommands = new ArrayList<>();
43+
private final List<SlashCommand> ownerCommands = new ArrayList<>();
4344

4445

4546
public HelpCommand(List<SlashCommandExtender> commands) {
@@ -72,6 +73,8 @@ else if (type == CommandType.SUPPORT)
7273
supportCommands.add(command);
7374
else if (type == CommandType.NORMAL)
7475
normalCommands.add(command);
76+
else if (type == CommandType.OWNER_ONLY)
77+
ownerCommands.add(command);
7578
});
7679

7780
var embedBuilder = new EmbedBuilder();
@@ -84,7 +87,7 @@ else if (type == CommandType.NORMAL)
8487
Button.primary("utility", "Utility"), Button.primary("fun", "Fun"),
8588
Button.primary("music", "Music"))
8689
.addActionRow(Button.primary("info", "Info"), Button.primary("support", "Support"),
87-
Button.primary("normal", "Normal"))
90+
Button.primary("normal", "Normal"), Button.primary("owner", "Owner"))
8891
.queue();
8992
}
9093

@@ -114,6 +117,9 @@ public void onButtonInteraction(@NotNull ButtonInteractionEvent event) {
114117
case "normal" -> event
115118
.editMessageEmbeds(new HelpEmbed(normalCommands, CommandType.NORMAL).build())
116119
.queue();
120+
case "owner" -> event
121+
.editMessageEmbeds(new HelpEmbed(ownerCommands, CommandType.OWNER_ONLY).build())
122+
.queue();
117123
}
118124
}
119125

src/main/java/io/github/org/programming/bot/commands/owner/RestartCommand.java

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import io.github.org.programming.backend.type.CommandType;
2525
import io.github.org.programming.bot.ProgrammingBot;
2626
import io.github.org.programming.bot.commands.util.GuildOnlyCommand;
27-
import net.dv8tion.jda.api.entities.GuildChannel;
2827
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
2928
import org.jetbrains.annotations.NotNull;
3029
import org.slf4j.Logger;

0 commit comments

Comments
 (0)