Skip to content

Commit

Permalink
fix: Forgot to construct new roleids array on linkrole
Browse files Browse the repository at this point in the history
  • Loading branch information
benaclejames committed Apr 18, 2024
1 parent b942a98 commit fc7ffa3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ public static void VerifyLicense(IReplyCallback msg, String gumroadIdOrAlias, St

// Get Gumroad to RoleID
GumRole roleInfo = guild.getRoles().get(gumroadId);
if (roleInfo == null || roleInfo.RoleId == null) {
if (roleInfo == null || roleInfo.getRoleIds() == null) {
//guild.getGuildSettings().adminChannel.Announce("License Verification Failed", "User " + ConstructUserIdentifier(msg.getUser()) + " attempted to verify a license for " + gumroadId + " but no role was found.");
PrintError(msg, "Missing Role!", "Please alert a server administrator!");
return;
}

// Now check if this key has already been redeemed in this server. If it has and it was redeemed by a different person, reject it
// Now check if this key has already been redeemed in this server. If it has, and it was redeemed by a different person, reject it
GumPurchase purchase = DynamoHelper.GetPurchaseByKey(token);
if (purchase != null && purchase.getUserId() != msg.getMember().getIdLong()) {
PrintError(msg, "Someone else has already used this license key.", null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public void onSlashCommandInteraction(@Nonnull SlashCommandInteractionEvent even

GumRole newRole = new GumRole();
newRole.setRoleId(role.getIdLong());
newRole.setRoleIds(new Long[]{role.getIdLong()});
server.getRoles().put(productId, newRole);
server.getAliases().put(alias, productId);

Expand All @@ -118,6 +119,15 @@ public void onSlashCommandInteraction(@Nonnull SlashCommandInteractionEvent even
event.reply("Role unlinked Successfully!").setEphemeral(true).queue();
}
break;

case "addrole":
{
String productId = event.getOption("product_id").getAsString();
Role role = event.getOption("role").getAsRole();
GumServer server = DynamoHelper.GetServer(event.getGuild());


}
}
}

Expand Down
10 changes: 8 additions & 2 deletions src/main/java/com/benaclejames/gumcord/SetupHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ public static void updateGuildCommands(Guild guild, GumServer gumGuild) {
.setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.ADMINISTRATOR))
.setGuildOnly(false);

var addRole = Commands.slash("addrole", "Adds a role to a Gumroad product")
.addOptions(products)
.addOption(OptionType.ROLE, "role", "Role to add", true)
.setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.MANAGE_ROLES))
.setGuildOnly(true);


guild.updateCommands().addCommands(unlinkProduct, getMemberInfo).queue();
}
Expand All @@ -86,13 +92,13 @@ public void onReady(@Nonnull ReadyEvent event) {
.setGuildOnly(true);

var linkRole = Commands.slash("linkrole", "Links a Gumroad product to a Discord role")
.addOption(OptionType.STRING, "product_id", "Product Name", true)
.addOption(OptionType.STRING, "product_id", "Product Id", true)
.addOption(OptionType.ROLE, "role", "Role to link", true)
.addOption(OptionType.STRING, "alias", "Alias to use in the verification selection", true)
.setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.MANAGE_ROLES))
.setGuildOnly(true);

Main.jda.updateCommands().addCommands(spawnVerify).addCommands(linkRole).queue();
Main.jda.updateCommands().addCommands(spawnVerify, linkRole).queue();
System.out.println("Commands registered. Bot Ready!");
}
}

0 comments on commit fc7ffa3

Please sign in to comment.