Повторная установка модулей
pip uninstall discordpip uninstall asynciopip install discordpip install asyncio
Опечатки в имени модуляdiscord, а не discord.py.").async def send_random_message(channel_id, text, interval):
while True:
# Ждем случайный интервал времени
await asyncio.sleep(random.randint(interval[0], interval[1]))
# Отправляем сообщение
channel = bot.get_channel(channel_id)
await channel.send(text)
Запуск функции
asyncio.run_coroutine_threadsafe(
send_random_message(channel_id, text, (31, 40)),
bot.loop
)
Примечания:
send_random_message принимает 3 аргумента: ID канала, текст сообщения и диапазон интервалов.