Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 changes: 0 additions & 2 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: Build and Deploy
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
REGISTRY: ghcr.io
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ WORKDIR /app
LABEL internal-port="8080"

LABEL arachne.name="Ninetales Discord Bot"
LABEL arachne.version="1.1.4"
LABEL arachne.version="1.1.5"

LABEL ninetales.update-note="Fixed bugs\nEdited descriptions"
LABEL ninetales.update-note="Fixed unknown roles (soggy)"

# Copy the built JAR from build stage
COPY --from=build /app/target/*.jar ./app.jar
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>ws.mia</groupId>
<artifactId>ninetales</artifactId>
<version>1.0</version>
<version>1.0</version> <!-- This is not used. See the Dockerfile version label instead. -->
<name>ninetales</name>
<description>ninetales</description>
<url/>
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/ws/mia/ninetales/discord/GuildRankService.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ public void syncRoles(boolean retrieve) {
List<Role> rolesToRemove = allGuildRoles;
rolesToRemove.removeIf(r -> r.getId().equals(rank.getDiscordRoleId()));
rolesToRemove.add(visitorRole);
List<Role> rolesToAdd = List.of(rank.getRole(guild), guildMemberRole);
List<Role> rolesToAdd = new ArrayList<>(List.of(guildMemberRole));
Role specificGuildRole = rank.getRole(guild); // could be unknown -> null
if(specificGuildRole != null) {
rolesToAdd.add(specificGuildRole);
}
rolesToRemove.removeAll(rolesToAdd); // We want to add the intersection. (since GM role is the same as Tail role)

guild.modifyMemberRoles(dcMember,
Expand Down Expand Up @@ -161,7 +165,6 @@ public void syncFirstRole(Member userToSync, Guild guild) {
if (players == null) return; // fail

HypixelAPI.GuildPlayer player = players.get(user.getMinecraftUuid());

if (player == null) {
mongoUserService.setDiscordMember(user.getDiscordId(), false);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ public void closeApplication(SlashCommandInteractionEvent event) {
mongoUserService.setAwaitingHypixelInvite(ntUser.getDiscordId(), false);
});


if (ntUser.getTailDiscussionChannelId() != null) {
mongoUserService.setTailDiscussionChannelId(ntUser.getDiscordId(), null);
event.getGuild().getTextChannelById(ntUser.getTailDiscussionChannelId()).delete().queue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public DiscordRuntimeService(DiscordLogService discordLogService, Environment en
this.environment = environment;
}



@PostConstruct
private void init() throws IOException {
if(List.of(environment.getActiveProfiles()).contains("dev")) {
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/ws/mia/ninetales/hypixel/HypixelGuildRank.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ws.mia.ninetales.hypixel;

import jakarta.annotation.Nullable;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Role;
import org.springframework.stereotype.Component;
Expand All @@ -9,8 +10,8 @@ public enum HypixelGuildRank {
GUILD_MASTER("Guild Master", EnvironmentServiceInjector.environmentService.getTailRoleId()),
TAIL("Tails", EnvironmentServiceInjector.environmentService.getTailRoleId()),
VULPIX("Vulpix", EnvironmentServiceInjector.environmentService.getVulpixRoleId()),
EGG("Egg", EnvironmentServiceInjector.environmentService.getEggRoleId());

EGG("Egg", EnvironmentServiceInjector.environmentService.getEggRoleId()),
UNKNOWN(null, null);

private final String hypixelRankName;
private final String discordRoleId;
Expand All @@ -21,14 +22,17 @@ public enum HypixelGuildRank {
}

public String getHypixelRankName() {
return hypixelRankName;
return hypixelRankName != null ? hypixelRankName : "Unknown";
}

@Nullable
public String getDiscordRoleId() {
return discordRoleId;
}

@Nullable
public Role getRole(Guild guild){
if(getDiscordRoleId() == null) return null;
return guild.getRoleById(getDiscordRoleId());
}

Expand All @@ -38,7 +42,7 @@ public static HypixelGuildRank fromHypixel(String hypixelRankName) {
return rank;
}
}
return null;
return UNKNOWN;
}

@Component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public Map<UUID, GuildPlayer> getGuildPlayers() {

HypixelGuildRank rank = HypixelGuildRank.fromHypixel(rankName);

if (rank != null) {
if (rank != null && uuidStr != null && rankName != null) {
retMap.put(uuid, new GuildPlayer(uuid, rank, joinTs));
}
}
Expand Down