Reputation: 23
i am trying to make it say the name of the user that did ~milk, it only produces the error when you type in discord ~milk here is the code that produces the error:
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('~milk'):
await message.channel.send(message.author, 'is blessed by the Baltic Gods of Dairy')
Upvotes: 1
Views: 2284
Reputation: 46
send()
takes only 1 to 2 positional arguments meaning it could be either send()
or send(something here)
, in your code you can use either f string or , concatenation of strings like :-
await message.channel.send(f"{message.author.display_name} is blessed by the Baltic Gods of Dairy.")
or
await message.channel.send(str(message.author.display_name)+"is blessed by Baltic gods of Dairy.")
Upvotes: 1
Reputation: 3156
You are trying to pass 3 arguments to the discord instead of 2. When you try concatenate strings while passing them as arguements, always use +. If you use a comma, it treats them as separate arguments and therefore gets 3 different parameters(self,author and your message) instead of 2(self and message).
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('~milk'):
await message.channel.send(message.author+ 'is blessed by the Baltic Gods of Dairy')
Upvotes: 2
Reputation: 8010
channel.send()
takes only one argument (and the implicit self which makes it appear like 2)
You can write it like this:
await message.channel.send(f'{message.author.mention} is blessed by ...')
Upvotes: 6