-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Spotify song handling and add DieCommand for enhanced user i…
…nteraction
- Loading branch information
1 parent
4627d3b
commit a9cde8d
Showing
9 changed files
with
58 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# Release Notes | ||
|
||
- Fixing audio reproduction. | ||
- Updated to version 3.0 | ||
- Port the bot to Spring Boot | ||
- Play from file command removed | ||
- Die command added |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/net/andrecarbajal/naviMusic/commands/general/DieCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package net.andrecarbajal.naviMusic.commands.general; | ||
|
||
import net.andrecarbajal.naviMusic.commands.SlashCommand; | ||
import net.andrecarbajal.naviMusic.dto.response.RichResponse; | ||
import net.dv8tion.jda.api.entities.Member; | ||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; | ||
import net.dv8tion.jda.api.interactions.commands.OptionType; | ||
import net.dv8tion.jda.api.interactions.commands.build.OptionData; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class DieCommand extends SlashCommand { | ||
public DieCommand() { | ||
super("die", "Rolls a die", Category.GENERAL); | ||
addOption(new OptionData(OptionType.INTEGER, "sides", "Number of sides on the die", false)); | ||
} | ||
|
||
@Override | ||
public void onCommand(SlashCommandInteractionEvent event) { | ||
Member member = event.getMember(); | ||
assert member != null; | ||
|
||
int sides = event.getOption("sides") == null ? 6 : (int) event.getOption("sides").getAsLong(); | ||
int roll = (int) (Math.random() * sides) + 1; | ||
|
||
RichResponse.builder() | ||
.title(String.format("Roll of a %d-sided die", sides)) | ||
.text(String.format("%s rolled a %d", member.getEffectiveName(), roll)) | ||
.build() | ||
.sendReply(event); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters