简体   繁体   English

TypeError:send()接受1到2个位置参数,但给出了3个

[英]TypeError: send() takes from 1 to 2 positional arguments but 3 were given

Here is part of code 这是代码的一部分

@client.event
async def on_message(message):
    # we do not want the bot to reply to itself
    if message.author == client.user:
        return
    # The command /patch return a link with the latest patch note
    if message.content.startswith('/patch'):
        await message.channel.send(message.channel, 'Last patchnotes: https://www.epicgames.com/fortnite/en/news')
    # The command /rank return attribute a rank according to the K/D of the user

used discord.py 用过的discord.py

when you type /patch 当您键入/ patch

here's what the console shows 这是控制台显示的内容

Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\FeNka\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\client.py", line 227, in _run_event
    await coro(*args, **kwargs)
  File "bot.py", line 107, in on_message
    await message.channel.send(message.channel, 'Last patchnotes: https://www.epicgames.com/fortnite/en/news')
TypeError: send() takes from 1 to 2 positional arguments but 3 were given

What could be wrong? 有什么事吗

Your call should be changed to 您的通话应更改为

await message.channel.send('Last patchnotes: https://www.epicgames.com/fortnite/en/news')

send is a function of the message.channel class, and thus has access to self . sendmessage.channel类的函数,因此可以访问self Its call probably looks something like: 它的调用可能类似于:

def send(self, message):
    #does things

self is implicit here, you don't send it, and that's why it looks like 2 args were passed when 3 actually were sent self在这里是隐式的,您不发送它,这就是为什么当实际发送3 2参数时看起来像传递了2 args的原因

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 discord.py TypeError: send() 需要 1 到 2 个位置参数,但给出了 3 个 - discord.py TypeError: send() takes from 1 to 2 positional arguments but 3 were given 类型错误:send() 从 1 到 2 个位置 arguments 但给出了 3 个 discord.py - TypeError: send() takes from 1 to 2 positional arguments but 3 were given discord.py TypeError: __init__() takes from 1 to 3 positional arguments but 4 were given - TypeError: __init__() takes from 1 to 3 positional arguments but 4 were given Money 和 TypeError:__init__() 需要 1 到 2 个位置参数,但给出了 3 个 - Money and TypeError: __init__() takes from 1 to 2 positional arguments but 3 were given 类型错误:execute() 需要 2 到 3 个位置参数,但给出了 7 个 - TypeError: execute() takes from 2 to 3 positional arguments but 7 were given 类型错误:read_csv() 需要 0 到 1 个位置参数,但给出了 2 个 - TypeError: read_csv() takes from 0 to 1 positional arguments but 2 were given Python/MySQL TypeError:execute() 需要 2 到 4 个位置参数,但给出了 5 个 - Python/MySQL TypeError: execute() takes from 2 to 4 positional arguments but 5 were given 类型错误:raw_input() 需要 1 到 2 个位置参数,但给出了 4 个 - TypeError: raw_input() takes from 1 to 2 positional arguments but 4 were given Django TypeError:url()需要2到4个位置参数,但是给出了16个 - Django TypeError: url() takes from 2 to 4 positional arguments but 16 were given 继承 TypeError: __init__() 接受 1 到 2 个位置参数,但给出了 8 个 - inheritance TypeError: __init__() takes from 1 to 2 positional arguments but 8 were given
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM