前提
discord.pyでbotをt作っています
もし メッセージに ○○ が入っているなら
画像を送る
というものを作っています。
そして、まず
@client.event async def on_message(message): faile = discord.File('gazou.jpg') if '○○','○○','○○','○○','○○','○○'in message.content: await message.channel.send(file=faile)
でやってみると、反応せず、今度は逆に
@client.event async def on_message(message): faile = discord.File('gazou.jpg') if '○○' in message.content: await message.channel.send(file=faile) @client.event async def on_message(message): faile = discord.File('gazou.jpg') if '○○' in message.content: await message.channel.send(file=faile) @client.event async def on_message(message): faile = discord.File('gazou.jpg') if '○○' in message.content: await message.channel.send(file=faile) @client.event async def on_message(message): faile = discord.File('gazou.jpg') if '○○' in message.content: await message.channel.send(file=faile)
とやってみたところ、最後の文しか反応しません。
調べてみたところ、pythoinは並列処理?なのでループしないといけないみたいです。
なので、もし一番目の一行に全部入れる
物が無理な場合、こちらを教えていただければ幸いです。
該当のソースコード
python
1import discord 2 3TOKEN = 00000000000000000000000000000000 4CHANNELID = 00000000000000000 5 6intents = discord.Intents.default() 7intents.message_content = True 8 9client = discord.Client(intents=intents) 10 11@client.event 12async def on_ready(): 13 print('起動しました') 14 15 16#問題の部分 17@client.event 18async def on_message(message): 19 faile = discord.File('gazou.jpg') 20 if '○○'in message.content: 21 await message.channel.send(file=faile) 22 23client.run(TOKEN)
試したこと
上に書いたように、一行に全部詰め込むのが無理だったので、福数の行にやってみましたが、無理でした
補足情報(FW/ツールのバージョンなど)
python 3.10
vscode

下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
また依頼した内容が修正された場合は、修正依頼を取り消すようにしましょう。