mirror of
https://github.com/wlinator/luminara.git
synced 2024-10-02 18:23:12 +00:00
Remove sell command
This commit is contained in:
parent
8fb1ee2590
commit
3e9995902f
4 changed files with 2 additions and 308 deletions
|
@ -1,59 +0,0 @@
|
|||
REPLACE INTO item
|
||||
(name, display_name, description, image_url, emote_id, quote, type)
|
||||
VALUES (
|
||||
"apple",
|
||||
"apple",
|
||||
"This is just an apple.. An item used for testing.",
|
||||
"https://i.imgur.com/ykQO3sH.png",
|
||||
1121491265658306692,
|
||||
"The rarest item in Racu, you literally can't get this.",
|
||||
"collectible"
|
||||
);
|
||||
|
||||
REPLACE INTO item
|
||||
(name, display_name, description, image_url, emote_id, quote, type)
|
||||
VALUES (
|
||||
"tester_badge",
|
||||
"tester badge",
|
||||
"A badge awarded to the people who helped make Racu.",
|
||||
"https://i.imgur.com/Z8zQXuQ.png",
|
||||
1121491902370418869,
|
||||
"Thank you for the support <3",
|
||||
"badge"
|
||||
);
|
||||
|
||||
REPLACE INTO item
|
||||
(name, display_name, description, image_url, emote_id, quote, type)
|
||||
VALUES (
|
||||
"bitch_coin",
|
||||
"bitchcoin",
|
||||
"Awarded on getting a natural hand (21 on the first two cards) in **/blackjack**. One of these coins is worth just as much as the number of bitches you have.",
|
||||
"https://i.imgur.com/Ztj9ZMB.png",
|
||||
1124044941702733925,
|
||||
"You may still be bitchless but at least you have this coin.",
|
||||
"collectible"
|
||||
);
|
||||
|
||||
REPLACE INTO item
|
||||
(name, display_name, description, image_url, emote_id, quote, type)
|
||||
VALUES (
|
||||
"rave_coin",
|
||||
"ravecoin",
|
||||
"Awarded on winning a bet of $9,000 or more.",
|
||||
"https://i.imgur.com/iROwZ6T.png",
|
||||
1125357545180110878,
|
||||
"IT'S OVER 9000!!!",
|
||||
"collectible"
|
||||
);
|
||||
|
||||
REPLACE INTO item
|
||||
(name, display_name, description, image_url, emote_id, quote, type)
|
||||
VALUES (
|
||||
"admin_badge",
|
||||
"admin badge",
|
||||
"A badge given to bot administrators, used by the bot to identify developer privileges.",
|
||||
"https://i.imgur.com/2krfanS.png",
|
||||
1125371605485371442,
|
||||
"admin_bagde",
|
||||
"badge"
|
||||
);
|
|
@ -2,8 +2,8 @@ import discord
|
|||
from discord.ext import commands, bridge
|
||||
|
||||
from lib import checks
|
||||
from lib.embeds.error import EconErrors, GenericErrors
|
||||
from modules.economy import blackjack, sell, slots, balance, stats, give, inventory, daily
|
||||
from lib.embeds.error import EconErrors
|
||||
from modules.economy import blackjack, slots, balance, stats, give, inventory, daily
|
||||
|
||||
|
||||
class Economy(commands.Cog):
|
||||
|
@ -104,18 +104,6 @@ class Economy(commands.Cog):
|
|||
async def inventory(self, ctx):
|
||||
return await inventory.cmd(self, ctx)
|
||||
|
||||
@bridge.bridge_command(
|
||||
name="sell",
|
||||
description="Sell items from your inventory.",
|
||||
help="Sell something from your inventory. This command has no arguments because when you do the command "
|
||||
"it will lead you through the process of selling items.",
|
||||
guild_only=True
|
||||
)
|
||||
@commands.guild_only()
|
||||
@checks.allowed_in_channel()
|
||||
async def sell_command(self, ctx):
|
||||
return await sell.cmd(self, ctx)
|
||||
|
||||
@bridge.bridge_command(
|
||||
name="slots",
|
||||
aliases=["slot"],
|
||||
|
@ -136,41 +124,6 @@ class Economy(commands.Cog):
|
|||
elif isinstance(error, commands.BadArgument):
|
||||
await ctx.respond(embed=EconErrors.bad_bet_argument(ctx))
|
||||
|
||||
# @commands.slash_command(
|
||||
# name="stats",
|
||||
# description="Display your stats (BETA)",
|
||||
# guild_only=True
|
||||
# )
|
||||
# @commands.guild_only()
|
||||
# @checks.allowed_in_channel()
|
||||
# async def stats_command(self, ctx, *, game: discord.Option(choices=["BlackJack", "Slots"])):
|
||||
# return await stats.cmd(self, ctx, game)
|
||||
#
|
||||
# @commands.command(
|
||||
# name="stats",
|
||||
# aliases=["stat"],
|
||||
# help="Display your gambling stats, you can choose between \"blackjack\" or \"slots\"."
|
||||
# )
|
||||
# @commands.guild_only()
|
||||
# @checks.allowed_in_channel()
|
||||
# async def stats_command_prefix(self, ctx, *, game: str):
|
||||
#
|
||||
# if game.lower() == "blackjack" or game.lower() == "bj":
|
||||
# game = "BlackJack"
|
||||
# elif game.lower() == "slots" or game.lower() == "slot":
|
||||
# game = "Slots"
|
||||
# else:
|
||||
# raise commands.BadArgument
|
||||
#
|
||||
# return await stats.cmd(self, ctx, game)
|
||||
#
|
||||
# @stats_command_prefix.error
|
||||
# async def on_command_error(self, ctx, error):
|
||||
# if isinstance(error, commands.MissingRequiredArgument):
|
||||
# await ctx.respond(embed=EconErrors.missing_bet(ctx))
|
||||
# elif isinstance(error, commands.BadArgument):
|
||||
# await ctx.respond(embed=EconErrors.bad_argument(ctx))
|
||||
|
||||
|
||||
def setup(client):
|
||||
client.add_cog(Economy(client))
|
||||
|
|
|
@ -1,197 +0,0 @@
|
|||
import asyncio
|
||||
import logging
|
||||
|
||||
import discord
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from lib import interaction
|
||||
from services.Currency import Currency
|
||||
from services.Inventory import Inventory
|
||||
from services.Item import Item
|
||||
|
||||
logs = logging.getLogger('Racu.Core')
|
||||
|
||||
load_dotenv('.env')
|
||||
|
||||
|
||||
async def cmd(self, ctx):
|
||||
inv = Inventory(ctx.author.id)
|
||||
items = inv.get_sell_data()
|
||||
|
||||
def response_check(msg):
|
||||
return msg.author == ctx.author and msg.channel == ctx.channel
|
||||
|
||||
if not items:
|
||||
embed = discord.Embed(
|
||||
color=discord.Color.red(),
|
||||
description="You don't have any items to sell."
|
||||
)
|
||||
return await ctx.respond(embed=embed)
|
||||
|
||||
options = SellCommandOptions(items)
|
||||
view = SellCommandView(ctx, options)
|
||||
|
||||
embed = discord.Embed(
|
||||
color=discord.Color.embed_background(),
|
||||
description="Please select the item you want to sell."
|
||||
)
|
||||
await ctx.respond(embed=embed, view=view, content=ctx.author.mention)
|
||||
|
||||
await view.wait()
|
||||
item = view.item
|
||||
|
||||
if item:
|
||||
item = Item.get_item_by_display_name(view.item)
|
||||
quantity = item.get_quantity(ctx.author.id)
|
||||
|
||||
if quantity == 1:
|
||||
embed = discord.Embed(
|
||||
color=discord.Color.embed_background(),
|
||||
description=f"You selected **{item.display_name}**, you have this item only once."
|
||||
)
|
||||
await ctx.edit(embed=embed)
|
||||
amount_to_sell = 1
|
||||
|
||||
elif quantity > 1:
|
||||
embed = discord.Embed(
|
||||
color=discord.Color.embed_background(),
|
||||
description=f"You selected **{item.display_name}**, you have this item **{quantity}** times.\n"
|
||||
)
|
||||
embed.set_footer(text=f"Please type the amount you want to sell in this chat.")
|
||||
await ctx.edit(embed=embed)
|
||||
|
||||
try:
|
||||
amount_message = await self.client.wait_for('message', check=response_check, timeout=60)
|
||||
amount = amount_message.content
|
||||
|
||||
if is_number_between(amount, quantity):
|
||||
amount_to_sell = int(amount)
|
||||
|
||||
else:
|
||||
embed = discord.Embed(
|
||||
color=discord.Color.red(),
|
||||
description="Invalid input... try the command again."
|
||||
)
|
||||
return await ctx.respond(embed=embed, content=ctx.author.mention)
|
||||
|
||||
except asyncio.TimeoutError:
|
||||
await ctx.respond(
|
||||
embed=discord.Embed(description="You ran out of time.", color=discord.Color.red()),
|
||||
content=ctx.author.mention)
|
||||
# logs.warning(f"{ctx.author.id} Sell Timeout")
|
||||
return
|
||||
|
||||
else:
|
||||
embed = discord.Embed(
|
||||
color=discord.Color.red(),
|
||||
description="You dont have this item."
|
||||
)
|
||||
embed.set_footer(text="It shouldn't have showed up in the list, my apologies.")
|
||||
return await ctx.edit(embed=embed)
|
||||
|
||||
"""
|
||||
Item & amount selection finished.
|
||||
Get price, confirmation message & handle balances.
|
||||
"""
|
||||
currency = Currency(ctx.author.id)
|
||||
worth = item.get_item_worth()
|
||||
total = worth * amount_to_sell
|
||||
view = interaction.ExchangeConfirmation(ctx)
|
||||
embed = discord.Embed(
|
||||
color=discord.Color.embed_background(),
|
||||
description=f"You're about to sell **{amount_to_sell} {item.display_name}(s)** for **${total}**. "
|
||||
f"Are you absolutely sure about this?"
|
||||
)
|
||||
message = await ctx.respond(embed=embed, view=view, content=ctx.author.mention)
|
||||
await view.wait()
|
||||
|
||||
if view.clickedConfirm:
|
||||
|
||||
try:
|
||||
currency.balance += total
|
||||
currency.push()
|
||||
inv.take_item(item, amount_to_sell)
|
||||
|
||||
embed = discord.Embed(
|
||||
color=discord.Color.green(),
|
||||
description=f"You have successfully sold "
|
||||
f"**{amount_to_sell} {item.display_name}(s)** for **${total}**."
|
||||
)
|
||||
await message.edit(embed=embed, view=None)
|
||||
|
||||
except Exception as e:
|
||||
await ctx.respond("Something went wrong.")
|
||||
logs.error(f"[CommandHandler] /sell post-confirmation error: {e}")
|
||||
return
|
||||
|
||||
else:
|
||||
return await message.edit(embed=None, content=f"**{ctx.author.name}** canceled the command.")
|
||||
|
||||
else:
|
||||
embed = discord.Embed(
|
||||
color=discord.Color.red(),
|
||||
description="You selected not to sell anything."
|
||||
)
|
||||
await ctx.edit(embed=embed)
|
||||
|
||||
class SellCommandOptions(discord.ui.Select):
|
||||
def __init__(self, items: str):
|
||||
self.item = None
|
||||
|
||||
super().__init__(
|
||||
placeholder="Select an item",
|
||||
min_values=1,
|
||||
max_values=1,
|
||||
options=[
|
||||
discord.SelectOption(label=item) for item in items
|
||||
]
|
||||
)
|
||||
|
||||
async def callback(self, interaction: discord.Interaction):
|
||||
await self.view.on_select(self.values[0], interaction)
|
||||
|
||||
|
||||
class SellCommandView(discord.ui.View):
|
||||
def __init__(self, ctx, options: SellCommandOptions):
|
||||
self.ctx = ctx
|
||||
self.options = options
|
||||
self.item = None
|
||||
|
||||
super().__init__(timeout=60)
|
||||
self.add_item(self.options)
|
||||
|
||||
async def on_timeout(self):
|
||||
embed = discord.Embed(
|
||||
color=discord.Color.red(),
|
||||
description="You ran out of time."
|
||||
)
|
||||
await self.message.edit(embed=embed, view=None)
|
||||
logs.warning(f"{self.ctx.author.name}: /sell command timed out.")
|
||||
self.stop()
|
||||
|
||||
async def interaction_check(self, interaction) -> bool:
|
||||
if interaction.user != self.ctx.author:
|
||||
await interaction.response.send_message("You can't use this menu, it's someone else's!", ephemeral=True)
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
async def on_select(self, item, interaction):
|
||||
self.item = item
|
||||
await interaction.response.edit_message(view=None)
|
||||
self.stop()
|
||||
|
||||
|
||||
def is_number_between(value, upper_limit):
|
||||
try:
|
||||
# Convert the value to an integer
|
||||
number = int(value)
|
||||
|
||||
# Check if the number is between 1 and the upper limit
|
||||
if 1 <= number <= upper_limit:
|
||||
return True
|
||||
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
return False
|
|
@ -65,9 +65,6 @@ async def cmd(self, ctx, bet):
|
|||
else:
|
||||
ctx_currency.take_balance(bet)
|
||||
|
||||
# item_reward = ItemHandler(ctx)
|
||||
# await item_reward.rave_coin(is_won=is_won, bet=bet)
|
||||
|
||||
stats = SlotsStats(
|
||||
user_id=ctx.author.id,
|
||||
is_won=is_won,
|
||||
|
|
Loading…
Reference in a new issue