Fix code style issues with Black
This commit is contained in:
@@ -3,16 +3,16 @@ from discord.ext import commands
|
||||
import discord
|
||||
from urllib.parse import quote_plus
|
||||
|
||||
|
||||
class GoogleBot(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 google link button.
|
||||
@@ -22,12 +22,12 @@ class Google(discord.ui.View):
|
||||
super().__init__()
|
||||
# we need to quote the query string to make a valid url. Discord will raise an error if it isn't valid.
|
||||
query = quote_plus(query)
|
||||
url = f'https://www.google.com/search?q={query}'
|
||||
url = f"https://www.google.com/search?q={query}"
|
||||
|
||||
# Link buttons cannot be made with the decorator
|
||||
# Therefore we have to manually create one.
|
||||
# We add the quoted url to the button, and add the button to the view.
|
||||
self.add_item(discord.ui.Button(label='Click Here', url=url))
|
||||
self.add_item(discord.ui.Button(label="Click Here", url=url))
|
||||
|
||||
|
||||
bot = GoogleBot()
|
||||
@@ -36,7 +36,7 @@ bot = GoogleBot()
|
||||
@bot.command()
|
||||
async def google(ctx: commands.Context, *, query: str):
|
||||
"""Returns a google link for a query"""
|
||||
await ctx.send(f'Google Result for: `{query}`', view=Google(query))
|
||||
await ctx.send(f"Google Result for: `{query}`", view=Google(query))
|
||||
|
||||
|
||||
bot.run()
|
||||
|
||||
Reference in New Issue
Block a user