Improved (still partial) i18n for /stage and /user
This commit is contained in:
@@ -28,21 +28,45 @@ class CogStage(Cog):
|
|||||||
description_localizations=in_every_locale("description", "commands", "stage"),
|
description_localizations=in_every_locale("description", "commands", "stage"),
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO Introduce i18n
|
|
||||||
# TODO Maybe add an option for order?
|
# TODO Maybe add an option for order?
|
||||||
@command_group.command(
|
@command_group.command(
|
||||||
name="add",
|
name="add",
|
||||||
description="Add new event stage",
|
description=_("description", "commands", "stage_add"),
|
||||||
|
description_localizations=in_every_locale("description", "commands", "stage_add"),
|
||||||
)
|
)
|
||||||
@option(
|
@option(
|
||||||
"event",
|
"event",
|
||||||
description="Name of the event",
|
description=_("description", "commands", "stage_add", "options", "event"),
|
||||||
|
description_localizations=in_every_locale(
|
||||||
|
"description", "commands", "stage_add", "options", "event"
|
||||||
|
),
|
||||||
autocomplete=basic_autocomplete(autocomplete_active_events),
|
autocomplete=basic_autocomplete(autocomplete_active_events),
|
||||||
required=True,
|
required=True,
|
||||||
)
|
)
|
||||||
@option("question", description="Question to be answered", required=True)
|
@option(
|
||||||
@option("answer", description="Answer to the stage's question", required=True)
|
"question",
|
||||||
@option("media", description="Media file to be attached", required=False)
|
description=_("description", "commands", "stage_add", "options", "question"),
|
||||||
|
description_localizations=in_every_locale(
|
||||||
|
"description", "commands", "stage_add", "options", "question"
|
||||||
|
),
|
||||||
|
required=True,
|
||||||
|
)
|
||||||
|
@option(
|
||||||
|
"answer",
|
||||||
|
description=_("description", "commands", "stage_add", "options", "answer"),
|
||||||
|
description_localizations=in_every_locale(
|
||||||
|
"description", "commands", "stage_add", "options", "answer"
|
||||||
|
),
|
||||||
|
required=True,
|
||||||
|
)
|
||||||
|
@option(
|
||||||
|
"media",
|
||||||
|
description=_("description", "commands", "stage_add", "options", "media"),
|
||||||
|
description_localizations=in_every_locale(
|
||||||
|
"description", "commands", "stage_add", "options", "media"
|
||||||
|
),
|
||||||
|
required=False,
|
||||||
|
)
|
||||||
async def command_stage_add(
|
async def command_stage_add(
|
||||||
self,
|
self,
|
||||||
ctx: ApplicationContext,
|
ctx: ApplicationContext,
|
||||||
@@ -85,30 +109,70 @@ class CogStage(Cog):
|
|||||||
# TODO Make a nice message
|
# TODO Make a nice message
|
||||||
await ctx.respond("Event stage has been created.")
|
await ctx.respond("Event stage has been created.")
|
||||||
|
|
||||||
# TODO Implement the command
|
|
||||||
# /stage edit <event> <stage> <order> <question> <answer> <media>
|
|
||||||
@command_group.command(
|
@command_group.command(
|
||||||
name="edit",
|
name="edit",
|
||||||
description="Edit the event stage",
|
description=_("description", "commands", "stage_edit"),
|
||||||
|
description_localizations=in_every_locale("description", "commands", "stage_edit"),
|
||||||
)
|
)
|
||||||
@option(
|
@option(
|
||||||
"event",
|
"event",
|
||||||
description="Name of the event",
|
description=_("description", "commands", "stage_edit", "options", "event"),
|
||||||
|
description_localizations=in_every_locale(
|
||||||
|
"description", "commands", "stage_edit", "options", "event"
|
||||||
|
),
|
||||||
autocomplete=basic_autocomplete(autocomplete_active_events),
|
autocomplete=basic_autocomplete(autocomplete_active_events),
|
||||||
required=True,
|
required=True,
|
||||||
)
|
)
|
||||||
# TODO Add autofill
|
|
||||||
@option(
|
@option(
|
||||||
"stage",
|
"stage",
|
||||||
description="Stage to edit",
|
description=_("description", "commands", "stage_edit", "options", "stage"),
|
||||||
|
description_localizations=in_every_locale(
|
||||||
|
"description", "commands", "stage_edit", "options", "stage"
|
||||||
|
),
|
||||||
autocomplete=basic_autocomplete(autocomplete_event_stages),
|
autocomplete=basic_autocomplete(autocomplete_event_stages),
|
||||||
required=True,
|
required=True,
|
||||||
)
|
)
|
||||||
@option("order", description="Number in the event stages' order", min_value=1, required=False)
|
@option(
|
||||||
@option("question", description="Question to be answered", required=False)
|
"order",
|
||||||
@option("answer", description="Answer to the stage's question", required=False)
|
description=_("description", "commands", "stage_edit", "options", "order"),
|
||||||
@option("media", description="Media file to be attached", required=False)
|
description_localizations=in_every_locale(
|
||||||
@option("remove_media", description="Remove attached media", required=False)
|
"description", "commands", "stage_edit", "options", "order"
|
||||||
|
),
|
||||||
|
min_value=1,
|
||||||
|
required=False,
|
||||||
|
)
|
||||||
|
@option(
|
||||||
|
"question",
|
||||||
|
description=_("description", "commands", "stage_edit", "options", "question"),
|
||||||
|
description_localizations=in_every_locale(
|
||||||
|
"description", "commands", "stage_edit", "options", "question"
|
||||||
|
),
|
||||||
|
required=False,
|
||||||
|
)
|
||||||
|
@option(
|
||||||
|
"answer",
|
||||||
|
description=_("description", "commands", "stage_edit", "options", "answer"),
|
||||||
|
description_localizations=in_every_locale(
|
||||||
|
"description", "commands", "stage_edit", "options", "answer"
|
||||||
|
),
|
||||||
|
required=False,
|
||||||
|
)
|
||||||
|
@option(
|
||||||
|
"media",
|
||||||
|
description=_("description", "commands", "stage_edit", "options", "media"),
|
||||||
|
description_localizations=in_every_locale(
|
||||||
|
"description", "commands", "stage_edit", "options", "media"
|
||||||
|
),
|
||||||
|
required=False,
|
||||||
|
)
|
||||||
|
@option(
|
||||||
|
"remove_media",
|
||||||
|
description=_("description", "commands", "stage_edit", "options", "remove_media"),
|
||||||
|
description_localizations=in_every_locale(
|
||||||
|
"description", "commands", "stage_edit", "options", "remove_media"
|
||||||
|
),
|
||||||
|
required=False,
|
||||||
|
)
|
||||||
async def command_stage_edit(
|
async def command_stage_edit(
|
||||||
self,
|
self,
|
||||||
ctx: ApplicationContext,
|
ctx: ApplicationContext,
|
||||||
@@ -164,25 +228,37 @@ class CogStage(Cog):
|
|||||||
|
|
||||||
await ctx.respond("Event stage has been updated.")
|
await ctx.respond("Event stage has been updated.")
|
||||||
|
|
||||||
# TODO Implement the command
|
|
||||||
# /stage delete <event> <stage> <confirm>
|
|
||||||
@command_group.command(
|
@command_group.command(
|
||||||
name="delete",
|
name="delete",
|
||||||
description="Delete the event stage",
|
description=_("description", "commands", "stage_delete"),
|
||||||
|
description_localizations=in_every_locale("description", "commands", "stage_delete"),
|
||||||
)
|
)
|
||||||
@option(
|
@option(
|
||||||
"event",
|
"event",
|
||||||
description="Name of the event",
|
description=_("description", "commands", "stage_delete", "options", "event"),
|
||||||
|
description_localizations=in_every_locale(
|
||||||
|
"description", "commands", "stage_delete", "options", "event"
|
||||||
|
),
|
||||||
autocomplete=basic_autocomplete(autocomplete_active_events),
|
autocomplete=basic_autocomplete(autocomplete_active_events),
|
||||||
required=True,
|
required=True,
|
||||||
)
|
)
|
||||||
@option(
|
@option(
|
||||||
"stage",
|
"stage",
|
||||||
description="Stage to delete",
|
description=_("description", "commands", "stage_delete", "options", "stage"),
|
||||||
|
description_localizations=in_every_locale(
|
||||||
|
"description", "commands", "stage_delete", "options", "stage"
|
||||||
|
),
|
||||||
autocomplete=basic_autocomplete(autocomplete_event_stages),
|
autocomplete=basic_autocomplete(autocomplete_event_stages),
|
||||||
required=True,
|
required=True,
|
||||||
)
|
)
|
||||||
@option("confirm", description="Confirmation of the operation", required=False)
|
@option(
|
||||||
|
"confirm",
|
||||||
|
description=_("description", "commands", "stage_delete", "options", "confirm"),
|
||||||
|
description_localizations=in_every_locale(
|
||||||
|
"description", "commands", "stage_delete", "options", "confirm"
|
||||||
|
),
|
||||||
|
required=False,
|
||||||
|
)
|
||||||
async def command_stage_delete(
|
async def command_stage_delete(
|
||||||
self, ctx: ApplicationContext, event: str, stage: str, confirm: bool = False
|
self, ctx: ApplicationContext, event: str, stage: str, confirm: bool = False
|
||||||
) -> None:
|
) -> None:
|
||||||
|
110
cogs/cog_user.py
110
cogs/cog_user.py
@@ -5,6 +5,7 @@ from discord import (
|
|||||||
option,
|
option,
|
||||||
)
|
)
|
||||||
from discord.ext.commands import Cog
|
from discord.ext.commands import Cog
|
||||||
|
from libbot.i18n import _, in_every_locale
|
||||||
|
|
||||||
from classes import PycordUser
|
from classes import PycordUser
|
||||||
from classes.pycord_bot import PycordBot
|
from classes.pycord_bot import PycordBot
|
||||||
@@ -17,58 +18,71 @@ class CogUser(Cog):
|
|||||||
def __init__(self, bot: PycordBot):
|
def __init__(self, bot: PycordBot):
|
||||||
self.bot: PycordBot = bot
|
self.bot: PycordBot = bot
|
||||||
|
|
||||||
# TODO Introduce i18n
|
command_group: SlashCommandGroup = SlashCommandGroup(
|
||||||
command_group: SlashCommandGroup = SlashCommandGroup("user", "User management")
|
"user",
|
||||||
|
description=_("description", "commands", "user"),
|
||||||
|
description_localizations=in_every_locale("description", "commands", "user"),
|
||||||
|
)
|
||||||
|
|
||||||
# TODO Implement the command
|
# TODO Implement the command
|
||||||
@command_group.command(
|
# @command_group.command(
|
||||||
name="create_channel",
|
# name="create_channel",
|
||||||
description="Create channel for the user",
|
# description="Create channel for the user",
|
||||||
)
|
# )
|
||||||
@option(
|
# @option(
|
||||||
"user",
|
# "user",
|
||||||
description="Selected user",
|
# description="Selected user",
|
||||||
)
|
# )
|
||||||
async def command_user_create_channel(self, ctx: ApplicationContext, user: User) -> None:
|
# async def command_user_create_channel(self, ctx: ApplicationContext, user: User) -> None:
|
||||||
await ctx.respond("Not implemented.")
|
# await ctx.respond("Not implemented.")
|
||||||
|
|
||||||
# TODO Implement the command
|
# TODO Implement the command
|
||||||
@command_group.command(
|
# @command_group.command(
|
||||||
name="update_channel",
|
# name="update_channel",
|
||||||
description="Update user's channel",
|
# description="Update user's channel",
|
||||||
)
|
# )
|
||||||
@option(
|
# @option(
|
||||||
"user",
|
# "user",
|
||||||
description="Selected user",
|
# description="Selected user",
|
||||||
)
|
# )
|
||||||
async def command_user_update_channel(self, ctx: ApplicationContext, user: User) -> None:
|
# async def command_user_update_channel(self, ctx: ApplicationContext, user: User) -> None:
|
||||||
await ctx.respond("Not implemented.")
|
# await ctx.respond("Not implemented.")
|
||||||
|
|
||||||
# TODO Implement the command
|
# TODO Implement the command
|
||||||
@command_group.command(
|
# @command_group.command(
|
||||||
name="delete_channel",
|
# name="delete_channel",
|
||||||
description="Delete user's channel",
|
# description="Delete user's channel",
|
||||||
)
|
# )
|
||||||
@option(
|
# @option(
|
||||||
"user",
|
# "user",
|
||||||
description="Selected user",
|
# description="Selected user",
|
||||||
)
|
# )
|
||||||
@option("confirm", description="Confirmation of the operation", required=False)
|
# @option("confirm", description="Confirmation of the operation", required=False)
|
||||||
async def command_user_delete_channel(
|
# async def command_user_delete_channel(
|
||||||
self, ctx: ApplicationContext, user: User, confirm: bool = False
|
# self, ctx: ApplicationContext, user: User, confirm: bool = False
|
||||||
) -> None:
|
# ) -> None:
|
||||||
await ctx.respond("Not implemented.")
|
# await ctx.respond("Not implemented.")
|
||||||
|
|
||||||
# TODO Introduce i18n
|
|
||||||
@command_group.command(
|
@command_group.command(
|
||||||
name="jail",
|
name="jail",
|
||||||
description="Jail the user",
|
description=_("description", "commands", "user_jail"),
|
||||||
|
description_localizations=in_every_locale("description", "commands", "user_jail"),
|
||||||
)
|
)
|
||||||
@option(
|
@option(
|
||||||
"user",
|
"user",
|
||||||
description="Selected user",
|
description=_("description", "commands", "user_jail", "options", "user"),
|
||||||
|
description_localizations=in_every_locale(
|
||||||
|
"description", "commands", "user_jail", "options", "user"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
@option(
|
||||||
|
"confirm",
|
||||||
|
description=_("description", "commands", "user_jail", "options", "confirm"),
|
||||||
|
description_localizations=in_every_locale(
|
||||||
|
"description", "commands", "user_jail", "options", "confirm"
|
||||||
|
),
|
||||||
|
required=False,
|
||||||
)
|
)
|
||||||
@option("confirm", description="Confirmation of the operation", required=False)
|
|
||||||
async def command_user_jail(self, ctx: ApplicationContext, user: User, confirm: bool = False) -> None:
|
async def command_user_jail(self, ctx: ApplicationContext, user: User, confirm: bool = False) -> None:
|
||||||
if not (await is_operation_confirmed(ctx, confirm)):
|
if not (await is_operation_confirmed(ctx, confirm)):
|
||||||
return
|
return
|
||||||
@@ -87,16 +101,26 @@ class CogUser(Cog):
|
|||||||
f"User **{user.display_name}** has been jailed and cannot interact with events anymore."
|
f"User **{user.display_name}** has been jailed and cannot interact with events anymore."
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO Introduce i18n
|
|
||||||
@command_group.command(
|
@command_group.command(
|
||||||
name="unjail",
|
name="unjail",
|
||||||
description="Unjail the user",
|
description=_("description", "commands", "user_unjail"),
|
||||||
|
description_localizations=in_every_locale("description", "commands", "user_unjail"),
|
||||||
)
|
)
|
||||||
@option(
|
@option(
|
||||||
"user",
|
"user",
|
||||||
description="Selected user",
|
description=_("description", "commands", "user_unjail", "options", "user"),
|
||||||
|
description_localizations=in_every_locale(
|
||||||
|
"description", "commands", "user_unjail", "options", "user"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
@option(
|
||||||
|
"confirm",
|
||||||
|
description=_("description", "commands", "user_unjail", "options", "confirm"),
|
||||||
|
description_localizations=in_every_locale(
|
||||||
|
"description", "commands", "user_unjail", "options", "confirm"
|
||||||
|
),
|
||||||
|
required=False,
|
||||||
)
|
)
|
||||||
@option("confirm", description="Confirmation of the operation", required=False)
|
|
||||||
async def command_user_unjail(self, ctx: ApplicationContext, user: User, confirm: bool = False) -> None:
|
async def command_user_unjail(self, ctx: ApplicationContext, user: User, confirm: bool = False) -> None:
|
||||||
if not (await is_operation_confirmed(ctx, confirm)):
|
if not (await is_operation_confirmed(ctx, confirm)):
|
||||||
return
|
return
|
||||||
|
@@ -116,16 +116,61 @@
|
|||||||
"description": "Event stage management"
|
"description": "Event stage management"
|
||||||
},
|
},
|
||||||
"stage_add": {
|
"stage_add": {
|
||||||
"description": "",
|
"description": "Add new event stage",
|
||||||
"options": {}
|
"options": {
|
||||||
|
"event": {
|
||||||
|
"description": "Name of the event"
|
||||||
|
},
|
||||||
|
"question": {
|
||||||
|
"description": "Question to be answered"
|
||||||
|
},
|
||||||
|
"answer": {
|
||||||
|
"description": "Answer to the stage's question"
|
||||||
|
},
|
||||||
|
"media": {
|
||||||
|
"description": "Media file to be attached"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"stage_edit": {
|
"stage_edit": {
|
||||||
"description": "",
|
"description": "Edit the event stage",
|
||||||
"options": {}
|
"options": {
|
||||||
|
"event": {
|
||||||
|
"description": "Name of the event"
|
||||||
|
},
|
||||||
|
"stage": {
|
||||||
|
"description": "Stage to edit"
|
||||||
|
},
|
||||||
|
"order": {
|
||||||
|
"description": "Number in the event stages' order"
|
||||||
|
},
|
||||||
|
"question": {
|
||||||
|
"description": "Question to be answered"
|
||||||
|
},
|
||||||
|
"answer": {
|
||||||
|
"description": "Answer to the question"
|
||||||
|
},
|
||||||
|
"media": {
|
||||||
|
"description": "Media file to be attached"
|
||||||
|
},
|
||||||
|
"remove_media": {
|
||||||
|
"description": "Remove attached media"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"stage_delete": {
|
"stage_delete": {
|
||||||
"description": "",
|
"description": "Delete the event stage",
|
||||||
"options": {}
|
"options": {
|
||||||
|
"event": {
|
||||||
|
"description": "Name of the event"
|
||||||
|
},
|
||||||
|
"stage": {
|
||||||
|
"description": "Stage to delete"
|
||||||
|
},
|
||||||
|
"confirm": {
|
||||||
|
"description": "Confirmation of the operation"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"unregister": {
|
"unregister": {
|
||||||
"description": "Leave the selected event",
|
"description": "Leave the selected event",
|
||||||
@@ -142,24 +187,38 @@
|
|||||||
"description": "User management"
|
"description": "User management"
|
||||||
},
|
},
|
||||||
"user_create_channel": {
|
"user_create_channel": {
|
||||||
"description": "",
|
"description": "Create channel for the user",
|
||||||
"options": {}
|
"options": {}
|
||||||
},
|
},
|
||||||
"user_update_channel": {
|
"user_update_channel": {
|
||||||
"description": "",
|
"description": "Update user's channel",
|
||||||
"options": {}
|
"options": {}
|
||||||
},
|
},
|
||||||
"user_delete_channel": {
|
"user_delete_channel": {
|
||||||
"description": "",
|
"description": "Delete user's channel",
|
||||||
"options": {}
|
"options": {}
|
||||||
},
|
},
|
||||||
"user_jail": {
|
"user_jail": {
|
||||||
"description": "",
|
"description": "Jail the user",
|
||||||
"options": {}
|
"options": {
|
||||||
|
"user": {
|
||||||
|
"description": "Selected user"
|
||||||
|
},
|
||||||
|
"confirm": {
|
||||||
|
"description": "Confirmation of the operation"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"user_unjail": {
|
"user_unjail": {
|
||||||
"description": "",
|
"description": "Unjail the user",
|
||||||
"options": {}
|
"options": {
|
||||||
|
"user": {
|
||||||
|
"description": "Selected user"
|
||||||
|
},
|
||||||
|
"confirm": {
|
||||||
|
"description": "Confirmation of the operation"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user