Skip to content

Commit

Permalink
Moved auction remind command to remind command
Browse files Browse the repository at this point in the history
  • Loading branch information
MysticFyr3 committed May 5, 2024
1 parent d5dc97a commit c706f5b
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ object AuctionCommand : ParentCommand() {
override val name = "Auction"
override var aliases = arrayOf("ah", "au", "auctions")
override val childCommands: MutableList<Command> =
mutableListOf(BidCommand, InfoCommand, ListCommand, UnlistCommand, ProfileCommand, RemindCommand)
mutableListOf(BidCommand, InfoCommand, ListCommand, UnlistCommand, ProfileCommand)

suspend fun formatAuctions(
context: ICommandContext,
Expand Down Expand Up @@ -69,9 +69,7 @@ object AuctionCommand : ParentCommand() {

val templateEmbedBuilder =
EmbedBuilder()
.setTitle(
context.translate("modules.auctions.commands.auctions.embeds.title")
)
.setTitle(context.translate("modules.auction.embeds.auction.title"))
.setColor(EmbedTemplates.Color.YELLOW.code)

val searchOptions =
Expand Down Expand Up @@ -103,17 +101,17 @@ object AuctionCommand : ParentCommand() {
val count = context.bot.database.auctionRepository.getAuctionCount(aggregation = aggregation.toMutableList())
if (count < 1) {
context.reply(
templateEmbedBuilder.setDescription(context.translate("modules.auctions.commands.auctions.errors.noResults"))
.setColor(EmbedTemplates.Color.RED.code).build()
templateEmbedBuilder.setDescription(context.translate("modules.auction.errors.auction.noAuctions"))
.setColor(EmbedTemplates.Color.RED.code).setFooter("misc.embeds.error.footer").build()
).queue()
return
}

val pageCount = ceil((count.toDouble() / 10)).toInt()
val paginator = EmbedPaginator(context, pageCount, { pageIndex ->
if (pageIndex >= pageCount) {
return@EmbedPaginator templateEmbedBuilder.setDescription(context.translate("modules.auctions.commands.auctions.errors.noResults"))
.setColor(EmbedTemplates.Color.RED.code).setFooter("")
return@EmbedPaginator templateEmbedBuilder.setDescription(context.translate("modules.auction.errors.auction.noResults"))
.setColor(EmbedTemplates.Color.RED.code).setFooter("misc.embeds.error.footer")
}
val auctionsList = context.bot.database.auctionRepository.getAuctionList(
skip = pageIndex * 10,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import xyz.pokecord.bot.utils.EmbedPaginator
class HelpCommand : Command() {
override val name = "Help"

override var aliases = arrayOf("h", "commands", "command")
override var aliases = arrayOf("h", "cmds", "commands", "command", "cmd")

private suspend fun getCommands(
context: ICommandContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,20 @@ class PokedexCommand : Command() {
val id = pokemonNameOrId.toIntOrNull()
val pokemon = if (id != null) Pokemon.getById(id) else Pokemon.getByName(pokemonNameOrId)

if (pokemon == null || !pokemon.hasShiny) {
if (pokemon == null) {
context.reply(
context.embedTemplates.error(context.translate("misc.errors.pokemonNotFound")).build()
).queue()
return
}

if (!pokemon.hasShiny) {
context.reply(
context.embedTemplates.error(context.translate("modules.pokemon.commands.pokedex.errors.noShiny")).build()
).queue()
return
}

val genderRate =
if (pokemon.species.genderRate == -1) context.translate("misc.texts.genderless")
else "${100 - pokemon.species.genderRate * 12.5}% ${context.translate("misc.texts.male")}, ${pokemon.species.genderRate * 12.5}% ${
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,69 @@ object RemindCommand : Command() {
override var aliases = arrayOf("rm", "rms", "rmd", "reminder", "reminders")

private val voteAliases = arrayOf("vote", "v", "next vote reminder")
private val auctionAliases = arrayOf("au", "ah", "auction", "auction activity")

@Executor
suspend fun execute(
context: ICommandContext,
@Argument(name = "reminder name", optional = true) reminder: String?
) {
val userData = context.getUserData()
val enabled = "`ENABLED`"
val disabled = "`DISABLED`"
val userData = context.getUserData()

if (reminder == null) {
context.reply(
context.embedTemplates.normal(
context.translate("modules.profile.commands.remind.embed.description.base",
mapOf(
"vote" to if (userData.voteReminder) enabled else disabled
"vote" to if (userData.voteReminder) enabled else disabled,
"auction" to if (userData.bidNotifications) enabled else disabled
)
),
context.translate("modules.profile.commands.remind.embed.title.base",
"user" to context.author.asTag
)
).setFooter(context.translate("modules.profile.commands.remind.embed.footer")).build()
).queue()
return
}
else {
val lowerCaseReminder = reminder.lowercase()
val vote = voteAliases.contains(lowerCaseReminder)
val userInput = reminder.lowercase()
val vote = voteAliases.contains(userInput)
val auction = auctionAliases.contains(userInput)

if(vote) {
if (vote) {
context.reply(
context.embedTemplates.normal(
context.translate(
if (userData.voteReminder) "modules.profile.commands.remind.embed.description.disabled"
else "modules.profile.commands.remind.embed.description.enabled"
),
context.translate(
"modules.profile.commands.remind.embed.title.toggle",
"reminderType" to "Vote"
)
).build()
).queue()
module.bot.database.userRepository.toggleVoteReminder(userData)
return
}

if (auction) {
context.reply(
context.embedTemplates.normal(
context.translate(
if (userData.voteReminder) "modules.profile.commands.remind.embed.description.enabled"
else "modules.profile.commands.remind.embed.description.disabled"
if (userData.voteReminder) "modules.profile.commands.remind.embed.description.disabled"
else "modules.profile.commands.remind.embed.description.enabled"
),
context.translate("modules.profile.commands.remind.embed.title.toggle",
"reminderType" to "Vote")
context.translate(
"modules.profile.commands.remind.embed.title.toggle",
"reminderType" to "Auction"
)
).build()
).queue()
context.bot.database.userRepository.toggleBidNotifications(userData)
return
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/main/resources/i18n/en-US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ misc:
#release: Transfers Pokémon to Professor Zihadikarp.
select: Selects a Pokémon, becoming your active Pokémon.
pokepedia:
forecast: Displays current weather, events, and time of day.
move: Displays specified move's information.
moveset: Recommends movesets for legendary and mythical Pokémon.
pokedex: Displays Pokémon base stats and general information.
Expand All @@ -64,6 +65,7 @@ misc:
"profile.info": Displays user statistics.
"profile.pokedex": Displays all Pokémon registered to Pokédex. Includes shinies.
private: Toggles your progress visibility to public/private.
remind: Displays all reminders. Specify reminder type for toggling.
staff:
blacklist: Prevent users from executing Pokecord commands.
blacklists: View a full list of all blacklisted users.
Expand Down Expand Up @@ -1003,6 +1005,10 @@ modules:
footers:
caught: This Pokémon is registered to your Pokédex!
uncaught: This Pokémon has not been registered to your Pokédex!
errors:
noShiny: |-
Pokecord triple checked the records, to no avail.
> **This Pokémon forme/variant has no shiny.**
forecast:
description: |-
*Pokecord is currently detecting no anomalies.*
Expand Down Expand Up @@ -1192,8 +1198,8 @@ modules:
More reminders will be added soon!
**Next Vote Reminder**: {{vote}}
disabled: You will no longer receive DMs when your next votes are ready.
enabled: You will now be DMed when your next votes are ready.
disabled: You will no longer be DMed regarding these notifications.
enabled: You will now be DMed when these notifications are due.
title:
base: "{{user}}'s Reminders"
toggle: "{{reminderType}} Reminder Toggled"
Expand Down

0 comments on commit c706f5b

Please sign in to comment.