Discord.py - 通过机器人将用户输入发送到另一个频道(重写)
Discord.py - sending user input to another channel via the bot (Rewrite)
我正在努力做到这一点,以便您可以在命令后从特定频道获取用户输入,然后机器人将用户输入发送到不同的频道。谁能告诉我我犯的任何错误以及如何解决这些错误,因为我的代码似乎不起作用?我最近才开始使用 discord.py 重写。
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'))
msg.channel
是一个 discord.TextChannel
实例,您要将它与一个整数进行比较,而这绝不是 True
。您需要比较频道 ID:
def check(msg):
return msg.channel.id == 873501773971726346
我正在努力做到这一点,以便您可以在命令后从特定频道获取用户输入,然后机器人将用户输入发送到不同的频道。谁能告诉我我犯的任何错误以及如何解决这些错误,因为我的代码似乎不起作用?我最近才开始使用 discord.py 重写。
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'))
msg.channel
是一个 discord.TextChannel
实例,您要将它与一个整数进行比较,而这绝不是 True
。您需要比较频道 ID:
def check(msg):
return msg.channel.id == 873501773971726346