W
W
Wolf_Yout2021-12-12 20:10:06
Python
Wolf_Yout, 2021-12-12 20:10:06

How to change language?

I'm trying to change the language, I need two languages, English and Russian
. I tried it like this:

custom_lang = {}
default_lang = ['ru']

async def determine_lang(bot, message):
    guild = message.guild
    if guild:
        return custom_lang.get(guild.id, default_lang)
    else:
        return default_lang

bot = commands.Bot(command_prefix=determine_prefix)

@bot.command()
@commands.guild_only()
@commands.has_permissions(administrator=True)
async def lang(ctx, *, lang="ru"):
    if lang == "ru":
        custom_lang[ctx.guild.id] = lang.split() or default_prefixes
        await ctx.reply(f'Окей! Я уже установил свой язык на русский!')
    if lang == "en":
        custom_lang[ctx.guild.id] = lang.split() or default_prefixes
        await ctx.reply(f'Okay, I`ve already set my language to English!')
    else:
        embed = create_embed(title="Язык указан неверно/The language is incorrect",description="Все языки/all languages:\nru - Русский\nen - English")
        return await ctx.reply(embed=embed)

@bot.command()
async def help(ctx):
    if determine_lang == 'ru':
        embedru = create_embed(title='Мои команды',description='**Обратите внимание! Вы можете поменять мой префикс через команду m!setprefix <Новый префикс>**\nm!play <url|название> - Воспроизвести что либо\nm!skip - Пропустить на данный момент играемую песню\nm!remove <id> - Удалить опред. песню\nm!queue - Посмотреть очередь либо узнать айди чтобы удалить\nm!now - Увидеть что играет **сейчас**\nm!volume <value> - изменить громкость(Изменяеться только после скипа)\nm!leave - Выйти + Стоп\nm!join - Зайти к вам в канал\nm!cat - Котик\nm!dog - Пёсик\nm!fox - Лисичка\nm!panda - Панда :>')
        await ctx.reply(embed=embedru)
    if determine_lang == 'en':
        embeden = create_embed(title='My commands',description='**Please note! You can change my prefix via command m!setprefix <New prefix>**\nm!play <url|title> - Play something\nm!skip - Skip the currently playing song\nm!remove <id> - Delete a certain song\nm! queue - View queue or know id to delete it\nm!now - See what is playing **now**\nm!volume <value> - change volume (Changes only after skip)\nm!leave - Exit + Stop\nm!join - Come to your channel\nm!cat - Kitty\nm!dog - Dog\nm!fox\nm!panda\nm!panda :>')
        await ctx.reply(embed=embeden)


But it's no use, and even then the help command stopped working

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Guerro69, 2021-12-13
@Guerro69

you didn't call the determine_lang function, the code should look like this: Also in this function where you return default_lang, you should specify the index.
if determine_lang() == 'ru':

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question