I am currently programming a Discord Bot for a friend. I have a new PC and now the following error occured after using my "!meme" command. It worked on my old Laptop, but i dont have it anymore...
Code for the command:
elif '!meme' in message.content:
random_message_i = ["Here you go:", "Classic one:", "This one is good:", "lol xD:"]
await message.channel.send(f"{random.choice(random_message_i)}")
meme_file_paths = [os.path.abspath(_) for _ in glob.glob("botmemes/*.png")]
random_meme_i = random.choice(meme_file_paths)
await message.channel.send(file=discord.File(random_meme_i))
print("[INFO] Last command: !meme")
Error:
Traceback (most recent call last):
File "C:\Users\cxyro\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 409, in _run_event
await coro(*args, **kwargs)
File "c:\Users\cxyro\Desktop\DiscordBot\discordbot.py", line 103, in on_message
random_meme_i = random.choice(meme_file_paths)
File "C:\Users\cxyro\AppData\Local\Programs\Python\Python310\lib\random.py", line 378, in choice
return seq[self._randbelow(len(seq))]
IndexError: list index out of range
(Yes, the code ant the memes are in the same main folder...)
Can somebody help me?
print(meme_file_paths)…!?meme_file_pathsis an empty list. That was the point of the previous comment.