Skip to content

Commit 97b5587

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 32f7f2d commit 97b5587

File tree

3 files changed

+24
-26
lines changed

3 files changed

+24
-26
lines changed

bot/cogs/snippets.py

+13-14
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import asyncpg.exceptions
66
import discord
77
from discord.ext import commands
8-
98
from libs.snippets.model import create_snippet, get_snippet
109
from libs.snippets.views import SnippetPreCreationConfirmationView
1110

@@ -69,15 +68,15 @@ async def remove(self, ctx: GuildContext, name: str):
6968
@commands.guild_only()
7069
@snippet.command()
7170
async def new(
72-
self,
73-
ctx: GuildContext,
74-
name: str,
75-
*,
76-
content: Optional[str] = None,
71+
self,
72+
ctx: GuildContext,
73+
name: str,
74+
*,
75+
content: Optional[str] = None,
7776
):
7877
if (
79-
await get_snippet(self.pool, ctx.guild.id, ctx.message.author.id, name)
80-
is not None
78+
await get_snippet(self.pool, ctx.guild.id, ctx.message.author.id, name)
79+
is not None
8180
):
8281
await ctx.send(
8382
content=f"Snippet `{name}` already exists!",
@@ -173,12 +172,12 @@ async def edit(self, ctx: GuildContext, name: str, content: Optional[str]):
173172

174173
@commands.Cog.listener()
175174
async def on_snippet_create(
176-
self,
177-
guild: discord.Guild,
178-
creator: Union[discord.User, discord.Member],
179-
snippet_name: str,
180-
snippet_text: str,
181-
response_context: GuildContext,
175+
self,
176+
guild: discord.Guild,
177+
creator: Union[discord.User, discord.Member],
178+
snippet_name: str,
179+
snippet_text: str,
180+
response_context: GuildContext,
182181
):
183182
try:
184183
await create_snippet(

bot/libs/snippets/model.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44

55
SnippetHeader = namedtuple(
66
"SnippetHeader",
7-
["id", "name", "content", "uses", "owner_id", "location_id",
8-
"created_at"]
7+
["id", "name", "content", "uses", "owner_id", "location_id", "created_at"],
98
)
109

1110

1211
async def get_snippet(
13-
pool: asyncpg.pool.Pool, guild_id: int, owner_id: int, snippet_name: str
12+
pool: asyncpg.pool.Pool, guild_id: int, owner_id: int, snippet_name: str
1413
):
1514
fields_str = ",".join(SnippetHeader._fields)
1615
query = f"""
@@ -24,13 +23,14 @@ async def get_snippet(
2423

2524

2625
async def create_snippet(
27-
pool: asyncpg.pool.Pool, guild_id: int, owner_id: int, snippet_name: str,
28-
snippet_text: str
26+
pool: asyncpg.pool.Pool,
27+
guild_id: int,
28+
owner_id: int,
29+
snippet_name: str,
30+
snippet_text: str,
2931
):
3032
query = """
3133
INSERT INTO snippets (owner_id, location_id, name, content)
3234
VALUES ($1, $2, $3, $4)
3335
"""
34-
await pool.execute(
35-
query, guild_id, owner_id, snippet_name, snippet_text
36-
)
36+
await pool.execute(query, guild_id, owner_id, snippet_name, snippet_text)

bot/libs/snippets/views.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
from libs.utils import RoboView, GuildContext
21
import discord.ui
3-
2+
from libs.utils import GuildContext, RoboView
43
from rodhaj import Rodhaj
54

65

76
class SnippetCreationModal(discord.ui.Modal, title="Editing Snippet"):
87
content = discord.ui.TextInput(
98
label="Snippet message",
109
placeholder="Call me Ishmael. Some years ago—never mind "
11-
+ "how long precisely...",
10+
+ "how long precisely...",
1211
style=discord.TextStyle.paragraph,
1312
)
1413

@@ -41,7 +40,7 @@ def __init__(self, bot: Rodhaj, ctx: GuildContext, snippet_name: str, timeout=15
4140

4241
@discord.ui.button(label="Create Snippet", style=discord.ButtonStyle.green)
4342
async def create_snippet(
44-
self, interaction: discord.Interaction, button: discord.ui.Button
43+
self, interaction: discord.Interaction, button: discord.ui.Button
4544
):
4645
if interaction.user.id != self._ctx.author.id:
4746
return

0 commit comments

Comments
 (0)