Answer the question
In order to leave comments, you need to log in
I get an error when typing a command to send a random media file from a folder, what should I do?
(I am using Python 3.9.5) here is the code:
import os
import random
import sys
import time
from os import listdir, path
from os import system
import discord
from discord.ext import commands
from progress.bar import IncrementalBar
client = commands.Bot(command_prefix='!')
token = open('token.txt', 'r').readline()
@client.command(pass_context=True)
async def Imgs(ctx, *args, **kwargs):
author = ctx.message.author
await ctx.send(file=discord.File(random.choice(os.listdir('images/'))))
print('User ' + f'{author} use command: !Imgs')
client.run(token)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question