前提・実現したいこと
anacomdaからbotを起動していたのですがPycharm(anaconda)にした後にpngファイルを呼び出すコマンドをしたら呼び出せなくなりました。
pngファイルの場所を変えたらいいのかもしれませんがどこに置けばいいかわかりません。
###現在のファイル位置
C:/Users/user/PycharmProjects/discordbot/discordbot1/bot.py
C:/Users/user/PycharmProjects/discordbot/discordbot1/b.png
発生している問題・エラーメッセージ
Ignoring exception in on_message Traceback (most recent call last): File "C:\Users\user\anaconda3\lib\site-packages\discord\client.py", line 312, in _run_event await coro(*args, **kwargs) File "C:/Users/user/PycharmProjects/discordbot/discordbot1/bot.py", line 44, in on_message await message.channel.send('a', file=discord.File('b.png')) File "C:\Users\user\anaconda3\lib\site-packages\discord\file.py", line 68, in __init__ self.fp = open(fp, 'rb') FileNotFoundError: [Errno 2] No such file or directory: 'b.png'
該当のソースコード
python
1import discord 2 3TOKEN = '' 4 5client = discord.Client() 6 7@client.event 8async def on_ready(): 9 print('Logged in') 10 11@client.event 12async def on_message(message): 13 14 if message.author.bot: 15 return 16 17 if message.content == 'a': 18 await message.channel.send('a', file=discord.File('b.png')) 19 20client.run(TOKEN)
補足情報
Win10
Python3.7
pycharm×anaconda3
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/07/24 03:59