Search code examples
pythonpython-3.xdiscord.pyuser-input

Discord.py - sending user input to another channel via the bot (Rewrite)


I'm trying to make it so that you can get user input from a specific channel after a command, and then the bot sends the user input to a different channel. Can anyone tell me any errors that I've made and how to fix them because my code doesn't seem to work? I've only recently started using the discord.py rewrite.

import discord
import os
from discord.ext import commands


client = commands.Bot(command_prefix=">")


@client.command()
async def resus(ctx):
  await ctx.send("To reserve a username type - user (your discord tag) (the username you want) (if you want verification)")
  def check(msg):
    return msg.channel.id == 873501773971726346
  
  msg = await client.wait_for("message", check=check)

  if msg.content.lower() == msg.content.lower():
    qwerty = bot.get_channel(873564203535958047)
    await qwerty.send(f"{msg}")
  else:
    await ctx.send("There has been a problem, please try again.")


@client.event
async def on_ready():
  print('We have logged in as {0.user}'.format(client))


client.run(os.getenv('TOKEN'))

Solution

  • msg.channel is a discord.TextChannel instance, tou're comparing it to an integer, that's never True. You need to compare the channel ID instead:

    def check(msg):
        return msg.channel.id == 873501773971726346