Skip to content

Commit

Permalink
Merge pull request #5 from Qwizi/internationalization
Browse files Browse the repository at this point in the history
Internationalization
  • Loading branch information
Qwizi authored Mar 17, 2024
2 parents c2e4b26 + d1430ae commit fe89206
Show file tree
Hide file tree
Showing 10 changed files with 198 additions and 58 deletions.
7 changes: 3 additions & 4 deletions bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
import discord
import redis
import sentry_sdk
from dotenv import load_dotenv
from redis import ConnectionError, TimeoutError

from bot.bot import bot
from bot.cogs.match import MatchCog
from bot.i18n import i18n
from bot.logger import logger
from bot.settings import settings

load_dotenv()

bot = discord.Bot(intents=discord.Intents.all())
sentry_sdk.init(
dsn=settings.SENTRY_DSN,
environment="production" if not settings.TESTING else "development",
Expand Down Expand Up @@ -63,4 +61,5 @@ async def on_application_command_error(
logger.error(f"Redis connection error: {e}")
# Handle the error appropriately, e.g., retrying or logging
sentry_sdk.capture_exception(e)
i18n.localize_commands()
bot.run(settings.TOKEN)
5 changes: 5 additions & 0 deletions bot/bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""Bot module."""

import discord

bot = discord.Bot(intents=discord.Intents.all())
16 changes: 12 additions & 4 deletions bot/cogs/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
OnSeriesStartEvent,
)
from bot.events.listener import EventListener
from bot.i18n import _
from bot.logger import logger
from bot.schemas import CreateMatch
from bot.settings import settings
Expand All @@ -45,7 +46,7 @@ def __init__(self, bot: discord.Bot, pubsub: PubSub) -> None:
)

@match.command(guild_ids=[settings.GUILD_ID])
async def connect(self, ctx: discord.ApplicationContext) -> None:
async def link(self, ctx: discord.ApplicationContext) -> None:
"""
Get connect account link command.
Expand All @@ -59,7 +60,10 @@ async def connect(self, ctx: discord.ApplicationContext) -> None:
"""
connect_account_link = get_connect_account_link()
await ctx.respond(f"[Połącz konto]({connect_account_link})", ephemeral=True)
await ctx.respond(
f"[{_('connect_account')}]({connect_account_link})",
ephemeral=True,
)

@match.command(guild_ids=[settings.GUILD_ID])
async def create(
Expand Down Expand Up @@ -92,13 +96,17 @@ async def create(
"""
await ctx.defer()
if ctx.author.voice is None:
await ctx.followup.send("Nie jestes na kanale glosowym.", ephemeral=True)
await ctx.followup.send(
_("error_user_is_not_in_voice_channel"),
ephemeral=True,
)
return
voice_channel = ctx.author.voice.channel
members = voice_channel.members
if settings.TESTING is False and len(members) < settings.MIN_PLAYERS:
await ctx.followup.send(
"Wymange 2 graczy, by rozpoczac mecz", ephemeral=True
_("error_min_members_count", settings.MIN_PLAYERS),
ephemeral=True,
)
return
await self._create_match(ctx, match_type, members)
Expand Down
Loading

0 comments on commit fe89206

Please sign in to comment.