Skip to content

Commit

Permalink
Merge pull request #503 from The-4th-Hokage/deepsource-transform-d8d7…
Browse files Browse the repository at this point in the history
…df88

Format code with black, yapf, autopep8 and isort
  • Loading branch information
Dhruvacube authored Feb 8, 2022
2 parents fa24037 + b651ad9 commit 75fd498
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
20 changes: 13 additions & 7 deletions minato_namikaze/lib/util/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,47 @@


class ConfirmationView(discord.ui.View):
def __init__(self, *, timeout: float, author_id: int, ctx: Context, delete_after: bool) -> None:
def __init__(self, *, timeout: float, author_id: int, ctx: Context,
delete_after: bool) -> None:
super().__init__(timeout=timeout)
self.value: Optional[bool] = None
self.delete_after: bool = delete_after
self.author_id: int = author_id
self.ctx: Context = ctx
self.message: Optional[discord.Message] = None

async def interaction_check(self, interaction: discord.Interaction) -> bool:
async def interaction_check(self,
interaction: discord.Interaction) -> bool:
if interaction.user and interaction.user.id == self.author_id:
return True
else:
await interaction.response.send_message('This confirmation dialog is not for you.', ephemeral=True)
await interaction.response.send_message(
"This confirmation dialog is not for you.", ephemeral=True)
return False

async def on_timeout(self) -> None:
if self.delete_after and self.message:
await self.message.delete()

@discord.ui.button(label='Confirm', style=discord.ButtonStyle.green)
async def confirm(self, button: discord.ui.Button, interaction: discord.Interaction):
@discord.ui.button(label="Confirm", style=discord.ButtonStyle.green)
async def confirm(self, button: discord.ui.Button,
interaction: discord.Interaction):
self.value = True
await interaction.response.defer()
if self.delete_after:
await interaction.delete_original_message()
self.stop()

@discord.ui.button(label='Cancel', style=discord.ButtonStyle.red)
async def cancel(self, button: discord.ui.Button, interaction: discord.Interaction):
@discord.ui.button(label="Cancel", style=discord.ButtonStyle.red)
async def cancel(self, button: discord.ui.Button,
interaction: discord.Interaction):
self.value = False
await interaction.response.defer()
if self.delete_after:
await interaction.delete_original_message()
self.stop()


class Context(commands.Context):
async def entry_to_code(self, entries):
width = max(len(a) for a, b in entries)
Expand Down
3 changes: 1 addition & 2 deletions minato_namikaze/slash/activities.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@


class Activities(
discord.SlashCommand,
):
discord.SlashCommand, ):
"""Get access to discord beta activities feature"""

activities: typing.Optional[typing.Literal[
Expand Down

0 comments on commit 75fd498

Please sign in to comment.