fix(shard): 🐛 Update cache in new mod commands.
This commit is contained in:
@@ -29,7 +29,7 @@ class Admin(base.Cog):
|
|||||||
@commands.command(aliases=["mod"])
|
@commands.command(aliases=["mod"])
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
async def moderator(
|
async def moderator(
|
||||||
self, ctx: commands.Context, user: discord.User, toggle: bool = True
|
self, ctx: commands.Context, user: discord.User, toggle: bool | None = None
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Gives the user the Moderator role.
|
"""Gives the user the Moderator role.
|
||||||
|
|
||||||
@@ -41,13 +41,17 @@ class Admin(base.Cog):
|
|||||||
- Bot Owner
|
- Bot Owner
|
||||||
"""
|
"""
|
||||||
|
|
||||||
instance, _ = await models.User.update_or_create(
|
user: models.User = await models.User.get_or_none(id=user.id)
|
||||||
id=user.id, defaults={"is_moderator": toggle}
|
|
||||||
)
|
if user is None:
|
||||||
await instance.set_cache(self.bot.redis)
|
return await ctx.send("❌ User not found.")
|
||||||
|
|
||||||
|
user.is_moderator = toggle if toggle is not None else not user.is_moderator
|
||||||
|
await user.save()
|
||||||
|
await user.set_cache(self.bot.redis)
|
||||||
|
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
f"Toggled the moderator role {'on' if toggle else 'off'} for {user.mention}."
|
f"✅ Toggled the moderator role {'on' if user.is_moderator else 'off'} for {user.mention}."
|
||||||
)
|
)
|
||||||
|
|
||||||
@commands.command(aliases=["b"])
|
@commands.command(aliases=["b"])
|
||||||
@@ -359,6 +363,11 @@ class Admin(base.Cog):
|
|||||||
|
|
||||||
await warn.delete()
|
await warn.delete()
|
||||||
|
|
||||||
|
user: models.User = await models.User.get_or_none(id=warn.user_id)
|
||||||
|
|
||||||
|
if user:
|
||||||
|
await user.set_cache(self.bot.redis)
|
||||||
|
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
f"✅ Deleted warning `#{warn.id}` for user <@{warn.user_id}>.",
|
f"✅ Deleted warning `#{warn.id}` for user <@{warn.user_id}>.",
|
||||||
allowed_mentions=discord.AllowedMentions(users=False),
|
allowed_mentions=discord.AllowedMentions(users=False),
|
||||||
@@ -387,6 +396,11 @@ class Admin(base.Cog):
|
|||||||
|
|
||||||
await ban.delete()
|
await ban.delete()
|
||||||
|
|
||||||
|
user: models.User = await models.User.get_or_none(id=ban.user_id)
|
||||||
|
|
||||||
|
if user:
|
||||||
|
await user.set_cache(self.bot.redis)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
not await models.Ban.filter(
|
not await models.Ban.filter(
|
||||||
expressions.Q(
|
expressions.Q(
|
||||||
@@ -426,6 +440,11 @@ class Admin(base.Cog):
|
|||||||
|
|
||||||
await self.bot.unban(user_id, ctx.author.id, False)
|
await self.bot.unban(user_id, ctx.author.id, False)
|
||||||
|
|
||||||
|
user: models.User = await models.User.get_or_none(id=user_id)
|
||||||
|
|
||||||
|
if user:
|
||||||
|
await user.set_cache(self.bot.redis)
|
||||||
|
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
f"✅ Cleared the record of <@{user_id}>.",
|
f"✅ Cleared the record of <@{user_id}>.",
|
||||||
allowed_mentions=discord.AllowedMentions(users=False),
|
allowed_mentions=discord.AllowedMentions(users=False),
|
||||||
|
|||||||
Reference in New Issue
Block a user