BotBoi345
BotBoi345

Reputation: 59

Why cant I change a message to an Int in Discord.py?

I am not able to Change A Message To An Int in Discord.py. Here's the code.

@bot.command()
async def triv(message):
    v = randint(1,3)
    def check(m):
        return m.author == message.author and m.channel == message.channel
    if int(v) == int(1):
        mn = randint(1, 15)
        mn1 = randint(1, 10)
        mz = mn * mn1
        membed = discord.Embed(
            title="Here's The Question", 
            description=str(mn) + " * " + str(mn1) + '''
Type Your Answer Below.. ''',
            url=None,
            color=discord.Color.blue())
        await message.send(embed=membed)
        gt = await bot.wait_for('message', check=check)
        if int(gt) == int(mz):
            await message.send('''Its Right!!''')
        else:
            await message.send('''Its Wrong... The Answer Was `''' + str(mz) + '''`''')

Here's the error message:

TypeError: int() argument must be a string, a bytes-like object or a number, not 'Message'

Upvotes: 0

Views: 125

Answers (1)

Bagle
Bagle

Reputation: 2346

Based on your code, gt is a discord.Message object. You have to use gt.content to get what the user has said. Please view the revised code section below.

gt = await bot.wait_for('message', check=check)
if int(gt.content) == int(mz):
    await message.send('''Its Right!!''')
else:
    await message.send('''Its Wrong... The Answer Was `''' + str(mz) + '''`''')

Upvotes: 1

Related Questions