Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

Commit

Permalink
pass it through black
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr25691 committed Oct 30, 2023
1 parent 353d85a commit e967acc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
4 changes: 1 addition & 3 deletions commands/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
async def calculator(ctx: lightbulb.Context):
try:
if ctx.options.expression in ["0/0", "0 / 0"]:
return await ctx.respond(
"I don't know"
)
return await ctx.respond("I don't know")
result = eval(ctx.options.expression)
except ZeroDivisionError:
return await ctx.respond("Not Approved")
Expand Down
4 changes: 3 additions & 1 deletion commands/joke.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

async def fetch_joke():
async with aiohttp.ClientSession() as session:
async with session.get("https://official-joke-api.appspot.com/random_joke") as response:
async with session.get(
"https://official-joke-api.appspot.com/random_joke"
) as response:
data = await response.json()
return data

Expand Down
24 changes: 10 additions & 14 deletions commands/moderation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,34 @@


@plugin.command()
@lightbulb.option(
"reason", "Reason for the ban", type=str, required=True
)
@lightbulb.option(
"member", "The person to ban", type=hikari.Member, required=True
)
@lightbulb.option("reason", "Reason for the ban", type=str, required=True)
@lightbulb.option("member", "The person to ban", type=hikari.Member, required=True)
@lightbulb.add_checks(lightbulb.has_guild_permissions(hikari.Permissions.BAN_MEMBERS))
@lightbulb.command("ban", "Ban a user from the server")
@lightbulb.implements(lightbulb.SlashCommand)
async def ban(ctx: lightbulb.Context):
try:
await ctx.get_guild().ban(ctx.options.member, reason=ctx.options.reason)
await ctx.respond(f"{ctx.options.member} has been banned from the server for: {ctx.options.reason}")
await ctx.respond(
f"{ctx.options.member} has been banned from the server for: {ctx.options.reason}"
)
except Exception as e:
logging.error(f"An error occurred while banning {str(ctx.options.member)}: {e}")
await ctx.respond(f"An error occurred while banning {str(ctx.options.member)}")


@plugin.command()
@lightbulb.option(
"reason", "Reason for the kick", type=str, required=True
)
@lightbulb.option(
"member", "The person to kick", type=hikari.Member, required=True
)
@lightbulb.option("reason", "Reason for the kick", type=str, required=True)
@lightbulb.option("member", "The person to kick", type=hikari.Member, required=True)
@lightbulb.add_checks(lightbulb.has_guild_permissions(hikari.Permissions.KICK_MEMBERS))
@lightbulb.command("kick", "Kick a user from the server")
@lightbulb.implements(lightbulb.SlashCommand)
async def kick(ctx: lightbulb.Context):
try:
await ctx.get_guild().kick(ctx.options.member, reason=ctx.options.reason)
await ctx.respond(f"{str(ctx.options.member)} has been kicked from the server for: {ctx.options.reason}")
await ctx.respond(
f"{str(ctx.options.member)} has been kicked from the server for: {ctx.options.reason}"
)
except Exception as e:
logging.error(f"An error occurred while kicking {str(ctx.options.member)}: {e}")
await ctx.respond(f"An error occurred while kicking {str(ctx.options.member)}")
Expand Down
4 changes: 4 additions & 0 deletions commands/quote.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@

plugin = lightbulb.Plugin(name="Quote")


async def fetch_random_quote():
async with aiohttp.ClientSession() as session:
async with session.get("https://api.quotable.io/random") as response:
data = await response.json()
return data


@plugin.command()
@lightbulb.command("quote", "Fetch a random quote")
@lightbulb.implements(lightbulb.SlashCommand)
Expand All @@ -24,8 +26,10 @@ async def quote(ctx: lightbulb.Context):
except Exception as e:
await ctx.respond(f"An error occurred: {str(e)}")


def load(bot):
bot.add_plugin(plugin)


def unload(bot):
bot.remove_plugin(plugin)

0 comments on commit e967acc

Please sign in to comment.