Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions events/on_command_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,26 +205,26 @@ async def on_command_error(self, ctx, error):
color=BLANK_COLOR,
).set_footer(text=f"{error.code} | {error_id}")
)
with push_scope() as scope:
scope.set_tag("error_id", error_id)
scope.set_tag("guild_id", ctx.guild.id)
scope.set_tag("user_id", ctx.author.id)
if isinstance(ctx.bot, commands.AutoShardedBot):
scope.set_tag("shard_id", ctx.guild.shard_id)
scope.set_level("error")
await bot.errors.insert(
{
"_id": error_id,
"error": str(error),
"time": datetime.datetime.now(tz=pytz.UTC).strftime(
"%m/%d/%Y, %H:%M:%S"
),
"channel": ctx.channel.id,
"guild": ctx.guild.id,
}
)
with push_scope() as scope:
scope.set_tag("error_id", error_id)
scope.set_tag("guild_id", ctx.guild.id)
scope.set_tag("user_id", ctx.author.id)
if isinstance(ctx.bot, commands.AutoShardedBot):
scope.set_tag("shard_id", ctx.guild.shard_id)
scope.set_level("error")
await bot.errors.insert(
{
"_id": error_id,
"error": str(error),
"time": datetime.datetime.now(tz=pytz.UTC).strftime(
"%m/%d/%Y, %H:%M:%S"
),
"channel": ctx.channel.id,
"guild": ctx.guild.id,
}
)

capture_exception(error)
capture_exception(error)
return

if isinstance(error, commands.CheckFailure):
Expand Down
29 changes: 23 additions & 6 deletions menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -5210,7 +5210,10 @@ async def on_timeout(self) -> None:
i.disabled = True
if not hasattr(self, "message") or not self.message:
return
await self.message.edit(view=self)
try:
await self.message.edit(view=self)
except discord.HTTPException:
pass

async def interaction_check(self, interaction: discord.Interaction, /) -> bool:
if interaction.user.id == self.user_id:
Expand Down Expand Up @@ -10039,16 +10042,25 @@ def __init__(self, bot, user_id: int, custom_callback: typing.Callable, args: li
async def on_timeout(self) -> None:
for item in self.children:
item.disabled = True
await self.message.edit(view=self)
try:
await self.message.edit(view=self)
except discord.HTTPException:
pass

async def _temp_disable(self, timer: int):
for item in self.children:
item.disabled = True
await self.message.edit(view=self)
try:
await self.message.edit(view=self)
except discord.HTTPException:
return
await asyncio.sleep(timer)
for item in self.children:
item.disabled = False
await self.message.edit(view=self)
try:
await self.message.edit(view=self)
except discord.HTTPException:
pass

async def interaction_check(self, interaction: discord.Interaction, /) -> bool:
if interaction.user.id == self.user_id:
Expand Down Expand Up @@ -11640,8 +11652,13 @@ async def erase_all_shifts(
{"Guild": interaction.guild.id, "EndEpoch": 0}
):
user_id = shift["UserID"]
member = interaction.guild.get_member(user_id) or await interaction.guild.fetch_member(user_id)
if member and member not in active_shift_users:
member = interaction.guild.get_member(user_id)
if not member:
try:
member = await interaction.guild.fetch_member(user_id)
except discord.NotFound:
continue
Comment on lines +11655 to +11660

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
member = interaction.guild.get_member(user_id)
if not member:
try:
member = await interaction.guild.fetch_member(user_id)
except discord.NotFound:
continue
try:
member = interaction.guild.get_member(user_id) or await interaction.guild.fetch_member(user_id)
except discord.NotFound:
continue

if member not in active_shift_users:
active_shift_users.append(member)

async for item in self.bot.shift_management.shifts.db.find(
Expand Down
5 changes: 5 additions & 0 deletions utils/autocompletes.py

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commands should have @commands.guild_only() decorators on them. There's no reason to do this.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ async def shift_type_autocomplete(
interaction: discord.Interaction, _: str
) -> typing.List[app_commands.Choice[str]]:
bot = interaction.client
if not interaction.guild:
return [app_commands.Choice(name="Use this command in a server", value="none")]

data = await bot.settings.find_by_id(interaction.guild.id)
if not data:
Expand Down Expand Up @@ -94,6 +96,9 @@ async def all_shift_type_autocomplete(
interaction: discord.Interaction, _: str
) -> typing.List[app_commands.Choice[str]]:
bot = (await Context.from_interaction(interaction)).bot
if not interaction.guild:
return [app_commands.Choice(name="Use this command in a server", value="none")]

data = await bot.settings.find_by_id(interaction.guild.id)
if not data:
return [app_commands.Choice(name="Default", value="Default")]
Expand Down