Plasma
Plasma

Reputation: 1

Variable used for user input is outputting as something different. [Discord.py]

I'm trying to take in user input multiple times in one command and have the bot repeat it but the message stores in the variable outputs as something else.

Here's the code I'm using:

@bot.command()
async def test(ctx):
  await ctx.channel.send("say something")

  try:
    message = await bot.wait_for("message", check=lambda m: m.author == ctx.author and m.channel == ctx.channel, timeout=30.0)
  except asyncio.TimeoutError:
    await ctx.channel.send("You took to long to respond")
  else:
    await ctx.channel.send(message)

And this is what message outputs as:

<Message id=1029677639088214026 channel=<TextChannel id=807970608410525747 name='bot-commands' position=1 nsfw=False news=False category_id=805140558573600819> type=<MessageType.default: 0> author=<Member id=712669578525802517 name='Plasma' discriminator='1163' bot=False nick=None guild=<Guild id=805140558125203467 name='Bot test' shard_id=None chunked=True member_count=12>> flags=<MessageFlags value=0>>

Upvotes: 0

Views: 108

Answers (1)

Jabro
Jabro

Reputation: 538

Bot.wait_for() is returning you a discord.Message object.

message = await bot.wait_for("message", check=lambda m: ...)

In order to send the content of the message, you need to send message.content, not the message object:

else:
   await ctx.channel.send(message.content)

Upvotes: 2

Related Questions