import random
import discord
from discord.ext import commands
cad = commands.cad()
my_files=[discord.File('A:\\mar\\as.jpg'), discord.File('A:\\mar\\sa.jpg'), discord.File('A:\\mar\\ar.jpg')]
chosen_image=random.choice(my_files)
bat = ['dog', 'cat', 'lion']
@Bot.event
async def on_message(msg):
.
.
.
if any(word in msg for word in bat):
await message.channel.send(file=chosen.image)My purpose is create a discord bot who sends a random photo from a folder when it sees a specific word in message. Thus, I wrote this code and when I run this code, it work in first message but then for second, ı faced with ValueError: I/O... error. How can I fix that? Can you write true code? Thank you.
ValueError: I/O operation on closed file problem
Users browsing this thread: 1 Guest(s)
