@@ -28,7 +28,14 @@ class Guess(Cog):
|
||||
await ctx.respond("Guild is not configured.")
|
||||
return
|
||||
|
||||
user: PycordUser = await self.bot.find_user(ctx.author)
|
||||
user: PycordUser = await self.bot.find_user(ctx.author, ctx.guild)
|
||||
|
||||
if user.is_jailed:
|
||||
# TODO Make a nice message
|
||||
await ctx.respond(
|
||||
"You are jailed and cannot interact with events. Please, contact the administrator."
|
||||
)
|
||||
return
|
||||
|
||||
if user.current_event_id is None or user.current_stage_id is None:
|
||||
# TODO Make a nice message
|
||||
|
@@ -40,7 +40,14 @@ class Register(Cog):
|
||||
await ctx.respond("Guild is not configured.")
|
||||
return
|
||||
|
||||
user: PycordUser = await self.bot.find_user(ctx.author)
|
||||
user: PycordUser = await self.bot.find_user(ctx.author, ctx.guild)
|
||||
|
||||
if user.is_jailed:
|
||||
# TODO Make a nice message
|
||||
await ctx.respond(
|
||||
"You are jailed and cannot interact with events. Please, contact the administrator."
|
||||
)
|
||||
return
|
||||
|
||||
if pycord_event._id in user.registered_event_ids:
|
||||
# TODO Make a nice message
|
||||
|
@@ -44,7 +44,14 @@ class Unregister(Cog):
|
||||
await ctx.respond("Guild is not configured.")
|
||||
return
|
||||
|
||||
user: PycordUser = await self.bot.find_user(ctx.author)
|
||||
user: PycordUser = await self.bot.find_user(ctx.author, ctx.guild)
|
||||
|
||||
if user.is_jailed:
|
||||
# TODO Make a nice message
|
||||
await ctx.respond(
|
||||
"You are jailed and cannot interact with events. Please, contact the administrator."
|
||||
)
|
||||
return
|
||||
|
||||
if pycord_event._id not in user.registered_event_ids:
|
||||
# TODO Make a nice message
|
||||
|
41
cogs/user.py
41
cogs/user.py
@@ -6,6 +6,7 @@ from discord import (
|
||||
)
|
||||
from discord.ext.commands import Cog
|
||||
|
||||
from classes import PycordUser
|
||||
from classes.pycord_bot import PycordBot
|
||||
|
||||
|
||||
@@ -57,7 +58,7 @@ class User(Cog):
|
||||
) -> None:
|
||||
await ctx.respond("Not implemented.")
|
||||
|
||||
# TODO Implement the command
|
||||
# TODO Introduce i18n
|
||||
@command_group.command(
|
||||
name="jail",
|
||||
description="Jail the user",
|
||||
@@ -68,9 +69,25 @@ class User(Cog):
|
||||
)
|
||||
@option("confirm", description="Confirmation of the operation", required=False)
|
||||
async def command_user_jail(self, ctx: ApplicationContext, user: User, confirm: bool = False) -> None:
|
||||
await ctx.respond("Not implemented.")
|
||||
if confirm is None or not confirm:
|
||||
await ctx.respond(self.bot._("operation_unconfirmed", "messages", locale=ctx.locale))
|
||||
return
|
||||
|
||||
# TODO Implement the command
|
||||
pycord_user: PycordUser = await self.bot.find_user(user, ctx.guild)
|
||||
|
||||
if pycord_user.is_jailed:
|
||||
# TODO Make a nice message
|
||||
await ctx.respond(f"User **{user.display_name}** is already jailed.")
|
||||
return
|
||||
|
||||
await pycord_user.jail(self.bot.cache)
|
||||
|
||||
# TODO Make a nice message
|
||||
await ctx.respond(
|
||||
f"User **{user.display_name}** has been jailed and cannot interact with events anymore."
|
||||
)
|
||||
|
||||
# TODO Introduce i18n
|
||||
@command_group.command(
|
||||
name="unjail",
|
||||
description="Unjail the user",
|
||||
@@ -81,7 +98,23 @@ class User(Cog):
|
||||
)
|
||||
@option("confirm", description="Confirmation of the operation", required=False)
|
||||
async def command_user_unjail(self, ctx: ApplicationContext, user: User, confirm: bool = False) -> None:
|
||||
await ctx.respond("Not implemented.")
|
||||
if confirm is None or not confirm:
|
||||
await ctx.respond(self.bot._("operation_unconfirmed", "messages", locale=ctx.locale))
|
||||
return
|
||||
|
||||
pycord_user: PycordUser = await self.bot.find_user(user, ctx.guild)
|
||||
|
||||
if not pycord_user.is_jailed:
|
||||
# TODO Make a nice message
|
||||
await ctx.respond(f"User **{user.display_name}** is not jailed.")
|
||||
return
|
||||
|
||||
await pycord_user.unjail(self.bot.cache)
|
||||
|
||||
# TODO Make a nice message
|
||||
await ctx.respond(
|
||||
f"User **{user.display_name}** has been unjailed and can interact with events again."
|
||||
)
|
||||
|
||||
|
||||
def setup(bot: PycordBot) -> None:
|
||||
|
Reference in New Issue
Block a user