mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-22 02:37:57 -05:00
[V3 i18n] Internationalise help for commands and cogs (#1143)
* Framework for internationalised command help * Translator for class docstring of cog * Remove references to old context module * Use CogManagerUI as PoC * Replace all references to RedContext * Rename CogI18n object to avoid confusion * Update docs * Update i18n docs. * Store translators in list instead of dict * Change commands module to package, updated refs in cogs * Updated docs and more references in cogs * Resolve syntax error * Update from merge
This commit is contained in:
@@ -1,16 +1,15 @@
|
||||
from copy import copy
|
||||
from discord.ext import commands
|
||||
import asyncio
|
||||
import inspect
|
||||
import discord
|
||||
|
||||
from redbot.core import RedContext, Config, checks
|
||||
from redbot.core.i18n import CogI18n
|
||||
from redbot.core import Config, checks, commands
|
||||
from redbot.core.i18n import Translator
|
||||
|
||||
_ = CogI18n("Warnings", __file__)
|
||||
_ = Translator("Warnings", __file__)
|
||||
|
||||
|
||||
async def warning_points_add_check(config: Config, ctx: RedContext, user: discord.Member, points: int):
|
||||
async def warning_points_add_check(config: Config, ctx: commands.Context, user: discord.Member, points: int):
|
||||
"""Handles any action that needs to be taken or not based on the points"""
|
||||
guild = ctx.guild
|
||||
guild_settings = config.guild(guild)
|
||||
@@ -25,7 +24,7 @@ async def warning_points_add_check(config: Config, ctx: RedContext, user: discor
|
||||
await create_and_invoke_context(ctx, act["exceed_command"], user)
|
||||
|
||||
|
||||
async def warning_points_remove_check(config: Config, ctx: RedContext, user: discord.Member, points: int):
|
||||
async def warning_points_remove_check(config: Config, ctx: commands.Context, user: discord.Member, points: int):
|
||||
guild = ctx.guild
|
||||
guild_settings = config.guild(guild)
|
||||
act = {}
|
||||
@@ -39,10 +38,10 @@ async def warning_points_remove_check(config: Config, ctx: RedContext, user: dis
|
||||
await create_and_invoke_context(ctx, act["drop_command"], user)
|
||||
|
||||
|
||||
async def create_and_invoke_context(realctx: RedContext, command_str: str, user: discord.Member):
|
||||
async def create_and_invoke_context(realctx: commands.Context, command_str: str, user: discord.Member):
|
||||
m = copy(realctx.message)
|
||||
m.content = command_str.format(user=user.mention, prefix=realctx.prefix)
|
||||
fctx = await realctx.bot.get_context(m, cls=RedContext)
|
||||
fctx = await realctx.bot.get_context(m, cls=commands.Context)
|
||||
try:
|
||||
await realctx.bot.invoke(fctx)
|
||||
except (commands.CheckFailure, commands.CommandOnCooldown):
|
||||
@@ -69,7 +68,7 @@ def get_command_from_input(bot, userinput: str):
|
||||
return "{prefix}" + orig, None
|
||||
|
||||
|
||||
async def get_command_for_exceeded_points(ctx: RedContext):
|
||||
async def get_command_for_exceeded_points(ctx: commands.Context):
|
||||
"""Gets the command to be executed when the user is at or exceeding
|
||||
the points threshold for the action"""
|
||||
await ctx.send(
|
||||
@@ -102,7 +101,7 @@ async def get_command_for_exceeded_points(ctx: RedContext):
|
||||
return command
|
||||
|
||||
|
||||
async def get_command_for_dropping_points(ctx: RedContext):
|
||||
async def get_command_for_dropping_points(ctx: commands.Context):
|
||||
"""
|
||||
Gets the command to be executed when the user drops below the points
|
||||
threshold
|
||||
|
||||
Reference in New Issue
Block a user