我正在制作一个不和谐的翻译机器人。帮我

I'm making a discord translator bot. Help me

async def 번역모드(ctx, number, tonumber):  
    def check(m):
        return m.author == ctx.author and m.channel == ctx.channel

    print("{} and {}".format(number, tonumber))

    #if number > 3 or tonumber>3 or number < 1 or tonumber < 1 or number == tonumber:
     #   await ctx.send("There is a problem with the command. Please try again.")
      #  return     
        # 1 == kor, 2 == eng, 3 == jpn 
            
    await ctx.send("Please enter the sentence you want to translate.")

    while True:
        sentence = await client.wait_for("message", check=check)
        print("translation {}".format(sentence.content))
        if sentence.content == "stop":
                await ctx.send("The translation mode has ended.")
                break

        if sentence.content is not None:
            await ctx.send("I received a sentence.")

            if number == 1 and tonumber == 2:
                print("let's start translation")
                result1 = translator.translate(sentence.content, dest='en')
                print("{}".format(result1.text))

                await ctx.send("{}".format(result1.text))

我正在 Discord 上制作翻译机器人。 number和tonumber是选择一种语言。例如)1 == 韩语,2 == 英语,3 == 日语 接收语句成功。所以它被打印出来,它交付良好。 但是

if number == 1 and tonumber == 2:
                print("let's start a translation")
                result1 = translator.translate(sentence.content, dest='en')
                print("{}".format(result1.text))

                await ctx.send("{}".format(result1.text))

这里就不说了。 我添加了一个 print("let's start a translation") 来查看它是否在继续。 没有打印出来

为了以防万一,我把所有的代码都记下来了。

from asyncio.windows_events import NULL
from discord.ext import commands
import discord
import time
import difflib
import asyncio
import googletrans

translator = googletrans.Translator()
client = discord.Client()
token = "I'll cover it up."
intents = discord.Intents.default()
intents.members = True

client = commands.Bot(intents=intents, command_prefix='>')


@client.event
async def on_ready():
    print(client.user.name)
    print("Let's start driving the bot.")
    game = discord.Game("Somethin' on your mind? ")
    await client.change_presence(status=discord.Status.online, activity=game)


@client.event
async def on_voice_state_update(member, before, after):
    if before.channel is None and after.channel is not None:
        await member.guild.system_channel.send(
            "{} has logged on to the voice channel.".format(member.name)
        )


@client.command()
async def 정보(ctx):
    members = [member.name for member in ctx.guild.members]
    await ctx.send(
        "{} server is {} server and Members {} and  Total {} people.".format(
            ctx.guild.name, 
            ctx.guild.region, 
            members, 
            ctx.guild.member_count
        )
    )


@client.command()
async def 어드민(ctx):
    await ctx.send("This server admin is {}".format(
        ctx.guild.owner
    ))


@client.command()
async def 안녕(ctx):
    await ctx.send("You said {}, Nice to meet you {}!"
    .format(ctx.message.content, ctx.author.name
    ))






@client.command(aliases=['translate', 'tl'])
async def 번역모드(ctx, number, tonumber):  
    def check(m):
        return m.author == ctx.author and m.channel == ctx.channel

    print("{} and {}".format(number, tonumber))

    #if number > 3 or tonumber>3 or number < 1 or tonumber < 1 or number == tonumber:
     #   await ctx.send("There is a problem with the command. Please try again.")
      #  return     
        # 1 == kor, 2 == eng, 3 == jpn 
            
    await ctx.send("Please enter the sentence you want to translate.")

    while True:
        sentence = await client.wait_for("message", check=check)
        print("translation {}".format(sentence.content))
        if sentence.content == "stop":
                await ctx.send("The translation mode has ended.")
                break

        if sentence.content is not None:
            await ctx.send("I received a sentence.")

            if number == 1 and tonumber == 2:
                print("let's start translation")
                result1 = translator.translate(sentence.content, dest='en')
                print("{}".format(result1.text))

                await ctx.send("{}".format(result1.text))




client.run(token)    

我想不出办法,因为我不够好。 我用了翻译器,所以我希望它能顺利交付。 哦,还有... import "googletrans" could not resolved 还有一个警告。

注意变量 number 和 tonumber 不是整数而是字符串,因此 number 将是“1”而不是 1 同样 tonumber 将是“2”而不是 2。
你可以通过两种方式解决这个问题:

1) 第一种方式:

Before def check() function just add number=int(number) and tonumber=int(tonumber) 
  1. 第二种方式:
async def 번역모드(ctx, number, tonumber): to async def 번역모드(ctx, number:int, tonumber:int):