Actual Code
import discord
import urllib.request
import json
import re
client=discord.Client()
citycode = '016010'
resp=urllib.request.urlopen('http://weather.livedoor.com/forecast/webservice/json/v1?city=%s'%citycode).read()
resp=json.loads(resp.decode('utf-8'))
@client.event
async def on_ready():
print("logged in as" + client.user.name)
@client.event
async def on_message(message):
if message.author!=client.user:
if message.content=="weather":
msg = resp ['location'] ['city']
msg+="The weather is \n"
for fin resp ['foreecasts']:
msg+=f['dateLabel']+" is "+f['telop']+"\n"
msg+="."
wait message.channel.send (message.channel, message.author.ment+msg)
client.run("token")
Error Displayed
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\yoich\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\client.py", line 227, in_run_event
wait coro (*args, **kwargs)
File "C:\Users\yoich\OneDrive\Desktop\bot General\Weathertest.py", line 27, in on_message
wait message.channel.send (message.channel, message.author.ment+msg)
TypeError: send() takes from 1 to 2 positional arguments but 3 where given
Where and how can I start it normally?Python uses python3
python python3 discord
If you change the send()
part to the following, it will work.
wait message.channel.send(message.author.ment+msg)
send()
is a method in the message.channel
class, so you have an implicit argument of self
.Therefore, the original call was to pass three arguments, including self
, and the error send() takes from 1 to 2 positional arguments but 3 where given
appears.
610 GDB gets version error when attempting to debug with the Presense SDK (IDE)
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
617 Uncaught (inpromise) Error on Electron: An object could not be cloned
911 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.