rewrite (shops): Fix indentation.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
from typing import Type, TYPE_CHECKING
|
from typing import Type, TYPE_CHECKING, Optional
|
||||||
from weakref import WeakValueDictionary
|
from weakref import WeakValueDictionary
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
@@ -11,7 +11,7 @@ from babel.translator import LazyStr
|
|||||||
from ..data import ShopData
|
from ..data import ShopData
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from core.lion import Lion
|
from core.lion import Lion
|
||||||
|
|
||||||
|
|
||||||
class ShopCog(LionCog):
|
class ShopCog(LionCog):
|
||||||
@@ -80,7 +80,7 @@ class Customer:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def balance(self):
|
def balance(self):
|
||||||
return self.lion.data['coins']
|
return self.lion.data['coins']
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def fetch(cls, bot: LionBot, shop_data: ShopData, guildid: int, userid: int):
|
async def fetch(cls, bot: LionBot, shop_data: ShopData, guildid: int, userid: int):
|
||||||
@@ -174,27 +174,27 @@ class Store(ui.LeoUI):
|
|||||||
(Note that each Shop instance is specific to a single customer.)
|
(Note that each Shop instance is specific to a single customer.)
|
||||||
"""
|
"""
|
||||||
def __init__(self, shop: Shop, interaction: discord.Interaction, **kwargs):
|
def __init__(self, shop: Shop, interaction: discord.Interaction, **kwargs):
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
# The shop this Store is an interface for
|
# The shop this Store is an interface for
|
||||||
# Client, shop, and customer data is taken from here
|
# Client, shop, and customer data is taken from here
|
||||||
# The Shop also manages most Customer object interaction, including purchases.
|
# The Shop also manages most Customer object interaction, including purchases.
|
||||||
self.shop = shop
|
self.shop = shop
|
||||||
|
|
||||||
# The row of Buttons used to access different shops, if any
|
# The row of Buttons used to access different shops, if any
|
||||||
# Transient, will be deprecated by direct access to UILayout.
|
# Transient, will be deprecated by direct access to UILayout.
|
||||||
self.store_row = ()
|
self.store_row = ()
|
||||||
|
|
||||||
# Current embed page
|
# Current embed page
|
||||||
self.embed: Optional[discord.Embed] = None
|
self.embed: Optional[discord.Embed] = None
|
||||||
|
|
||||||
# Current interaction to use
|
# Current interaction to use
|
||||||
self.interaction: discord.Interaction = interaction
|
self.interaction: discord.Interaction = interaction
|
||||||
|
|
||||||
def set_store_row(self, row):
|
def set_store_row(self, row):
|
||||||
self.store_row = row
|
self.store_row = row
|
||||||
for item in row:
|
for item in row:
|
||||||
self.add_item(item)
|
self.add_item(item)
|
||||||
|
|
||||||
async def refresh(self):
|
async def refresh(self):
|
||||||
"""
|
"""
|
||||||
@@ -207,14 +207,14 @@ class Store(ui.LeoUI):
|
|||||||
Redraw the store UI.
|
Redraw the store UI.
|
||||||
"""
|
"""
|
||||||
if self.interaction.is_expired():
|
if self.interaction.is_expired():
|
||||||
# This is actually possible,
|
# This is actually possible,
|
||||||
# If the user keeps using the UI,
|
# If the user keeps using the UI,
|
||||||
# but never closes it until the origin interaction expires
|
# but never closes it until the origin interaction expires
|
||||||
raise ValueError("This interaction has expired!")
|
raise ValueError("This interaction has expired!")
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.embed is None:
|
if self.embed is None:
|
||||||
await self.refresh()
|
await self.refresh()
|
||||||
|
|
||||||
await self.interaction.edit_original_response(embed=self.embed, view=self)
|
await self.interaction.edit_original_response(embed=self.embed, view=self)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user