Skip to content

Commit f68d4da

Browse files
committed
chore: not even vscode knows how to git add
1 parent 5b90dfc commit f68d4da

File tree

6 files changed

+29
-22
lines changed

6 files changed

+29
-22
lines changed

.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
TOKEN=...
1+
TOKEN=...
2+
OWNER_IDS=[123, 456]

bolb_bot/__main__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ async def startup(self, *args, **kwargs):
3838
await super().startup(*args, **kwargs)
3939

4040

41-
bot = MyBot(intents=intents)
41+
ids = getenv("OWNER_IDS")
42+
assert ids is not None
43+
bot = MyBot(intents=intents, owner_ids=[int(i) for i in ids.strip("[]").split(", ")])
4244

4345

4446
if __name__ == "__main__":

bolb_bot/cogs/bolbs.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from datetime import datetime, timedelta
3+
from datetime import datetime, timedelta, timezone
44
from random import choices, randint
55
from typing import TYPE_CHECKING
66

@@ -34,11 +34,11 @@ async def bolb(self, ctx: Context):
3434
@command(description="Claim your daily bolbs", aliases=["dailyclaim"])
3535
async def daily(self, ctx: Context):
3636
async with self.bot.db.execute(
37-
"SELECT daily FROM bolb WHERE id=$1", ctx.author.id
37+
"SELECT daily FROM bolb WHERE id=?", (ctx.author.id,)
3838
) as c:
3939
row = await c.fetchone()
4040
daily_raw = row[0] if row else 0
41-
daily = datetime.fromtimestamp(daily_raw)
41+
daily = datetime.fromtimestamp(daily_raw, tz=timezone.utc)
4242

4343
next_day = daily + timedelta(days=1)
4444

@@ -59,11 +59,11 @@ async def daily(self, ctx: Context):
5959
@command(description="Claim your weekly bolbs", aliases=["weeklyclaim"])
6060
async def weekly(self, ctx: Context):
6161
async with self.bot.db.execute(
62-
"SELECT weekly FROM bolb WHERE id=$1", ctx.author.id
62+
"SELECT weekly FROM bolb WHERE id=?", (ctx.author.id,)
6363
) as c:
6464
row = await c.fetchone()
6565
weekly_raw = row[0] if row else 0
66-
weekly = datetime.fromtimestamp(weekly_raw)
66+
weekly = datetime.fromtimestamp(weekly_raw, tz=timezone.utc)
6767

6868
next_week = weekly + timedelta(weeks=1)
6969

bolb_bot/cogs/events.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
TooManyArguments,
1414
)
1515
from nextcord.utils import utcnow
16-
from nextcord import Embed
16+
from nextcord import Embed, NotFound, Forbidden
1717

1818
if TYPE_CHECKING:
1919
from nextcord import Message
@@ -45,6 +45,7 @@ async def on_message(self, message: Message):
4545
SET bolbs = bolb.bolbs + 1""",
4646
(message.author.id, 1, utcnow(), utcnow()),
4747
)
48+
await self.bot.db.commit()
4849

4950
@Cog.listener()
5051
async def on_command_error(self, ctx: Context, error: Exception):
@@ -74,26 +75,29 @@ async def on_command_error(self, ctx: Context, error: Exception):
7475
guild = ctx.guild.name
7576

7677
tb = "\n".join(format_exception(type(error), error, error.__traceback__))
77-
await painchannel.send_embed( # type: ignore
78-
desc=f"command {ctx.command} gave ```py\n{tb}```, "
79-
f"invoke: {ctx.message.content} in "
80-
f"{channel} ({name}) in {guild} by {ctx.author}"
81-
)
8278
log.error(
8379
"Command %s raised %s: %s",
8480
ctx.command,
8581
type(error).__name__,
8682
error,
8783
exc_info=True,
8884
)
85+
await ctx.send(self.bot.owner_ids)
8986

9087
for user_id in self.bot.owner_ids:
91-
user = self.bot.get_user(user_id)
92-
93-
if not user:
88+
try:
89+
user = await self.bot.fetch_user(user_id)
90+
except NotFound:
9491
continue
9592

96-
await user.send(embed=embed)
93+
try:
94+
await self.bot.get_wrapped_person(user).send_embed(
95+
desc=f"command {ctx.command} gave ```py\n{tb}```, "
96+
f"invoke: {ctx.message.content} in "
97+
f"{channel} ({name}) in {guild} by {ctx.author}"
98+
)
99+
except Forbidden:
100+
log.error("%s has dms closed smh", str(user))
97101

98102
@Cog.listener()
99103
async def on_ready(self):

poetry.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ license = "AGPL3"
88
[tool.poetry.dependencies]
99
python = "^3.9"
1010
nextcord = "^2.0.0-alpha.1"
11-
ooliver-botbase = "^1.14.1"
11+
ooliver-botbase = "^1.14.2"
1212
python-dotenv = "^0.20.0"
1313
jishaku = "^2.4.0"
1414
aiosqlite = "^0.17.0"

0 commit comments

Comments
 (0)