Python3とdiscord.pyを使ってDiscordのbotを作っているのですが、"/keihou"と送ると現在発表されている警報情報を取得し投稿する(発表されていないときはその旨を投稿する)処理の実装で詰まってしまっています。
最後のawait message.channel.send.message("現在警報は発表されていません!")
の部分でAttributeError: 'function' object has no attribute 'message'と言われています。
理由がわからないので改善点などご指摘いただけると助かります????
import discord import requests import feedparser import schedule client = discord.Client() # 接続に使用するオブジェクト # 起動時に通知してくれる処理 @client.event async def on_ready(): print('ログインしました') RSS_URL_HYOGO = 'http://weather.livedoor.com/forecast/rss/warn/28.xml' RSS_URL_OSAKA = 'http://weather.livedoor.com/forecast/rss/warn/27.xml' alertfeedhyogo = feedparser.parse(RSS_URL_HYOGO) alertfeedosaka = feedparser.parse(RSS_URL_OSAKA) count = False @client.event async def on_message(message): if message.content.startswith('/keihou'): #ここから兵庫 for entry in alertfeedhyogo.entries: Information = entry.title alert = Information.rsplit("が") nums = (Information.find('警報')) if(nums!=-1): await message.channel.send(alert[0]) count = True #ここから大阪 for entry in alertfeedosaka.entries: Informations = entry.title alerts = Informations.rsplit("が") nums = (Informations.find('警報')) numm = (Informations.find('大阪市')) if(nums!=-1 and numm!=-1): await message.channel.send(alerts[0]) count = True else: count = False if(count==True): await message.channel.send.message("が発表されています!") else: await message.channel.send.message("現在警報は発表されていません!") client.run('')
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/07/26 02:09