Skip to content

Commit

Permalink
Fixed wrong queries.
Browse files Browse the repository at this point in the history
  • Loading branch information
DxsSucuk committed Jan 2, 2024
1 parent c395a7c commit 1449627
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<groupId>de.presti</groupId>
<artifactId>Ree6</artifactId>
<version>3.1.0</version>
<version>3.1.1</version>
<packaging>jar</packaging>

<properties>
Expand Down Expand Up @@ -156,7 +156,7 @@
<dependency>
<groupId>de.ree6</groupId>
<artifactId>Ree6-SQL</artifactId>
<version>2.2.0</version>
<version>2.2.2</version>
</dependency>

<!-- Logging -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void onPerform(CommandEvent commandEvent) {
}

ReactionRole reactionRole = SQLSession.getSqlConnector().getSqlWorker().getEntity(new ReactionRole(),
"FROM ReactionRole WHERE guildAndId.guildId=:gid AND roleId=:roleId AND messageId=:messageId",
"FROM ReactionRole WHERE guildRoleId.guildId=:gid AND guildRoleId.roleId=:roleId AND messageId=:messageId",
Map.of("gid", commandEvent.getGuild().getIdLong(), "roleId", role.getAsRole().getIdLong(), "messageId", messageId));

if (reactionRole != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void onPerform(CommandEvent commandEvent) {
switch (subCommandGroup) {
case "manage" -> {
StreamAction streamAction = SQLSession.getSqlConnector().getSqlWorker()
.getEntity(new StreamAction(), "FROM StreamAction WHERE actionName = :name AND guildAndId.guildId = :gid",
.getEntity(new StreamAction(), "FROM StreamAction WHERE guildAndName.name = :name AND guildAndName.guildId = :gid",
Map.of("name", name.getAsString(), "gid", commandEvent.getGuild().getIdLong()));

if (streamAction != null) {
Expand Down Expand Up @@ -164,7 +164,7 @@ public void onPerform(CommandEvent commandEvent) {
switch (subCommand) {
case "create" -> {
StreamAction streamAction = SQLSession.getSqlConnector().getSqlWorker()
.getEntity(new StreamAction(), "FROM StreamAction WHERE actionName = :name AND guildAndId.guildId = :gid",
.getEntity(new StreamAction(), "FROM StreamAction WHERE guildAndName.actionName = :name AND guildAndName.guildId = :gid",
Map.of("name", name.getAsString(), "gid", commandEvent.getGuild().getIdLong()));

if (streamAction == null) {
Expand All @@ -174,7 +174,7 @@ public void onPerform(CommandEvent commandEvent) {
streamAction = new StreamAction();
streamAction.setIntegration(twitchIntegration);
streamAction.setGuildId(commandEvent.getGuild().getIdLong());
streamAction.setActionName(name.getAsString());
streamAction.setName(name.getAsString());

SQLSession.getSqlConnector().getSqlWorker().updateEntity(streamAction);
commandEvent.reply(commandEvent.getResource("message.stream-action.added", name.getAsString()));
Expand All @@ -188,7 +188,7 @@ public void onPerform(CommandEvent commandEvent) {

case "delete" -> {
StreamAction streamAction = SQLSession.getSqlConnector().getSqlWorker()
.getEntity(new StreamAction(), "FROM StreamAction WHERE actionName = :name AND guildAndId.guildId = :gid",
.getEntity(new StreamAction(), "FROM StreamAction WHERE guildAndName.actionName = :name AND guildAndName.guildId = :gid",
Map.of("name", name.getAsString(), "gid", commandEvent.getGuild().getIdLong()));
if (streamAction != null) {
SQLSession.getSqlConnector().getSqlWorker().deleteEntity(streamAction);
Expand All @@ -200,11 +200,11 @@ public void onPerform(CommandEvent commandEvent) {

case "list" -> {
List<StreamAction> streamActions = SQLSession.getSqlConnector().getSqlWorker()
.getEntityList(new StreamAction(), "FROM StreamAction WHERE guildAndId.guildId = :gid",
.getEntityList(new StreamAction(), "FROM StreamAction WHERE guildAndName.guildId = :gid",
Map.of("gid", commandEvent.getGuild().getIdLong()));

commandEvent.reply(LanguageService.getByEvent(commandEvent, "message.stream-action.list",
String.join("\n", streamActions.stream().map(StreamAction::getActionName).toArray(String[]::new))));
String.join("\n", streamActions.stream().map(StreamAction::getName).toArray(String[]::new))));
}

case "points" -> {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/de/presti/ree6/commands/impl/info/Help.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public void sendHelpInformation(String categoryString, CommandEvent commandEvent
String prefix = SQLSession.getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getIdLong(), "chatprefix").getStringValue();
for (Category cat : Category.values()) {
if (cat != Category.HIDDEN) {
if (!BotConfig.isModuleActive(cat.name().toLowerCase())) continue;

String formattedName = cat.name().toUpperCase().charAt(0) + cat.name().substring(1).toLowerCase();
em.addField("**" + formattedName + "**", prefix + "help " + cat.name().toLowerCase(), true);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/presti/ree6/events/LoggingEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void onGuildUpdateVanityCode(@NotNull GuildUpdateVanityCodeEvent event) {
if (!event.getGuild().getSelfMember().hasPermission(Permission.MANAGE_SERVER)) return;

Invite invite = event.getOldVanityCode() != null ?
SQLSession.getSqlConnector().getSqlWorker().getEntity(new Invite(), "FROM Invite WHERE guildAndId.guild = :gid AND code = :code",
SQLSession.getSqlConnector().getSqlWorker().getEntity(new Invite(), "FROM Invite WHERE guildAndCode.guild = :gid AND guildAndCode.code = :code",
Map.of("gid", event.getGuild().getIdLong(), "code", event.getOldVanityCode()))
: null;

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/de/presti/ree6/events/OtherEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -560,10 +560,10 @@ public void onMessageReactionAdd(@NotNull MessageReactionAddEvent event) {
}
}
} else {
ReactionRole reactionRole = SQLSession.getSqlConnector().getSqlWorker().getEntity(new ReactionRole(), "FROM ReactionRole WHERE guildAndId.guildId=:gid AND emoteId=:emoteId AND messageId=:messageId", Map.of("gid", event.getGuild().getIdLong(), "emoteId", emojiId, "messageId", message.getIdLong()));
ReactionRole reactionRole = SQLSession.getSqlConnector().getSqlWorker().getEntity(new ReactionRole(), "FROM ReactionRole WHERE guildRoleId.guildId=:gid AND emoteId=:emoteId AND messageId=:messageId", Map.of("gid", event.getGuild().getIdLong(), "emoteId", emojiId, "messageId", message.getIdLong()));

if (reactionRole != null) {
Role role = event.getGuild().getRoleById(reactionRole.getRoleId());
Role role = event.getGuild().getRoleById(reactionRole.getId());

if (role != null) {
event.getGuild().addRoleToMember(event.getMember(), role).queue();
Expand Down Expand Up @@ -606,11 +606,11 @@ public void onMessageReactionRemove(@NotNull MessageReactionRemoveEvent event) {
}

ReactionRole reactionRole = SQLSession.getSqlConnector().getSqlWorker().getEntity(new ReactionRole(),
"FROM ReactionRole WHERE guildAndId.guildId=:gid AND emoteId=:emoteId AND messageId=:messageId",
"FROM ReactionRole WHERE guildRoleId.guildId=:gid AND emoteId=:emoteId AND messageId=:messageId",
Map.of("gid", event.getGuild().getIdLong(), "emoteId", emojiId, "messageId", event.getMessageIdLong()));

if (reactionRole != null) {
Role role = event.getGuild().getRoleById(reactionRole.getRoleId());
Role role = event.getGuild().getRoleById(reactionRole.getId());

if (role != null) {
event.getGuild().removeRoleFromMember(event.getMember(), role).queue();
Expand Down

0 comments on commit 1449627

Please sign in to comment.