# cogs/money.py
# 略
@bot.command()
async def bag(ctx):
await open_account(ctx.author)
user = ctx.author
users = await get_bank_data()
try:
bag = users[str(user.id)]["bag"]
except:
bag = []
em = discord.Embed(title = "Bag", color = 0xFF5733)
em.set_thumbnail(url = user.avatar_url)
for item in bag:
name = item["item"]
amount = item["amount"]
em.add_field(name = name, value = amount)
await ctx.send(embed = em)
async def buySomething(user, itemName, amount):
name = None
itemName = itemName.lower()
for item in shop:
Item_Name = item["name"].lower()
if Item_Name == itemName:
name = Item_Name
price = item["price"]
break
if name == None:
return [False, 1]
cost = price * amount
users = await get_bank_data()
bal = await update_bank(user)
if bal[0] < cost :
return [False , 2]
@commands.command()
# amount = 1为默认
async def buy(self, ctx, item, amount = 1):
pass
await open_account(ctx.author)
res = await buy_this(ctx.author, item, amount)
if res[0] == False :
if res[1] == 1 :
await ctx.send("没有这个东西喔")
return
if res[1] == 2 :
await ctx.send(f"你的钱包里没有足够的钱去买 {item}")
return
await ctx.send(f"你买到了 {amount} x{item}")
<<: Day 09 - 智慧城市Go Smart Award 经历(3) - 得奖
>>: 【Day 12】使用 Systems Manager 的 Parameter Store 保存变数
昨天简单介绍过 Prometheus 了,那麽今天我们就自己架一个来玩看看吧。尝试任何一个新工具的第...
完整参考连结在底下 甚麽是网页快取? 想一想大型网站如FB、IG,或是虾皮等购物网站,如果一次有很多...
安装 stylebot 进入 邦帮忙 打开 Stylebot 开启代码页 输入以下代码 .head...
这章节是延伸v-if和v-show管理元件,如何用更简便的方式做tab页签。 v-bind:is 做...
大家好,我是长风青云。早起跟朋友约、下午无缝接轨去帮弟弟搬宿、晚上一回到家就开始做ppt和发片。累瘫...