feat: started working on shop
This commit is contained in:
parent
61cdad8b21
commit
ccdfa9abcf
4 changed files with 152 additions and 0 deletions
|
@ -79,6 +79,7 @@ object Bot {
|
||||||
add(::AwakeExtension)
|
add(::AwakeExtension)
|
||||||
add(::ProfileExtension)
|
add(::ProfileExtension)
|
||||||
add(::TopExtension)
|
add(::TopExtension)
|
||||||
|
// add(::ShopExtension)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.presence {
|
this.presence {
|
||||||
|
|
|
@ -0,0 +1,97 @@
|
||||||
|
/*
|
||||||
|
* Bedge
|
||||||
|
* Copyright (C) 2023 moonleay
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.moonleay.bedge.extensions
|
||||||
|
|
||||||
|
import com.kotlindiscord.kord.extensions.commands.Arguments
|
||||||
|
import com.kotlindiscord.kord.extensions.commands.application.slash.converters.impl.enumChoice
|
||||||
|
import com.kotlindiscord.kord.extensions.extensions.Extension
|
||||||
|
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
|
||||||
|
import com.kotlindiscord.kord.extensions.types.respond
|
||||||
|
import net.moonleay.bedge.data.database.repository.UserRepository
|
||||||
|
import net.moonleay.bedge.extensions.component.ShopAction
|
||||||
|
import net.moonleay.bedge.extensions.component.ShopItem
|
||||||
|
import net.moonleay.bedge.util.EmbedColor
|
||||||
|
import net.moonleay.bedge.util.MessageUtil
|
||||||
|
|
||||||
|
class ShopExtension : Extension() {
|
||||||
|
|
||||||
|
override val name = "shop"
|
||||||
|
override val allowApplicationCommandInDMs: Boolean
|
||||||
|
get() = false
|
||||||
|
|
||||||
|
|
||||||
|
override suspend fun setup() {
|
||||||
|
publicSlashCommand(::ShopArguments) {
|
||||||
|
name = "shop"
|
||||||
|
description = "Buy stuff with your items"
|
||||||
|
|
||||||
|
this.action {
|
||||||
|
val user = this.user.asUser()
|
||||||
|
val ud = UserRepository.getUserByID(user.id.value)
|
||||||
|
|
||||||
|
if (ud == null) {
|
||||||
|
this.respond {
|
||||||
|
this.embeds.add(
|
||||||
|
MessageUtil.getEmbed(EmbedColor.ERROR,
|
||||||
|
"You don't have an account here!",
|
||||||
|
"And therefore I cannot show you our shop.\n" +
|
||||||
|
"You can register by running `/time`.",
|
||||||
|
user.username)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return@action
|
||||||
|
}
|
||||||
|
when(this.arguments.action){
|
||||||
|
ShopAction.LIST_OFFERS -> {
|
||||||
|
var description = "Your Coins: ${ud.coins}\n" +
|
||||||
|
"Your lvl: ${ud.level}\n\n" +
|
||||||
|
"item :: price :: required level\n"
|
||||||
|
|
||||||
|
ShopItem.entries.forEach { itm ->
|
||||||
|
description += "\"${itm.readableName}\" :: ${itm.cost} coins :: ${itm.requiredLevel}\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
this.respond {
|
||||||
|
this.embeds.add(
|
||||||
|
MessageUtil.getEmbed(
|
||||||
|
EmbedColor.INFO,
|
||||||
|
"The Shop",
|
||||||
|
description,
|
||||||
|
user.username
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ShopAction.BUY -> {
|
||||||
|
var description = ""
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inner class ShopArguments : Arguments() {
|
||||||
|
|
||||||
|
val action by enumChoice<ShopAction> {
|
||||||
|
this.name = "action"
|
||||||
|
this.description = "What you want to do"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* Bedge
|
||||||
|
* Copyright (C) 2023 moonleay
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.moonleay.bedge.extensions.component
|
||||||
|
|
||||||
|
import com.kotlindiscord.kord.extensions.commands.application.slash.converters.ChoiceEnum
|
||||||
|
|
||||||
|
enum class ShopAction(override val readableName: String) : ChoiceEnum {
|
||||||
|
LIST_OFFERS("list offers"),
|
||||||
|
BUY("buy")
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Bedge
|
||||||
|
* Copyright (C) 2023 moonleay
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.moonleay.bedge.extensions.component
|
||||||
|
|
||||||
|
import com.kotlindiscord.kord.extensions.commands.application.slash.converters.ChoiceEnum
|
||||||
|
|
||||||
|
enum class ShopItem(override val readableName: String, val itemDescription: String, val cost: Int, val requiredLevel: Int) : ChoiceEnum {
|
||||||
|
ADD_CUSTOM_SERVER_MOTD("Add a custom MOTD", "Add a MOTD to my minecraft server", 2, 0),
|
||||||
|
REMOVE_DEATH_FROM_COUNTER("Remove Death", "Remove a death from the death counter on my minecraft server", 21, 4),
|
||||||
|
UPDATE_WAKEUP_MESSAGE("Update wakeup msg", "Update the message the bot sends, when you wake up", 4, 2),
|
||||||
|
UPDATE_REMINDER_MESSAGE("Update reminder msg","Update the message the bot sends you to remind you to go to bed", 4, 2)
|
||||||
|
}
|
Loading…
Reference in a new issue