__init__
PYL-W0201114 user_points: The total points of the user.
115 view (nextcord.ui.View, optional): The view to attach to the message.
116 """
117 self.lang = await self.get_lang()118 embed = nextcord.Embed(title=title, description=description, color=color)
119 embed.add_field(
120 name=self.lang["blackjack_your_hand"],
246 async def on_timeout(self):
247 """Handle the timeout event for the view."""
248 if not self.ended:
249 self.lang = await self.get_lang()250 await self.handle_bet_result(
251 self.interaction, BlackjackResult.DEALER_WINS, send=False
252 )
220
221 @nextcord.ui.button(label="Stand", style=nextcord.ButtonStyle.secondary)
222 async def stand_button(self, button, interaction):
223 self.lang = await self.get_lang()224 if interaction.user.id == self.author_id:
225 """
226 Handle the "Stand" button interaction.
189 button (nextcord.ui.Button): The button that was clicked.
190 interaction (nextcord.Interaction): The interaction that triggered the button click.
191 """
192 self.lang = await self.get_lang()193 user_id = self.interaction.user.id
194 user_points = (await user_handler.get_user_data(user_id))["points"]
195 if interaction.user.id == self.author_id:
164 """
165 self.author = interaction.user
166 self.channel = interaction.channel
167 self.interaction = interaction168 dropdown = DropdownSelector(
169 options=self.options,
170 placeholder=self.placeholder,
Defining an instance attribute outside __init__
affects the readability of code. It is expected to find all the attributes an instance may have by reading its __init__
method. If there is a need to initialize attribute via sub-initialization methods, it is recommended to assign attributes to None
in the init then call the sub-initialization methods.