###したい事
Discord.pyの翻訳botを作りたい
###質問理由
エラー表示が起きて起動しない為
###エラー内容
Ignoring exception in on_message
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/discord/client.py", line 333, in _run_event
await coro(*args, **kwargs)
File "<string>", line 76, in on_message
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/googletrans/client.py", line 255, in detect
data = self._translate(text, 'en', 'auto', kwargs)
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/googletrans/client.py", line 78, in _translate
token = self.token_acquirer.do(text)
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/googletrans/gtoken.py", line 194, in do
self._update()
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/googletrans/gtoken.py", line 62, in _update
code = self.RE_TKK.search(r.text).group(1).replace('var ', '')
AttributeError: 'NoneType' object has no attribute 'group'
###補足
言語_Python/バージョン_3.8.3
###該当コード
Python
1elif message.content.startswith('t'): 2 say = message.content 3 say = say[7:] 4 if say.find('-') == -1: 5 str = say 6 detact = translator.detect(str) 7 befor_lang = detact.lang 8 if befor_lang == 'ja': 9 convert_string = translator.translate(str, src=befor_lang, dest='en') 10 embed = discord.Embed(title='変換結果', color=0xff0000) 11 embed.add_field(name='Befor', value=str) 12 embed.add_field(name='After', value=convert_string.text, inline=False) 13 await message.channel.send(embed=embed) 14 else: 15 convert_string = translator.translate(str, src=befor_lang, dest='ja') 16 embed = discord.Embed(title='変換結果', color=0xff0000) 17 embed.add_field(name='Befor', value=str) 18 embed.add_field(name='After', value=convert_string.text, inline=False) 19 await message.channel.send(embed=embed) 20 else: 21 trans, str = list(say.split('=')) 22 befor_lang, after_lang = list(trans.split('-')) 23 convert_string = translator.translate(str, src=befor_lang, dest=after_lang) 24 embed = discord.Embed(title='変換結果', color=0xff0000) 25 embed.add_field(name='Befor', value=str) 26 embed.add_field(name='After', value=convert_string.text, inline=False) 27 await message.channel.send(embed=embed) 28 29 if message.content.startswith('!detect'): 30 say = message.content 31 s = say[8:] 32 detect = translator.detect(s) 33 m = 'この言語は ' + detect.lang + ' と思われます' 34 await message.channel.send(m)
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。