Python3.7を使ってます。  
初プログラミングなのと、初質問なんで、わかりにくいところがあるかもしれません。  
よければどんどん指定してください。

**ソースコード**

```

    # coding: UTF-8
    import discord
    import urllib.request
    import jso
    import re
    
    client = discord.Client()
    
    citycodes = {
        "土浦": '080020',
        "水戸": '080010',
        "札幌": '016010',
        "仙台": '040010',
        "東京": '130010',
        "横浜": '140010',
        "名古屋": '230010',
        "大阪": '270000',
        "広島": '340010',
        "福岡": '400010',
        "鹿児島": '460010',
        "那覇": '471010'
    }
    
    @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:
    
        reg_res = re.compile(u"Bot君、(.+)の天気は？").search(message.content)
        if reg_res:
    
          if reg_res.group(1) in citycodes.keys():
    
            citycode = citycodes[reg_res.group(1)]
            resp = urllib.request.urlopen('http://weather.livedoor.com/forecast/webservice/json/v1?city=%s'%citycode).read()
            resp = json.loads(resp.decode('utf-8'))
    
            msg = resp['location']['city']
            msg += "の天気は、\n"
            for f in resp['forecasts']:
              msg += f['dateLabel'] + "が" + f['telop'] + "\n"
            msg += "です。"
    
            await client.send_message(message.channel, message.author.mention + msg)
    
          else:
            await client.send_message(message.channel, "そこの天気はわかりません...")
    
    client.run("TOKEN")
    
```

**表示されたエラー**

```

    Ignoring exception in on_message
    Traceback (most recent call last):
      File "/home/pi/.local/lib/python3.7/site-packages/discord/client.py", line 270, in _run_event
        await coro(*args, **kwargs)
      File "/home/pi/Desktop/DiscordBOT/TenkiBOT/discordbot.py", line 47, in on_message
        await client.send_message(message.channel, message.author.mention + msg)
    AttributeError: 'Client' object has no attribute 'send_message'
    
```
CC BY-SA 4.0
2020-05-12T12:11:02.043
66539
2022-11-12T04:04:10.433
2020-05-12T23:19:01.680
19110
40112
question
python discord
discordbot.pyで天気を表示するbotを作っていたところエラーが出ました: 'Client' object has no attribute 'send_message'
47行目を  
`await message.channel.send(messange.author.mention + msg)`  
50行目を  
`await message.channel.send("そこの天気はわかりません...")`  
にしてみてください。それでも使えない場合は、  
`from discord.ext import commands `をして、  
`bot = commands.Bot(command_prefix='!')`を入れて、5  
50行目の後に  
`await bot.process_commands(message)`を入れてください。
CC BY-SA 4.0
2021-07-31T01:22:29.117
80492
2021-07-31T01:22:29.117
47439
66539
answer