Fix code style issues with Black
This commit is contained in:
@@ -6,13 +6,12 @@ import discord
|
||||
class Bot(commands.Bot):
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
command_prefix=commands.when_mentioned_or('$'),
|
||||
intents=discord.Intents(guilds=True, messages=True)
|
||||
command_prefix=commands.when_mentioned_or("$"), intents=discord.Intents(guilds=True, messages=True)
|
||||
)
|
||||
|
||||
async def on_ready(self):
|
||||
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
||||
print('------')
|
||||
print(f"Logged in as {self.user} (ID: {self.user.id})")
|
||||
print("------")
|
||||
|
||||
|
||||
# Define a simple View that gives us a confirmation menu
|
||||
@@ -24,16 +23,16 @@ class Confirm(discord.ui.View):
|
||||
# When the confirm button is pressed, set the inner value to `True` and
|
||||
# stop the View from listening to more input.
|
||||
# We also send the user an ephemeral message that we're confirming their choice.
|
||||
@discord.ui.button(label='Confirm', style=discord.ButtonStyle.green)
|
||||
@discord.ui.button(label="Confirm", style=discord.ButtonStyle.green)
|
||||
async def confirm(self, button: discord.ui.Button, interaction: discord.Interaction):
|
||||
await interaction.response.send_message('Confirming', ephemeral=True)
|
||||
await interaction.response.send_message("Confirming", ephemeral=True)
|
||||
self.value = True
|
||||
self.stop()
|
||||
|
||||
# This one is similar to the confirmation button except sets the inner value to `False`
|
||||
@discord.ui.button(label='Cancel', style=discord.ButtonStyle.grey)
|
||||
@discord.ui.button(label="Cancel", style=discord.ButtonStyle.grey)
|
||||
async def cancel(self, button: discord.ui.Button, interaction: discord.Interaction):
|
||||
await interaction.response.send_message('Cancelling', ephemeral=True)
|
||||
await interaction.response.send_message("Cancelling", ephemeral=True)
|
||||
self.value = False
|
||||
self.stop()
|
||||
|
||||
@@ -46,15 +45,15 @@ async def ask(ctx: commands.Context):
|
||||
"""Asks the user a question to confirm something."""
|
||||
# We create the view and assign it to a variable so we can wait for it later.
|
||||
view = Confirm()
|
||||
await ctx.send('Do you want to continue?', view=view)
|
||||
await ctx.send("Do you want to continue?", view=view)
|
||||
# Wait for the View to stop listening for input...
|
||||
await view.wait()
|
||||
if view.value is None:
|
||||
print('Timed out...')
|
||||
print("Timed out...")
|
||||
elif view.value:
|
||||
print('Confirmed...')
|
||||
print("Confirmed...")
|
||||
else:
|
||||
print('Cancelled...')
|
||||
print("Cancelled...")
|
||||
|
||||
|
||||
bot.run('token')
|
||||
bot.run("token")
|
||||
|
||||
Reference in New Issue
Block a user