Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 不协调Py将消息发送到特定通道_Python_Discord.py - Fatal编程技术网

Python 不协调Py将消息发送到特定通道

Python 不协调Py将消息发送到特定通道,python,discord.py,Python,Discord.py,我正在开发我的discord机器人。 我在下命令要把信息发送到一个特定的房间,除非我做不到。。。这是我的密码: @client.command(name='say', help='Dire un message à votre place') @commands.has_permissions(send_messages=True, manage_messages=True) async def say(ctx, message, channelid): await client.wai

我正在开发我的discord机器人。 我在下命令要把信息发送到一个特定的房间,除非我做不到。。。这是我的密码:

@client.command(name='say', help='Dire un message à votre place')
@commands.has_permissions(send_messages=True, manage_messages=True)
async def say(ctx, message, channelid):
    await client.wait_until_ready()
    channel = client.get_channel(channelid)
    embed = discord.Embed(title="Message", color=discord.Color.dark_red())
    embed.add_field(name="Nouveau message de {}".format(ctx.message.author), value="{}".format(message))
    embed.set_footer(text="{}".format(ctx.message.author))
    await channel.send(embed=embed)
这是我在终点站遇到的错误

Command raised an exception: AttributeError: 'NoneType' object has no attribute 'send"
提前感谢您的回复


注:我的机器人是法语的

这里有一部分代码可以让你开始!我最近提出:

@client.event
async def on_member_join(member):
    channel = discord.utils.get(member.guild.channels, name="You can have a message as string more then one word, by doing:

@client.command(name='say', help='Dire un message à votre place')
@commands.has_permissions(send_messages=True, manage_messages=True)
async def say(ctx, channel:discord.TextChannel, message):
    #Embed making
    embed = discord.Embed(title="Message", color=discord.Color.dark_red())
    embed.add_field(name="Nouveau message de {}".format(ctx.message.author), value="{}".format(message))
    embed.set_footer(text="{}".format(ctx.message.author))

    await channel.send(embed=e)
@client.event
成员加入时的异步定义(成员):

channel=discord.utils.get(member.guild.channels,name=“这是一段可以让您开始的代码!我最近做了以下几点:

@client.event
async def on_member_join(member):
    channel = discord.utils.get(member.guild.channels, name="You can have a message as string more then one word, by doing:

@client.command(name='say', help='Dire un message à votre place')
@commands.has_permissions(send_messages=True, manage_messages=True)
async def say(ctx, channel:discord.TextChannel, message):
    #Embed making
    embed = discord.Embed(title="Message", color=discord.Color.dark_red())
    embed.add_field(name="Nouveau message de {}".format(ctx.message.author), value="{}".format(message))
    embed.set_footer(text="{}".format(ctx.message.author))

    await channel.send(embed=e)
@client.event
成员加入时的异步定义(成员):

channel=discord.utils.get(member.guild.channels,name=“通过执行以下操作,您可以将一条消息作为字符串包含多个单词:

async def say(ctx, channel:discord.TextChannel, *msg):
    message = " ".join(msg)
    #Embed making
    embed = discord.Embed(title="Message", color=discord.Color.dark_red())
    embed.add_field(name="Nouveau message de {}".format(ctx.message.author), value="{}".format(message))
    embed.set_footer(text="{}".format(ctx.message.author))

    await channel.send(embed=e)
冒号和discord.Channel表示您需要在discord屏幕上输入
#Channel
格式 要获得多字母信息,请执行以下操作:

c?say #text-channel-send Hello and Bye
星号使它成为一个元组,所以如果你这样做

" ".join(msg)
所以Hello和bye是元组的一部分,就像这样:
('Hello','and','bye')

它连接元组的元素,给你一个字符串,用空格分隔。它也适用于列表。
希望这对您有所帮助

您可以通过执行以下操作将消息作为字符串保存到多个单词中:

async def say(ctx, channel:discord.TextChannel, *msg):
    message = " ".join(msg)
    #Embed making
    embed = discord.Embed(title="Message", color=discord.Color.dark_red())
    embed.add_field(name="Nouveau message de {}".format(ctx.message.author), value="{}".format(message))
    embed.set_footer(text="{}".format(ctx.message.author))

    await channel.send(embed=e)
冒号和discord.Channel表示您需要在discord屏幕上输入
#Channel
格式 要获得多字母信息,请执行以下操作:

c?say #text-channel-send Hello and Bye
星号使它成为一个元组,所以如果你这样做

" ".join(msg)
所以Hello和bye是元组的一部分,就像这样:
('Hello','and','bye')

它连接元组的元素,给你一个字符串,用空格分隔。它也适用于列表。
希望这有帮助。get_channel(channelid)
找不到需要的频道,所以它返回
None
值。你确定
channelid
正确吗?我发送的消息是
c?请说消息720347475361267843
向上!!)看起来像
客户端。get_channel(channelid)
找不到所需的频道,因此它返回
None
值。你确定
channelid
正确吗?我在discord上发送的消息是
c?请说消息720347475361267843
向上!!)我有一个错误
命令引发了一个异常:NameError:名称'member'未定义
我有一个错误
命令引发了一个异常:NameError:名称'member'未定义
我有一个错误:
回溯(最近一次调用):文件“main.py”,第74行,在异步定义中(ctx,channel:discord.channel,message):AttributeError:module'discord'没有属性'channel'
我有一个错误:
回溯(最近一次调用):文件“main.py”,第74行,在异步定义中说(ctx,channel:discord.channel,message):AttributeError:module'discord'没有属性'channel'